Sampling distribution of the difference in sample means
sampling independently from two populations
has a mean of μ 1 − μ 2
E ( X ¯ − X ¯ ) = E ( X ¯ ) − E ( X ¯ ) = μ 1 − μ 2
has a standard deviation of σ X 1 ¯ − X 2 ¯ = σ 1 2 n 1 + σ 2 2 n 2
V a r ( X ¯ 1 − X ¯ 2 ) = V a r ( X ¯ 1 ) + V a r ( X ¯ 2 ) = σ 1 2 n 1 + σ 2 2 n 2
is normally distributed if we are sampling from normally distributed populations
if the distributions are not normal but the sample sizes are large:
X ¯ 1 , X ¯ 2 and X ¯ 1 − X ¯ 2 will be approximately normal
Hypothesis Testing and Confidence Intervals for μ 1 − μ 2 when σ 1 and σ 2 are unknown
if we are drawing two independent samples from two normally distributed populations
(needed here as both procedures assume normality)
then
( X ¯ 1 − X ¯ 2 ) − ( μ 1 − μ 2 ) σ 1 2 n 1 + σ 2 2 n 2 ∼ N ( 0 , 1 )
( X 1 − X 2 ) − ( μ 1 − μ 2 ) s 1 2 n 1 + s 2 2 n 2 has the t-distribution
two methods
both assume
the two samples are simple random samples from their respective populations
or are the results of a randomized experiment
populations are normally distributed
not very important for large sample sizes (Central Limit Theorem )
two sample t procedures are more robust to violation of normality than the one sample t procedure as well
can be t
the two samples are independent
pooled-variance two-sample t
an exact procedure that requires the additional assumption that σ 1 2 = σ 2 2
means that the distributions look the same but for a shift
math looks clean, but if assumption is false...
assumes normality
S E p ( X ¯ 1 − X ¯ 2 ) = s p 2 n 1 + s p 2 n 2
d f for the t: n 1 + n 2 − 2
welch procedure
approximate procedure that does not assume σ 1 2 = σ 2 2
assumes normality as well
S E W ( X ¯ 1 − X ¯ 2 ) = s 1 2 n 1 + s 2 2 n 2
d f for the t: ( s 1 2 n 1 + s 2 2 n 2 ) 2 1 n 1 − 1 ( s 1 2 n 1 ) 2 + 1 n 2 − 1 ( s 2 2 n 2 ) 2
( s 1 2 n 1 + s 2 2 n 2 ) 2 / 1 n 1 − 1 ( s 1 2 n 1 ) + 1 n 2 − 1 ( s 2 2 n 2 ) 2
to estimate the common population variance, we pool the sample variances together
s p 2 = ( n 1 − 1 ) s 1 2 + ( n 2 − 1 ) s 2 2 n 1 + n 2 − 2
the endpoints of a ( 1 − α ) 100 % confidence interval for μ 1 − μ 2 are given by
t test statistic
t = X ¯ 1 − X ¯ 2 S E ( X ¯ 1 − X ¯ 2 ) (no mean because we're assuming they're equal for the H 0 )
t test is always done assuming H 0 is true
used to test the null hypothesis that the population means are equal ( H 0 : μ 1 = μ 2 )
to choose between the 2 procedures consider
pooled-variance t is exact if the assumptions are true, while Welch is only an approximation
pooled-variance t is a special case of other common statistical methods (ANOVA/regression), while Welch is its own thing
pooled-variance t can perform horribly if the population variances are very different, while Welch does well
even worse if the sample sizes are also very different
when σ 1 2 = σ 2 2 Welch performs only a little worse than the pooled-variance t
example
psychotic x nonpsychotic
ratio of s 1 s 2 < 2 , in this case its 1.10
they're pretty close, and sample sd's are never gonna be equal, so its reasonable to say that σ 1 = σ 2
both pooled-variance t and welch are reasonable
using pooled variance
s p 2 = ( n 1 − 1 ) s 1 2 + ( n 2 − 1 ) s 2 2 n 1 + n 2 − 2 = ( 10 − 1 ) 5.27 2 + ( 15 − 1 ) 4.77 2 10 + 15 − 2 = 24.73
S E p ( X ¯ 1 − X ¯ 2 ) = s p 1 n 1 + 1 n 2
t = X ¯ 1 − X ¯ 2 S E p ( X ¯ 1 − X ¯ 2 )
degrees of freedom are n 1 + n 2 − 2 = 23
95% confidence interval for μ 1 − μ 2
X ¯ 1 − X ¯ 2 ± t .025 S E p ( X ¯ 1 − X ¯ 2 )
24.25 − 16.47 ± 2.069 × 2.03
= .78 ± 4.20
for a 95% interval of ( 3.58 , 11 , 98 )
using welch
S E W ( X ¯ 1 − X ¯ 2 ) = s 1 2 n 1 + s 2 2 n 2
t = X ¯ 1 − X ¯ 2 S E W ( X ¯ 1 − X ¯ 2 )
d f = ( s 1 2 n 1 + s 2 2 n 2 ) 2 1 n 1 − 1 ( s 1 2 n 1 ) 2 + 1 n 2 − 1 ( s 2 2 n 2 ) 2 = 18.053 .
95% confidence interval for μ 1 − μ 2
X ¯ 1 − X ¯ 2 ± t .025 S E W ( X ¯ 1 − X ¯ 2 )
24.25 − 16.47 ± 2.100 × 2.07
= 7.78 ± 4.35
for a 95% interval of ( 3.43 , 12.13 )
just use R
we can be 95 % confident that the difference in true mean dopamine levels ( μ p − μ n ) lies between 3.6 and 12.0
p-value = 0.0008569
the mean of the group that became nonpshychotic was significantly lower than that of the group that remained psychotic (two-tailed t-test of independent means: t ( 23 ) = 3.83 ; P < .001 ) .
blood calcium level
group that drink orange juice vs one who didnt
confidence interval
95% CI for μ d − μ c
μ d = true mean change in calcium for the vitamin d group
μ d − μ c = treatment effect
hypothesis
H 0 : μ d − μ c = 0 → H 0 : μ d = μ c
H a : μ d ≠ μ c
plots look symmetric, we dont know if its normal tho
the t-procedure stull works well with normality violations so should be fine
sd's are close, either pooled-variance or welch are reasonable
R
pooled
t.test(Fortified,Control,var.equal=TRUE)
welch
t.test(Fortified,Control,var.equal=FALSE)
95 % CI for μ d − μ c = ( − 3.3 , 2.6 ) mg/dl
we can be 95% confident that the difference in true mean of the change in calcium (μ d − μ c ) lies between -3.3 and 2.6 ml/dl
t(23) = -0.24647
p-value is double the area to the left≈ 0.81
large p → no evidence against H 0
there is no evidence of a difference in the true mean change in calcium between the vitamin d and the control group
paired-difference procedures (dependent samples)
both measurements are on the same sample, with different conditions
designs
pretest-posttest design
sketchy
measurements are taken on the same individuals before and after a treatment
normally we have a control group that doesnt get the treatment
crossover design
participants are randomly assigned to a time order of the treatments
treatment 1 → some time → treatment 2
treatment 2 → some time → treatment 1
matched pairs design
individuals are matched based on relevant variables
one will take treatment 1 the other treatment 2
paired-difference t procedure
treat the observed differences as a single sample from a population of differences
one data using the difference between the 2
X ¯ ± t α 2 S E ( X ¯ )
( 1 − α ) 100 % confidence interval for the population mean difference μ
X ¯ = sample mean of the differences
d f = n − 1
n is the number of differences
S E ( X ¯ ) = s n
hypothesis
H 0 : μ = μ 0 ; almost always H 0 : μ = 0
difference between the 2 groups = 0 (theyre equal)
t = X ¯ − μ 0 S E ( x ¯ )