# Exam5.2: Example 5.2 from Generalized Linear Mixed Models: Modern... In StroupGLMM: R Codes and Datasets for Generalized Linear Mixed Models: Modern Concepts, Methods and Applications by Walter W. Stroup

## Description

Exam5.2 three factor main effects only design

## References

1. Stroup, W. W. (2012). Generalized Linear Mixed Models: Modern Concepts, Methods and Applications. CRC Press.

`DataSet5.2`
 ``` 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154``` ```DataSet5.2\$a <- factor( x = DataSet5.2\$a) DataSet5.2\$b <- factor( x = DataSet5.2\$b) DataSet5.2\$c <- factor(x = DataSet5.2\$c) ##---first adding factor a in model Exam5.2.lm1 <- lm( formula = y~ a , data = DataSet5.2 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary( Exam5.2.lm1 ) library(lsmeans) ##---A first ( Lsm5.2lm1 <- lsmeans::lsmeans( object = Exam5.2.lm1 , specs = "a" # , ... ) ) ## lsmeans::contrast(object = Lsm5.2lm1 , method = "pairwise") Anovalm1 <- anova(object = Exam5.2.lm1) Anovalm1 ##---then adding factor b in model Exam5.2.lm2 <- lm( formula = y~ a + b , data = DataSet5.2 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary( Exam5.2.lm1 ) (Lsm5.2lm2 <- lsmeans::lsmeans( object = Exam5.2.lm2 , specs = "b" # , ... ) ) ## lsmeans::contrast(object = Lsm5.2lm2, method = "pairwise") Anovalm2 <- anova(object = Exam5.2.lm2) Anovalm2 ##---then adding factor c in model Exam5.2.lm3 <- lm( formula = y~ a + b + c , data = DataSet5.2 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary( Exam5.2.lm3 ) (Lsm5.2lm3 <- lsmeans::lsmeans( object = Exam5.2.lm3 , specs = "c" # , ... ) ) ## lsmeans::contrast(object = Lsm5.2lm3, method = "pairwise") Anovalm3 <- anova(object = Exam5.2.lm3) Anovalm3 ##---Now Change the order and add b first in model Exam5.2.lm4 <- lm( formula = y~ b , data = DataSet5.2 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary( Exam5.2.lm4 ) (Lsm5.2lm4 <- lsmeans::lsmeans( object = Exam5.2.lm4 , specs = "b" # , ... ) ) ## lsmeans::contrast(object = Lsm5.2lm4, method = "pairwise") Anovalm4 <- anova(object = Exam5.2.lm4) ##---then adding factor a in model Exam5.2.lm5 <- lm( formula = y~ b + a , data = DataSet5.2 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary( Exam5.2.lm5 ) (Lsm5.2lm5 <- lsmeans::lsmeans( object = Exam5.2.lm5 , specs = "a" # , ... ) ) ## lsmeans::contrast(object = Lsm5.2lm3, method = "pairwise") Anovalm5 <- anova(object = Exam5.2.lm5) Anovalm5 ```