View
212
Download
0
Embed Size (px)
Citation preview
Hyp Test II: 1
Hypothesis Testing: Additional Applications
In this lesson we consider a series of
examples that parallel the situations we
discussed for confidence interval estimation.
We will also focus on computer analysis for
conducting hypothesis tests
Hyp Test II: 2
Applications we will consider:
1. One population, 2 known – test of the mean, .
2. One Normal population, 2 Unknown, test of mean,
(We have already done several examples of 1&2).
3. 3. Paired, Normally distributed data – test of the
mean within subject difference, d.
4. Two Independent Normal populations, test of
equality of 1 and 2:
a. UNknown Variances, assumed equal: 12 2
2
b. UNknown Variances, assumed UNequal: 12
22
Hyp Test II: 3
Applications continued:
5. One Normal population – test of the variance, 2 .
6. Two Independent Normal distributions,
test of equality of variances, 12 and 2
2.
7. One Binomial Distribution – test of proportion,
Hyp Test II: 4
Application 3: Paired Normally Distributed Data:
Test of d 1. Research Question
Ten patients participated in a study to determine if a diet low in fat is effective in “reducing cholesterol.”
Cholesterol levels were measured prior to and following treatment.
Is there a mean decrease in cholesterol level after the diet?
Hyp Test II: 5
This is paired data: ID Pre Post1 200 1922 178 170…… …10222 195
• We are interested in whether the within-subject difference, post-pre, is close to zero, indicating no change, or far from zero, indicating a real change.
2. Assumptions
The change in cholesterol levels are a random sample from a normal distribution with unknown variance.
Hyp Test II: 6
3. Specify Ho and Ha
Ho: d = 0
Ha: d 0
• While a one-sided test might be of interest, it is
possible that cholesterol could increase
• so we are interested in change in either direction.
4. Test statistic:
Variance UNknown suggests we use a t-statistic:
1/
d don
d
xt
s n
Hyp Test II: 7
5. Decision Rule
Compare p-value to type I error set at .05 .
Reject Ho for p<.05 .
6. Calculations
We have n=10, and after computing a
difference for each subject find:
xd = -15.1 sd = 13.34 se = 4.22
15.1 03.58
4.22/d do
d
xt
s n
Hyp Test II: 8
Achieved Significance (P-value):
9(2)Pr[ 3.58] 2(.0030) .006p t
7. Statistical Decision
Since .006 < .05 p-value < type I error
REJECT Ho
8. Conclusion
This sample suggests that the low fat diet was effective in lowering cholesterol – since a negative change indicates a decreased level post-diet.
Hyp Test II: 9
9. 95% Confidence Interval Estimate
x t9; .975 (se) = -15.1 2.26(4.22) = (-24.6, -5.6).
• This agrees with our conclusion in step 8:
• The confidence interval does not include zero
• in fact the upper limit of the interval is less than zero, indicating we are “confident” that there is a true mean decrease
Hyp Test II: 10
Notes:
In this example, we wanted to test whether the within-subject mean difference was equal to zero.
• This type of test is known as a PAIRED t-TEST.
• Some computer packages offer a special computation of a paired t-test.
• In other software you must first compute the within-subject differences, and then conduct a
one-sample t-test, with 0 = 0
• Both strategies are available in Minitab
Hyp Test II: 11
Change in Cholesterol Data in Minitab
To compute within subject differences use: Calc Calculator
Name new variable
Type in expression to compute using variables and operators:
Hyp Test II: 12
Change in Cholesterol Data in Minitab with computed within-subject difference
Hyp Test II: 13
Using Minitab: 1-Sample t-test on Differences:
Stat Basic Statistics 1-Sample t
Select Difference Variable
Test Mean is Zero
Hyp Test II: 14
T-Test of the Mean
Test of mu = 0.00 vs mu not = 0.00
Variable N Mean StDev SE Mean T PPost_Pre 10 -15.10 13.34 4.22 -3.58 0.0059
Hyp Test II: 15
Using Minitab: Paired t-test:
Stat Basic Statistics Paired t
Select the 2 variables
Options lets you set mean and confidence level.
Hyp Test II: 16
Paired T-Test and Confidence IntervalPaired T for Post - Pre N Mean StDev SE MeanPost 10 196.90 18.72 5.92Pre 10 212.00 19.78 6.25Difference 10 -15.10 13.34 4.22
95% CI for mean difference: (-24.64, -5.56)T-Test of mean difference = 0 (vs not = 0): T-Value = -3.58 P-Value = 0.006
Hyp Test II: 17
Application 4: Two Independent Normal Populations
Test of Equality of Means
a. Unknown (EQUAL) variances
1. Research Question
In the ICU study, data was collected on 25
consecutive patients, on the type of admission,
elective or emergency, and on patient age at
admission.
Is the mean patient age the same for emergency
as for elective admission patients?
Hyp Test II: 18
2. Assumptions
• Independent samples from normal distributions
• This is equivalent to taking 2 separate
independent samples of consecutive
emergency admissions and consecutive
elective admissions.
• Assume 12 0
2 2 is unknown.
3. Specify Ho and Ha
Ho: 1 0 0 (There is no difference in mean age)
Ha: 1 0 0 (The mean ages differ)
Hyp Test II: 19
4. Test statistic:
• Variance UNknown t-statistic
• Variances assumed equal pooled variance est.
1 0
1 0 1 0( 1) ( 1) 2 2
1 0
( ) ( )on n
p p
x xt
s s
n n
5. Decision Rule
Calculate achieved significance (P-value)
Reject Ho when p-value is less than type I error
of .05
Hyp Test II: 20
6. Calculations Statistics on Age:
Admit N Mean StDev
0.Elective 14 60.29 19.83
1.Emergency 11 52.64 25.17
Pooled Variance:
Test Statistic:
1 0 1 0
2 2
1 0
( ) ( ) (52.64 60.29) 0.851
497.71 497.7111 14
o
p p
x xt
s s
n n
2 2 2 22 1 1 0 0
1 0
( 1) ( 1) 10(25.17) 13(19.83)497.71
( 1) ( 1) 10 13p
n s n ss
n n
Hyp Test II: 21
Achieved Significance (P-value):
1 0( 1) ( 1) 10 13 23df n n
23(2)Pr[ 0.851] 2(.2018) .4036p t
7. Statistical Decision
Since p-value > .05
There is insufficient evidence to reject the null hypothesis: do NOT reject
8. Conclusion
The data do not indicate a statistically significant difference in the mean age between elective and emergency patients.
Hyp Test II: 22
9. 95% Confidence Interval Estimate
(x1 – x0) t23; .975 (se) = - 7.65 2.069 (8.99)
= (-26.24, 10.95).
• This agrees with our conclusion in step 8:
• The confidence interval includes zero
• While the sample means differ by almost 8 years, the variability in age is large, so this difference is not significant.
• If you feel 8 years is an important difference – failing to find this significant may be an issue of inadequate power
Hyp Test II: 23
In MINITAB: Enter data with 2 variables:
• Admit: admission status, 1=Emergency, 0=Elective
• Age: patient age in years
Hyp Test II: 24
Using MINITAB: Stat Basic Stats 2-Sample t
Samples: analysis variable
Subscripts: variable defining groupsCheck to use pooled
variance estimate
Hyp Test II: 25
Two-Sample T-Test and CI:
Two-sample T for age
admit N Mean StDev SE Mean0 14 60.3 19.8 5.31 11 52.6 25.2 7.6
Difference = mu (0) - mu (1)Estimate for difference: 7.6595% CI for difference: (-10.94, 26.24)T-Test of difference = 0 (vs not =): T-Value = 0.85 P-Value = 0.404 DF = 23Both use Pooled StDev = 22.3
Hyp Test II: 26
Application 4: Two Independent
Normals
Test of Equality of
Means
b. UNknown (UNEQUAL)
Variances1. Research Question
In the ICU study, data collected on these patients included the hospital length of stay (LOS) in days.
Is the mean length of stay the same for emergency admission as for elective admission patients?
Hyp Test II: 27
2. Assumptions
• Independent samples from normal distributions
• This is equivalent to taking 2 separate
independent samples of consecutive
emergency admissions and consecutive
elective admissions.
• Assume 12 2
2 unknown.
3. Specify Ho and Ha
Ho: 1 o 0 (No difference in means)
Ha: 1 o 0 (Means are different)
Hyp Test II: 28
4. Test statistic:
• use separate estimates of the variances of each sample
• Satterthwaite’s degrees of freedom
1 0 1 0
2201
1 0
( ) ( )ox xt
ssn n
22 21 2
1 22 22 2
1 2
1 2
1 21 1
s sn n
fs sn n
n n
Hyp Test II: 29
5. Decision Rule
• Calculate achieved significance (P-value)
• Reject Ho for p less than type I error of .05
6. Calculations
straight to the computer analysis – tricky to do by hand – that degrees of freedom computation is a nightmare with a hand calculator!
Hyp Test II: 30
Using Minitab: Stats Basic Stats 2-sample t
Samples: analysis variable
Subscripts: variable defining groupsDo NOT Check to
use separate variance estimates
Hyp Test II: 31
Two Sample T-Test and Confidence Interval
Two sample T for LOS
Admit N Mean StDev SE Mean
0 14 8.8 10.9 2.9
1 11 5.55 4.16 1.3
95% CI for mu (0) - mu (1): ( -3.5, 9.9)
T-Test mu (0) = mu (1) (vs not =): T = 1.02 P = 0.32 DF = 17
Hyp Test II: 32
7. Statistical Decision
Since p-value > .05
There is insufficient evidence to reject the null hypothesis: do NOT reject
8. Conclusion
The data do not provide statistically significant evidence that LOS differs between
elective and emergency patients.
Hyp Test II: 33
Note:
• A difference in hospital length of stay of 3 days is actually quite large.
• This difference as non-significant means we should probably consider:
• Are our assumptions met?
• Is the underlying distribution of LOS for each group really normal?
• LOS often has a very skewed distribution, with a few large outliers. We might want to consider other statistical methods – non-parametric methods.(beyond the scope of this course).
Hyp Test II: 34
• Is our sample size large enough?
• Do we have adequate power to find what is clearly a clinically meaningful difference statistically significant?
• Since the variances were rather large, we probably need a much larger sample to address this question.
• See notes on sample size in context of hypothesis testing for further discussion of this point
Hyp Test II: 35
Application 5: One Normal distribution: Test of 2
Example:
In drug manufacturing it is important
• that the amount of drug in the capsules be a particular value on the average
• that the variation around that value be very small.
The drug company will consider its machine accurate enough if the capsules are filled within ± 1 SD =.5 mg of the desired amount of the drug. A sample of 20 capsules are taken, and contents weighed.
Hyp Test II: 36
1. Research Question:
Is the variance of drug in the capsules greater than (.5)2 = 0.25 mg2?
2. Assumptions:
The data are a random sample from a normal distribution.
3. Specify Hypotheses:
Ho: 2 0.25
Ha: 2 > 0.25 (One-sided)
Hyp Test II: 37
4. Test Statistic:
For a confidence interval for 2:
• We used a chi-squared statistic, so our test statistic will be:
• Where o2 is specified by Ho.
2
2
( 1)
o
n sY
Hyp Test II: 38
5. Decision Rule:
Calculate the achieved significance (p-value) and
compare to = .05. Reject Ho for p<.05
We are interested only in a one-sided test:
We want the probability for only one tail of the distribution, for a 1-sided test. In this case the upper tail, to reject Ho for large values of observed s2.
Chi-squared Distribution, n-1 df
Hyp Test II: 39
6. Calculations: (Our sample gives:
x = 2.00, s = .787, n=20 )
To compute achieved significance (p-
value) for 1-sided test:
2 2
1 2
( 1) 19(.787)47.07
.25no
n sY
47.07
Pr( 47.07) 1 Pr( 47.07) .0003Y Y
Hyp Test II: 40
7. Statistical Decision:
Our achieved significance (p-value) is less
than .05: we will therefore reject Ho.
8. Conclusion:
The variance of amount of drug per capsule, estimated at s2=.62 mg2, is significantly greater than 0.25 mg2. The company should adjust it’s machines.
Hyp Test II: 41
9. Confidence Interval Estimate:
• In this case, for a 1-sided test,
• want a 95% Lower confidence bound:
I am 95% “confident” that the true variance is greater than 0.39 mg2 . (which is greater than 0.25 !)
2 2
21,1
( 1) 19(.787).39
30.14n
n sLL
2.95 = 30.14
area = .05
Hyp Test II: 42
Not directly available in Minitab (V12, 13)
• Use strategy of
• Obtain descriptive stats s2
• Compute test statistic, y = (n-1)s2/o2
• Obtain achieved significance: Pr[n
2 > y] = 1 – Pr[y n2]
CalcProb DistChisq
Cumulative Dist FunctionChi-Square with 19 DF x P( X <= x ) 47.0700 0.9997
Hyp Test II: 43
Using Minitab to get Confidence Interval:
Stat Basic Stats Display Descriptive Stats
1. Select variable
2. Select Graph menu
3. Check graphical summary and set confidence level
Hyp Test II: 44
Graphical Summary Results include:
Use this to get lower bound for 95% 1-sided confidence interval for variance:
(.625)2 = 0.39
2.05 2
.95
area = .05
area = .05
.90
area past 2.05 = .95
Hyp Test II: 45
Application 6: Two Independent Normal Distributions:
Test of Equality of Variances
1. Research Question
In the example on LOS of Emergency and Elective case ICU patients, we assumed that the variances in LOS of the two patient groups were different.
Now I would like to test that assumption. My research question is,
“Does the variability of LOS differ between emergency and elective patients?”
Hyp Test II: 46
2. Assumptions
Independent simple random samples from normal
distributions.
3. Specify Ho and Ha: 22 2 11 0 2
0
: : 1o oH H
22 2 11 0 2
0
: : 1a aH H
Hyp Test II: 47
4. Test Statistic:
For comparing two variances we use the F-statistic:
• By convention: use larger value of s2 in numerator when computing F-statistic
2larger
1; 1 2smaller
num denn n
sF
s
5. Decision Rule
We’ll use a type I error = .05, and reject Ho for
p<.05.
Hyp Test II: 48
6. Computations: Descriptive Stats for LOS
Admit N Mean StDev Var
0.Elective 14 8.79 10.91 119.10
1.Emergency 11 5.55 4.16 17.27
• Here, use s02 in numerator, as larger of 2 values:
0 1
20
1; 1 13;1021
119.106.92
17.27n n
sF or F
s
Hyp Test II: 49
Achieved Significance:
• This is a 2-sided test
• Ho, Ha specified only equality of variances, not
direction
13;10 13;10(2)Pr( 6.92) (2) 1 Pr( 6.92)p F F
(2) 1 .9979 .0042
Hyp Test II: 50
7. Statistical DecisionThe achieved significance is less than .05.We therefore reject Ho in favor of the alternative.
8. ConclusionIt appears that the variances of LOS among elective and emergency patients differ significantly. The standard deviation of elective patients is 10.9 days, while it is only 4.2 days for emergency patients.
Hyp Test II: 51
9. Confidence Interval:
0 1
2021 1, 1;(1 / 2) 13,10;.975
1 119.10 1:
17.27n n
sLL
s F F
16.92 1.93
3.583
I am 95% “confident” that the true variance ratio is bounded away from zero.
Note: Only need a lower limit. Since we always put the larger variance in the numerator, it will always be > 1. Therefore we only need to know if the lower limit is also >1.
Hyp Test II: 52
Test for equality of 2 variances is known as:
• Variance Ratio Test or
• F-test for Equality of Variances or
• F-test for Homogeneity of Variances
In Minitab, this is available under:
Stat Basic Statistics 2 Variances
(the above is not available in Version 12)
Or Stat ANOVA Test for Equal Variances
Or Stat ANOVA Homogeneity of Variances
(depends upon version – test is the same)
Hyp Test II: 53
Stat Basic Statistics 2 Variances (not in V.12)
Samples: analysis variable
Subscripts: group variable
Hyp Test II: 54
Stat ANOVA Test for Equal Variances
Response: analysis variable
Factors: group variable
Hyp Test II: 55
Test for Equal Variances (or Homogeneity of Variances)
Response LOSFactors AdmitConfLvl 95.0000
Bonferroni confidence intervals for standard deviations
Lower Sigma Upper N Factor Levels7.57485 10.9135 18.9659 14 0(Emergency)2.76712 4.1560 7.9877 11 1(Elective)
F-Test (normal distribution)
Test Statistic: 6.896P-Value : 0.004
Levene's Test (any continuous distribution)
Test Statistic: 1.526P-Value : 0.229
Hyp Test II: 56
Hyp Test II: 57
Notes on Minitab Results:
• 95% Confidence intervals on the standard deviation for each sample are displayed – computations are done on variances, and square roots taken of the limits
• Note little overlap
• 2 tests for the equality of the variances:
• F-test assumes a normal distribution for LOS for each group
• Levene’s test does not require that we assume underlying normality
Hyp Test II: 58
Application 7: Test of Proportion - One Binomial Distribution
1. Research Question:
• In the ICU study, data was collected on 200 consecutive patients.
• 40 of the patients died in the hospital.
• Is there evidence that the in-hospital mortality rate differs from 25%?
Hyp Test II: 59
1. ASSUMPTIONS
• A random sample of patients (over time)
• The outcome of mortality follows a Binomial Distribution: Bin(, n).
- 2 outcomes: live, die (success)
- Probability of dying – constant
- Independence of outcome across patients
• For large n, the sample proportion, p, follows a Normal distribution:
(1 )~ ,p N
n
Hyp Test II: 60
3. Specify Ho and Ha
4. Test Statistic:
5. Decision Rule: We will reject Ho for achieved significance less than = 0.05 .
: 0.25 . : 0.25o aH vs H
1o
o o
pz
n
Hyp Test II: 61
6. Computations
Sample estimate: p = 40/200 = .20
Test Statistic:
Achieved Significance:
.20 .25
1.631 .25 .75
200
o
o o
pz
n
.25
-1.63 0 1.63z
(2)Pr[ 1.63]p value z 2(.051) .102
Hyp Test II: 62
7. Statistical Decision:
Since p=.102 > .05 Fail to reject Ho.
8. Conclusion:
The observed mortality rate of 20% for ICU patients seen at this hospital is not inconsistent with the hypothesized rate of 25%. The difference is not statistically significant.
9. Confidence Interval Estimate:
1 / 2
( )(1 ) (.2)(.8).20 (1.96)
200
p pp z
n
(.2)(.8).20 (1.96) .20 .055 (.145,.255)
200
Hyp Test II: 63
Using Minitab: Stat Basic Stats 1 Proportion
n
p
o
Check to use Normal approx.
Hyp Test II: 64
Test and CI for One Proportion (Normal Approximation)
Test of p = 0.25 vs p not = 0.25
X N Sample p 95.0% CI Z-Value P-Value40 200 0.200000 (0.144564, 0.255436) -1.63 0.102
Test and CI for One Proportion (Exact Binomial)
Test of p = 0.25 vs p not = 0.25 ExactX N Sample p 95.0% CI P-Value40 200 0.200000 (0.146894, 0.262226) 0.103