Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data Lab 6: Hypothesis Testing and CIs for: Two Sample Problems M. George Akritas M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data Exercise 1: Section 9.3.7, p.356, #10 Use the commands df=read.table( ”http://www.stat.psu.edu/~mga/401/Data/ Temp28DayStrength.txt”,header=TRUE) x=df$Temp y=df$Strength out=lm(y∼x) summary(out) fit=aov(lm(y∼ x)) summary(fit) to answer all questions of this problem. M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data Exercise 2: The Notched Box Plot I Use the data of n1 = 32 strength measurements of cold-rolled and n2 = 35 measurements of two-sided galvanized steel. I Read the data in R with the command: df=read.table( ”http://www.stat.psu.edu/~mga/401/Data/ SteelStrengthData.txt”, header = T) I boxplot(df$Value∼ df$Sample,notch=TRUE) I Turn in the boxplot and comment. (Note: As an informal test, if notches do not overlap, population medians differ.) M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data The R command ”t.test”: How it is used I The default is to assume σ1 6= σ2 , do 95% CI, and give the p-value for H0 : µ1 − µ2 = 0 vs Ha : µ1 − µ2 6= 0: t.test(y ∼ x) # For values in y and sample index in x t.test(y[1:32],y[33:67]) # Specify the two samples separately I or: x1=y[which(x==1)]; x2=y[which(x==2)]; t.test(x1,x2) I For the pooled variance T test, and 99% CI do: t.test(y ∼ x, var.equal = TRUE, conf.level = 0.99) I To test H0 : µ1 − µ2 = 1.8 vs Ha : µ1 − µ2 < 1.8 do: t.test(y ∼ x,mu=1.8, alternative = ”less”) I Other options: alternative = ”greater” or the default ”two.sided” M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data Exercise 3 I Use the data set from Exercise 2, to test the hypothesis H0 : µ1 − µ2 = 0 vs Ha : µ1 − µ2 6= 0, at level of significance 0.9, without assuming σ1 6= σ2 . Report the outcome of the test and also the 90% CI for µ1 − µ2 . I Repeat the above using the assumption that σ1 = σ2 . M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems Outline Regression Comparing Two Means: Independent Samples Comparing Two Means: Paired Data Exercise 4: Section 10.5.5, p.399, #2,a,b,c Use the commands for the paired data t test for means: I t.test(x, y, alternative = c(”two.sided”, ”less”, ”greater”), mu = 0, paired = TRUE, conf.level = 0.95) I x,y above can be replaced by y ∼ Sample to answer parts a, b, and c of this problem. M. George Akritas Lab 6: Hypothesis Testing and CIs for: Two Sample Problems