Mathematics 243 t-methods Day 28 - March 26 1. The relationship between a hypothesis test with significance level α and a 100(1 − α)% confidence interval. 2. What does a confidence interval mean? 3. Inference for µ – review of the t-test (a) Preliminary analysis: (data in vector x) > boxplot(x) > stripchart(x,pch=1) > summary(x) (b) Assumptions: simple random sample (independent trials of a process), population close to normal or sample size large x̄ − µ0 √ (c) Test statistic: s/ n s (d) Confidence interval: x̄ ± t∗ √ n (e) t-test and additional functions from package mosaic > x=sample(sr$GPA,30) > t.test(x,mu=3.2) One Sample t-test data: x t = -1.5053, df = 29, p-value = 0.1431 alternative hypothesis: true mean is not equal to 3.2 95 percent confidence interval: 2.862712 3.251288 sample estimates: mean of x 3.057 > interval(t.test(x)) mean of x lower upper 3.057000 2.862712 3.251288 > pval(t.test(x,mu=3.2)) p.value 0.143054 > stat(t.test(x,mu=3.2)) t -1.505332 4. Simulating confidence intervals using mosaic > mu=mean(sr$GPA) > ints = do(1000) * interval(t.test(sample(sr$GPA,4))) > str(ints) 'data.frame': 1000 obs. of 3 variables: $ mean of x: num 3.48 2.76 3.32 2.97 3.31 ... $ lower : num 2.36 2.14 2.5 2.16 2.73 ... $ upper : num 4.59 3.37 4.14 3.77 3.89 ... > misshigh=sum(ints$lower>mu) > misslow=sum(ints$upper<mu) > misslow;misshigh; (misslow+misshigh)/1000 [1] 10 [1] 47 [1] 0.057 5. Inference for µ1 − µ2 (a) Preliminary analysis: (data in dataframe d, quantitative variable x and factor variable f) > boxplot(x~f,data=d) > stripchart(x~f,data=d,pch=1) > aggregate(x~f,data=d,FUN=summary) (b) Assumptions: two simple random samples, independent of each other, population close to normal or sample size large or randomized assignment to two treatments (x̄1 − x̄2 ) − (µ1 − µ2 ) p (c) Test statistic: s21 /n1 + s22 /n2 (d) Confidence interval: (x̄1 − x̄2 ) ± t∗ SE (e) t-test > t.test(length~sex,data=KidsFeet) Welch Two Sample t-test data: length by sex t = 1.9174, df = 36.275, p-value = 0.06308 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -0.04502067 1.61291541 sample estimates: mean in group B mean in group G 25.10500 24.32105 > interval(t.test(length~sex,data=KidsFeet)) mean in group B mean in group G lower upper 25.10500000 24.32105263 -0.04502067 1.61291541 > pval(t.test(length~sex,data=KidsFeet)) p.value 0.06308223 > stat(t.test(length~sex,data=KidsFeet)) t 1.917445 2
© Copyright 2026 Paperzz