descriptive statistics for numeric variables types of measures: measures of location measures of...
TRANSCRIPT
Descriptive Statistics for Numeric Variables
Types of Measures:measures of locationmeasures of spread
measures of relative spreadingmeasures of shape
What to describe?
• What is the “location” or “center” of the data? (“measures of location”)
• How do the data vary? (“measures of variability”)
Measures of Location
• Mean
• Median
• Mode
Mean
• Another name for average.
• If describing a population, denoted as , the greek letter i.e. “mu”. (PARAMETER)
• If describing a sample, denoted as , called “x-bar”. (STATISTIC)
• Appropriate for describing measurement data.
• Seriously affected by unusual values called “outliers”.
x
Calculating Sample Mean
Formula:
That is, add up all of the data points and divide by the number of data points.
Data (# ER arrivals in 1 hr): 2 8 3 4 1
Sample Mean = (2+8+3+4+1)/5
= 3.6 arrivals
n
xx
n
ii
1
Median
• Another name for 50th percentile.
• Appropriate for describing measurement data.
• “Robust to outliers,” that is, not affected much by unusual values.
Calculating Sample Median
Order data from smallest to largest.
If odd number of data points, the median is the middle value.
Data (# ER arrivals in 1 hr.): 2 8 3 4 1
Ordered Data: 1 2 3 4 8
Median
Calculating Sample Median
Order data from smallest to largest.
If even number of data points, the median is the average of the two middle values.
Data (# ER arrivals in 1 hr.): 2 8 3 4 1 8
Ordered Data: 1 2 3 4 8 8
Median = (3+4)/2 = 3.5
Mode
• The value that occurs most frequently.
• One data set can have many modes.
• Appropriate for all types of data, but most useful for categorical data or discrete data with only a few number of possible values.
In JMP: Heart Attack Data• Select Analyze Distribution (JMP Demo
)
In JMP: Heart Attack Data
Sample sizen = 45 (don’t use N)
The most appropriate measure of location depends on …
the shape of the data’s distribution. e.g.
Most appropriate measure of location
• Depends on whether or not data are “symmetric” or “skewed”.
• Depends on whether or not data have one (“unimodal”) or more (“multimodal”) modes.
Cholesterol Level of Heart Attack Patients - Symmetric and Unimodal (approx.)
Cholesterol Level of Heart Attack Patients - Symmetric and Unimodal (approx.)
The mean and the median are approximately the same as this distribution is nearly symmetric.
Slight right skewness – see measures of shape.
Heights of College Students - Symmetric and Bimodal
Heights of College Students - Symmetric and Bimodal
Variable n Mean Median StdDev Males 84 70.048 70.000 3.030 Females 89 64.798 65.000 2.877 All 176 67.313 67.000 4.017
Variable SE Mean Min Max Q1 Q3Males 0.331 63.0 76.0 68.0 72.0Females 0.305 56.0 77.0 63.0 67.0All 0.303 56.0 77.0 64.0 70.0
Heights of College Students - Symmetric and Bimodal
Mean height for females Mean height for males
Overall mean
Systolic Volume for Heart Attack Patients - Skewed Right
•Sample mean (79.42) is substantially larger than the sample median (67.00), median is “better” measure of average.
•Skewness statistic is > 1 suggesting pronounced right skewness (see measures of shape).
Time Until Outcome for Heart Attack Patients - Skewed Left
•Sample mean (112.4) is substantially smaller than the sample median (138.00), median is “better” measure of average.
•Skewness statistic is < - 1 suggesting pronounced left skewness (see measures of shape)
Choosing Appropriate Measure of Location
• If data are symmetric, the mean, median, and mode will be approximately the same.
• If data are multimodal, report the mean, median and/or mode for each subgroup.
• If data are skewed, report the median.
Measures of Variability
• Range
• Interquartile range (IQR)
• Variance and standard deviation
• Coefficient of variation (CV)
Range
• The difference between largest and smallest data point.
• Highly affected by outliers.
• Best for symmetric data with no outliers.
Cholesterol Level of Heart Attack Patients - Symmetric and Unimodal (approx.)
Cholesterol Level of Heart Attack Patients - Symmetric and Unimodal (approx.)
Max. = 93 (mmoles/l)
Min. = 38 (mmoles/l)
Range = 93 – 38 = 55 (mmoles/l)
Interquartile range
• The difference between the “third quartile” (75th percentile) and the “first quartile” (25th percentile). So, the “middle-half” of the values.
• IQR = Q3-Q1
• Robust to outliers or extreme observations.
• Works well for skewed data.
Systolic Volume for Heart Attack Patients - Skewed Right
•Q3 = 92.50 Q1 = 52.50 IQR = 92.50 – 52.50 = 40.0
•The range of the middle 50% of systolic volumes is 40 mmoles/l.
Q3
Q1
Variance
• If measuring variance of population, denoted by 2 (“sigma-squared”).
• If measuring variance of sample, denoted by s2
(“s-squared”).
• Measures average squared deviation of data points from their mean.
• Highly affected by outliers. Best for symmetric data.
• Problem is units are squared.
Formula for the Sample Variance (s2)
1
)(1
2
2
n
xxs
n
ii
This is nearly (if not for the n-1 in the denominator) the average squared deviation from the sample mean for our observed data.
Standard deviation
• Sample standard deviation is square root of sample variance, and so is denoted by s.
• Units are the original units.
• Measures “average” deviation of data points from their mean.
• Also, highly affected by outliers.
Sleep Study: Comparing Time to Fall Asleep of Smokers vs. Non-smokers
What differences in distribution of time to fall asleep do we see when comparing the smokers to non-smokers in this study?
1) Typical time to fall asleep is 20-21 minutes for both populations.
2) IQR for smokers is twice that for non-smokers.
3) Distribution for non-smokers is approx. normal, not so for smokers.
Sleep Study: Comparing Time to Fall Asleep of Smokers vs. Non-smokers
Smokers Non-smokers
s = 3.69 minutes > s = 2.28 minutes
IQR = 7.05 minutes > IQR = 3.00 minutes
Empirical Rule – The standard deviation and the normal distribution
For unimodal, moderately symmetrical, sets of data approximately:
• 68% of observations lie within 1 standard deviation of the mean.
• 95% of observations lie within 2 standard deviations of the mean.
i.e. Normally Distributed Data
x
The Empirical Rule
x - s x x + s
68% within1 standard deviation
34% 34%
The Empirical Rule
x - 2s x - s x x + 2sx + s
68% within1 standard deviation
34% 34%
95% within 2 standard deviations
The Empirical Rule
13.5% 13.5%
x - 3s x - 2s x - s x x + 2s x + 3sx + s
68% within1 standard deviation
34% 34%
95% within 2 standard deviations
99.7% of data are within 3 standard deviations of the mean
The Empirical Rule
0.1% 0.1%
2.4% 2.4%
13.5% 13.5%
Application of Empirical Rule – Medical Lab Tests
When you have blood drawn and it is screened for different chemical levels, any results two standard deviations below or two standard deviations above the mean for healthy individuals will get flagged as being abnormal.
Example: For potassium, healthy individuals have a mean level 4.4 meq/l with a SD of .45 meq/l
Individuals with levels outside the range :4.4 – 2(.45) to 4.4 + 2(.45)
3.5 meq/l to 5.3 meq/l would be flagged as having abnormal potassium.
sx 2
Coefficient of Variation (CV)
• Ratio of sample standard deviation to sample mean multiplied by 100.
• Measures relative variability, that is, variability relative to the magnitude of the data.
• Unitless, so good for comparing variation between two groups and for comparing variability of measurements in completely different scales and/or units.
%100x
sCV
Heart Attack Data: Which volume measure has more variation, systolic or diastolic?
SYSVOLCV = 39.95/79.42
= 50.3%
DIAVOL
CV = 48.79/158.93
= 30.7%
Thus systolic volume has the greater variation in our sample on the basis of the CV.
The most appropriate measure of variability depends on …
the shape of the data’s distribution.
Choosing Appropriate Measure of Variability
• If data are symmetric, with no serious outliers, use range and standard deviation.
• If data are skewed, and/or have serious outliers, use IQR.
• If comparing variation across two variables, use coefficient of variation if the variables are in different units and/or scales. If the scales and units are roughly the same direct comparison of the standard deviation is fine.
Measures of Shape – Skewness and KurtosisStatistical software packages will give some
measure of skewness and kurtosis for a given numeric variable.
Skewness measures departure from symmetry and is usually characterized as being left or right skewed as seen previously.
Kurtosis measures “peakedness” of a distribution and comes in two forms, platykurtosis and leptokurtosis.
Skewness
Pearson’s Skewness Coefficient
Fisher’s Measure of Skewness has a complicated formula but most software packages compute it.
Fisher’s Skewness > 1.00 moderate right skewness > 2.00 severe right skewness
Fisher’s Skewness < -1.00 moderate left skewness
< -2.00 severe right skewness
s
medianxSkewness
If skewness < -.20 severe left skewness
If skewness > +.20 severe right skewness
Skewness
Skewness = -.5786
Suggesting slight left skewness.
Skewness = 1.944
Suggesting strong right skewness.
KurtosisMeasures peakedness of a distribution.
Normal distribution has Kurtosis = 0.
Leptokurtotic distributions are more peaked than normal with fatter tails,Kurtosis > 0
Platykurtotic distributions are less peaked (squashed normal) than normal,Kurtosis < 0
KurtosisExample 1: Blood pH levels for subjects in right heart catheter study. Here we see slightly left skewed (-1.22) but markedly leptokurtotic (3.49) distribution. The reference normal curve has been added and blue curve is the density estimate from the data.
Example 2: Kurtosis
Times to fall asleep for non-smokers are approx. normal as both skewness and kurtosis are close to 0.
Times to fall asleep for smokers are fairly platykurtotic.
Kurtosis = -1.50
Transformations to Improve Normality (removing skewness)
Many statistical methods require that the numeric variables you are working with have an approximately normal distribution.
Reality is that this is often times not the case. One of the most common departures from normality is skewness, in particular, right skewness.
2V
UP
) as thisofthink ( log 010 VV
V1
21V
3V
4VBiggerImpact
BiggerImpact
3 V
2 V
. . .
.
. . .
.V Middle rung:
No transformation( = 1)
Middle rung:No transformation
( = 1)
DOWN
Here V represents our variable of interest. We are going to consider this variable raised to a power , i.e. V
Here V represents our variable of interest. We are going to consider this variable raised to a power , i.e. V
We go up the ladder to remove left skewness and down the ladder to remove right skewness.
We go up the ladder to remove left skewness and down the ladder to remove right skewness.
Right skewed
Left skewed
Tukey’s Ladder of Powers
Tukey’s Ladder of Powers
• To remove right skewness we typically take the square root, cube root, logarithm, or reciprocal of a the variable etc., i.e. V.5, V.333, V0, V-1, etc.
• To remove left skewness we raise the variable to a power greater than 1, such as squaring or cubing the values, i.e. V2, V3, etc.
Removing Right Skewness
LI-PDP LIPDP 3 LIPDP )(log10 LIPDP
Example: PDP-LI levels for cancer patients
In the log base 10 scale the PDP-LI values are approximately normally distributed.