Comparison of 2 or more means Acknowledgement: Thanks to Professor Pagano (Harvard School of Public Health) for lecture material
e.g. n=16, df=15, 0.05 points are ±2.13 Is = 0 ? -- consider versus or One sample t test
Population (Normal) T-treatmentC-control TT CC TT CC H 0 : T = C Two sample t
Population (Normal) T-treatmentC-control TT CC TT CC Sample nTnT nCnC sTsT sCsC H 0 : T = C Two sample t
1.Samples dependent (Paired) 2.Samples independent Two situations:
Example – Paired study Each subject is tested under 2 conditions: –Time to angina when exposed to plain air –Time to angina when exposed to air + CO
Plain air Carbon monoxide Example – Paired study
Plain air Carbon monoxide Example – Paired study
Plain air Carbon monoxide Example – Paired study
Response Error Model for a Subject: At time 1 At time 2 Measured under same conditions!
Example – Paired study Response Error Model for a Subject: At time 1 At time 2 Measured under different conditions! = The condition effect
Example – Paired study Take Difference -At time 1 At time 2 Take Sample of Subjects, Test whether
So Look at the differences:
So treat the d’s as the data and perform a one-sample t-test: T-test Average change in time to angina = SD of change in time to angina = Calculate p value for H 0 : μ=0
n= 63 Example - Paired study (Hypothesis test)
Example - Paired Study (One sided CI) Obtain an UPPER BOUND for mean difference
In order to decide the s 1 2 and S 1 2 and the degrees of freedom we need to know whether, or not, T = C For two independent samples:
If T C (recommended) and degrees of freedom, : Heteroscedastic
If T = C (which can be tested) we can use a common value: Homoscedastic
Two samples (groups): Treatment Control Example
Stata Output paired t. ttest var1 = var2 Paired t test Variable | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] var1 | var2 | diff | Ho: mean(var1 - var2) = mean(diff) = 0 Ha: mean(diff) 0 t = t = t = P |t| = P > t =
Stata Output unpaired t. ttest var1 = var2, unpaired Two-sample t test with equal variances Variable | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] var1 | var2 | combined | diff | Degrees of freedom: 6 Ho: mean(var1) - mean(var2) = diff = 0 Ha: diff 0 t = t = t = P |t| = P > t =
Stata Output unpaired unequal. ttest var1 = var2, unpaired unequal Two-sample t test with unequal variances Variable | Obs Mean Std. Err. Std. Dev. [95% Conf. Interval] var1 | var2 | combined | diff | Satterthwaite's degrees of freedom: Ho: mean(var1) - mean(var2) = diff = 0 Ha: diff 0 t = t = t = P |t| = P > t =
Summary Paired test Hypothesis test CI 2 independent samples: –Hypothesis test for equal/unequal variance –CI under equal/unequal variance