---------------------------- First problem ---------------------------- > library(oehlert) > library(cfcdae) > attach(pr03.2) > cm=matrix(c(1,-1,0,0,0,0,1,-1,0,0,0,0,1,-1,0,.25,.25,.25,.25,-1),5,4) > f=lm(lifespan~treat) > cm # each column gives contrast coefficients for the 5 groups [,1] [,2] [,3] [,4] [1,] 1 0 0 0.25 [2,] -1 1 0 0.25 [3,] 0 -1 1 0.25 [4,] 0 0 -1 0.25 [5,] 0 0 0 -1.00 > linear.contrast(f,treat,cm,jointF=T) $estimates estimates se t-value p-value lower-ci upper-ci 1 -0.20 4.188358 -0.0477514 9.619937e-01 -8.4926583 8.092658 2 -1.24 4.188358 -0.2960587 7.676970e-01 -9.5326583 7.052658 3 8.04 4.188358 1.9196065 5.728167e-02 -0.2526583 16.332658 4 23.40 3.311188 7.0669498 1.127335e-10 16.8440780 29.955922 $Ftest F df1 df2 p-value 13.61195 4 120 3.515622e-09 > linear.contrast(f,treat,cm,scheffe=T) estimates se t-value p-value lower-ci upper-ci 1 -0.20 4.188358 -0.0477514 9.619937e-01 -13.304239 12.90424 2 -1.24 4.188358 -0.2960587 7.676970e-01 -14.344239 11.86424 3 8.04 4.188358 1.9196065 5.728167e-02 -5.064239 21.14424 4 23.40 3.311188 7.0669498 1.127335e-10 13.040189 33.75981 My problem wasn't very coherent; sorry about that! Testing H0: mu1=mu2=mu3=mu4 and 0.25*(mu1+mu2+mu3+mu4)-m5=0 simultaneously using jointF=T gives a p-value of 0.0000000035, so we reject @ the 5% level. All's this tells us is that one of those two statements (or both) is false, not which one! The Scheffe CIs indicate that we accept H0: mu1=mu2=mu3=mu4 but reject H0: 0.25*(mu1+mu2+mu3+mu4)-m5=0, all capping the SFER at 5%. This is better information: no difference among the first four group means, but group five is significantly different from the rest. ---------------------------- Pr 5.1 ---------------------------- > lines(pairwise(f,treat)) # default is Tukey HSD 5 -18.72 4 -0.68 | 1 5.92 | 2 6.12 | 3 7.36 | We accept no significant difference among groups 1, 2, 3, and 4; but 5 is sig. different from the rest. The concusions are the same as the previous problem. ---------------------------- Ex 4.2 ---------------------------- > attach(ex03.3) > ?linear.contrast # tells us to use subcommand 'confidence=0.99' > linear.contrast(f,treat,c(1/3,1/3,1/3,-1),confidence=0.99) estimates se t-value p-value lower-ci upper-ci 1 2.4 2.32379 1.032796 0.3319086 -5.397216 10.19722 We are 99% confident that the average of the three treatment groups is between -5.4% less and 10.2% more than the control group. Since the p-value=0.33>0.05 we accept no difference at the 5% level. ---------------------------- Ex 4.3 ---------------------------- The contrast is c=0.5(mu1+mu2)-0.5(mu3+mu3), the difference in averages between experienced and novice. > strength=c(7.3550,7.5900,7.7750,6.2350,7.0000,6.7900,7.6250,5.7975,8.1050,8.3600,8.0100,8.2675) > oper=factor(c(1,1,1,2,2,2,3,3,3,4,4,4)) > f=lm(strength~oper) > linear.contrast(f,oper,c(0.5,0.5,-0.5,-0.5)) estimates se t-value p-value lower-ci upper-ci 1 -0.57 0.3781401 -1.507378 0.1701418 -1.441993 0.3019926 Since p-value=0.38>0.05 we accept no difference between experienced and novice at the 5% level. Note that estimated difference is -0.57 lbs., although not significant, the the experienced are doing *worse* than the novices. ---------------------------- Ex 4.4 ---------------------------- Let's make a table of group, brand, texture, and price: 1 A chewy expensive 2 A crisp expensive 3 B chewy inexpensive 4 B crisp inexpensive 5 C chewy expensive 6 D crisp inexpensive Groups 1, 3, 5 are chewy; groups 2, 4, 6 are crispy, so chewy vs. crispy is (mu1+mu3+mu5)/3-(mu2+mu4+mu6)/3 Groups 1, 2, 5 are expensive; groups 3, 4, 6 are inexpensive, so expensive vs. inexpensive is (mu1+mu2+mu5)/3-(mu3+mu4+mu6)/3 In terms of coefficients, chewy vs. crispy is (1,-1,1,-1,1,-1)/3; expensive vs. inexpensive is (1,1,-1,-1,1,-1)/3. You do not need to divide by three if you are simply testing differences. ---------------------------- Ex 5.3 ---------------------------- The problem asks for tests of all possible pairwise comparisons keeping SFER capped at 5%. I would use REGWR because this gives a bit more power than Tukey and the problem is not asking for SCI. It is fine if you use Tukey though (and the conclusions do not change). Using the same code from Ex. 4.3 > strength=c(7.3550,7.5900,7.7750,6.2350,7.0000,6.7900,7.6250,5.7975,8.1050,8.3600,8.0100,8.2675) > oper=factor(c(1,1,1,2,2,2,3,3,3,4,4,4)) > f=lm(strength~oper) > lines(pairwise(f,oper,type="regwr")) 2 -0.734 | 3 -0.233 | 1 0.164 | 4 0.803 | We conclude that there are no differences among the operators at the 5% overall SFER level. ---------------------------- Ex 5.4 ---------------------------- Again, all pairwise comparisons are asked for controlling the FDR at 0.05. Use SNK for this one. > attach(ex03.1) > names(ex03.1) [1] "liverWt" "diet" > f=lm(liverWt~diet) > lines(pairwise(f,diet,type="snk")) 2 -0.1316 | 3 -0.1133 | 1 0.0341 | | 4 0.2109 | Groups 2, 3, 1 are not significantly different; groups 1 and 4 are not significantly different. Group 4 is significantly different from groups 2 and 3. ---------------------------- Ex 5.5 ---------------------------- The problem asks you to only compare the three treatments to control. This is Dunnett's procedure. > attach(ex03.3) > names(ex03.3) [1] "treat" "moisture" > f=lm(moisture~treat) > ex03.3 # look at data to see control is 4th group > compare.to.control(f,treat,control=4) difference lower upper 3 - 4 0.6 -7.589637 8.789637 1 - 4 2.1 -6.089637 10.289637 2 - 4 4.5 -3.689637 12.689637 > ex03.3 The SCI are mu3-mu4 (-7.6,8.8) mu1-mu4 (-6.1,10.3) mu2-mu4(-3.7,12.7) Note that none of the treatments are sig. different from control.