options ps = 60 ls = 85 ; * ---------------------------------------------------------- ; * Exercise 6.3 ; * ---------------------------------------------------------- ; data ex6_3 ; input fabric temp shrink @@ ; cards ; 1 210 1.8 1 210 2.1 1 215 2.0 1 215 2.1 1 220 4.6 1 220 5.0 1 225 7.5 1 225 7.9 2 210 2.2 2 210 2.4 2 215 4.2 2 215 4.0 2 220 5.4 2 220 5.6 2 225 9.8 2 225 9.2 3 210 2.8 3 210 3.2 3 215 4.4 3 215 4.8 3 220 8.7 3 220 8.4 3 225 13.2 3 225 13.0 4 210 3.2 4 210 3.6 4 215 3.3 4 215 3.5 4 220 5.7 4 220 5.8 4 225 10.9 4 225 11.1 ; proc print data = ex6_3 ; run ; proc glm data = ex6_3 ; class fabric temp ; model shrink = fabric temp fabric*temp ; contrast 'fabric main effect' fabric 1 -1 0 0, fabric 1 0 -1 0, fabric 1 0 0 -1 ; * the above code calculates the fabric main effect as a set of 3 pairwise contrasts ; contrast 'linear temp' temp -3 -1 1 3 ; contrast 'quadratic temp' temp 1 -1 -1 1 ; contrast 'cubic temp' temp -1 3 -3 1 ; contrast 'linear temp x fabric int. ' fabric*temp -3 -1 1 3 3 1 -1 -3 0 0 0 0 0 0 0 0 , fabric*temp -3 -1 1 3 0 0 0 0 3 1 -1 -3 0 0 0 0 , fabric*temp -3 -1 1 3 0 0 0 0 0 0 0 0 3 1 -1 -3 / e ; contrast 'quad. temp x fabric int. ' fabric*temp 1 -1 -1 1 -1 1 1 -1 0 0 0 0 0 0 0 0 , fabric*temp 1 -1 -1 1 0 0 0 0 -1 1 1 -1 0 0 0 0 , fabric*temp 1 -1 -1 1 0 0 0 0 0 0 0 0 -1 1 1 -1 ; contrast 'cubic temp x fabric int. ' fabric*temp -1 3 -3 1 1 -3 3 -1 0 0 0 0 0 0 0 0 , fabric*temp -1 3 -3 1 0 0 0 0 1 -3 3 -1 0 0 0 0 , fabric*temp -1 3 -3 1 0 0 0 0 0 0 0 0 1 -3 3 -1 ; output out = rex6_3 p = pred r = res ; run ; proc plot data = rex6_3 ; plot pred*fabric=temp pred*temp=fabric res*pred ; run ; proc capability noprint data = rex6_3 lineprinter ; var res ; qqplot res /normal(mu = est sigma = est symbol='.') square ; run ; * ---------------------------------------------------------- ; * Exercise 6.11 ; * ---------------------------------------------------------- ; data ex6_11 ; input base alcohol prod @@ ; cards ; 1 1 90.7 1 1 91.4 1 2 89.3 1 2 88.1 1 2 90.4 1 3 89.5 1 3 87.6 1 3 88.3 1 3 90.3 2 1 87.3 2 1 88.3 2 1 91.5 2 2 94.7 2 3 93.1 2 3 90.7 2 3 91.5 ; proc print data = ex6_11 ; run ; proc glm data = ex6_11 ; class base alcohol ; model prod = base alcohol base*alcohol ; lsmeans base alcohol base*alcohol / stderr ; means base alcohol base*alcohol ; * next four lines help interpret interaction (simple effect tests) ; estimate 'base1 vs base2 @ alc1' base 1 -1 base*alcohol 1 0 0 -1 0 0 / e ; estimate 'base1 vs base2 @ alc2' base 1 -1 base*alcohol 0 1 0 0 -1 0 ; estimate 'base1 vs base2 @ alc3' base 1 -1 base*alcohol 0 0 1 0 0 -1 ; lsmeans base*alcohol / slice = alcohol ; output out = rex6_11 p = pred r = res ; run ; proc plot data = rex6_11 ; plot res*pred ; run ; proc capability noprint data = rex6_11 lineprinter ; var res ; qqplot res /normal(mu = est sigma = est symbol='.') square ; run ; * ---------------------------------------------------------- ; * Table 6.13 data ; * ---------------------------------------------------------- ; data table613 ; input t d s r ; do i = 1 to r ; input weightgain @@ ; output ; end ; cards ; 25 80 10 3 86 52 73 25 80 25 3 544 371 482 25 80 40 3 390 290 397 25 160 10 3 53 73 86 25 160 25 3 393 398 208 25 160 40 3 249 265 243 35 80 10 3 439 436 349 35 80 25 3 249 245 330 35 80 40 3 247 277 205 35 160 10 3 324 305 364 35 160 25 3 352 267 316 35 160 40 3 188 223 281 ; proc print data = table613 ; run ; proc glm data = table613 ; class t d s ; model weightgain = t | d | s ; random t | d | s / test ; run ; * ---------------------------------------------------------- ; * Exercise 7.3 ; * ---------------------------------------------------------- ; data ex7_3 ; input alloy $ casting strength @@ ; cards ; A 1 13.2 A 1 15.5 A 2 15.2 A 2 15.0 A 3 14.8 A 3 14.2 A 4 14.6 A 4 15.1 B 1 17.1 B 1 16.7 B 2 16.5 B 2 17.3 B 3 16.1 B 3 15.4 B 4 17.4 B 4 16.8 C 1 14.1 C 1 14.8 C 2 13.2 C 2 13.9 C 3 14.5 C 3 14.7 C 4 13.8 C 4 13.5 ; proc glm data = ex7_3 ; class alloy casting ; model strength = alloy casting(alloy) ; random casting(alloy) / test ; lsmeans alloy / stderr cl e = casting(alloy) ; run ; proc mixed data = ex7_3 ; class alloy casting ; model strength = alloy ; random casting(alloy) ; lsmeans alloy / cl ; run ; * ---------------------------------------------------------- ; * Exercise 8.1 a,b,c,e,f ; * ---------------------------------------------------------- ; data ex8_1 ; input method $ block weight @@ ; cards ; Tr 1 450 Tr 2 469 Tr 3 249 Tr 4 125 Tr 5 280 Tr 6 352 Tr 7 221 Tr 8 251 Ba 1 358 Ba 2 512 Ba 3 281 Ba 4 58 Ba 5 352 Ba 6 293 Ba 7 283 Ba 8 186 Spy 1 331 Spy 2 402 Spy 3 183 Spy 4 70 Spy 5 258 Spy 6 281 Spy 7 219 Spy 8 46 Spk 1 317 Spk 2 423 Spk 3 379 Spk 4 63 Spk 5 289 Spk 6 239 Spk 7 269 Spk 8 357 SSp 1 479 SSp 2 341 SSp 3 404 SSp 4 115 SSp 5 182 SSp 6 349 SSp 7 276 SSp 8 182 Fld 1 245 Fld 2 380 Fld 3 263 Fld 4 62 Fld 5 336 Fld 6 282 Fld 7 171 Fld 8 98 ; proc glm data = ex8_1 ; class method block ; model weight = block method ; lsmeans method /stderr pdiff cl ; lsmeans method / adjust = dunnett pdiff = control ('Fld') cl ; output out = r_ex8_1 p = pred r = res ; run ; data r_ex8_1a ; set r_ex8_1 ; sqabsresid = sqrt(abs(res)) ; run ; proc plot data = r_ex8_1a vpercent = 70 hpercent = 90 ; plot res*pred sqabsresid*pred ; proc capability noprint data = r_ex8_1a lineprinter ; var res ; qqplot res /normal(mu = est sigma = est symbol='.') square ; run ; * ---------------------------------------------------------- ; * Exercise 8.5 a,b,d ; * ---------------------------------------------------------- ; data ex85 ; input tech timepd construction $ time @@ ; cards ; 1 1 C 90 1 2 B 90 1 3 A 89 1 4 D 104 2 1 D 96 2 2 C 91 2 3 B 97 2 4 A 100 3 1 A 84 3 2 D 96 3 3 C 98 3 4 B 104 4 1 B 88 4 2 A 88 4 3 D 98 4 4 C 106 ; proc print data = ex85 ; run ; proc glm data = ex85 ; class tech timepd construction ; model time = tech timepd construction ; lsmeans construction / stderr pdiff adjust = tukey ; means construction / tukey ; run;