Exam2.B.7 is related to multi batch regression data assuming different forms of linear models with factorial experiment.

References

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

See also

Examples

#----------------------------------------------------------------------------------- ## Classical main effects and Interaction Model #----------------------------------------------------------------------------------- data(DataExam2.B.7) DataExam2.B.7$a <- factor(x = DataExam2.B.7$a) DataExam2.B.7$b <- factor(x = DataExam2.B.7$b) Exam2.B.7.lm1 <- lm( formula = y~ a + b + a*b , data = DataExam2.B.7 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) #----------------------------------------------------------------------------------- ## One way treatment effects model #----------------------------------------------------------------------------------- DesignMatrix.lm1 <- model.matrix (object = Exam2.B.7.lm1) DesignMatrix2.B.7.2 <- DesignMatrix.lm1[,!colnames(DesignMatrix.lm1) %in% c("a2","b")] lmfit2 <- lm.fit( x = DesignMatrix2.B.7.2 , y = DataExam2.B.7$y , offset = NULL , method = "qr" , tol = 1e-07 , singular.ok = TRUE # , ... ) Coefficientslmfit2 <- coef( object = lmfit2) #----------------------------------------------------------------------------------- ## One way treatment effects model without intercept #----------------------------------------------------------------------------------- DesignMatrix2.B.7.3 <- as.matrix(DesignMatrix.lm1[,!colnames(DesignMatrix.lm1) %in% c("(Intercept)","a2","b")]) lmfit3 <- lm.fit( x = DesignMatrix2.B.7.3 , y = DataExam2.B.7$y , offset = NULL , method = "qr" , tol = 1e-07 , singular.ok = TRUE # , ... ) Coefficientslmfit3 <- coef( object = lmfit3) #----------------------------------------------------------------------------------- ## Nested Model (both models give the same result) #----------------------------------------------------------------------------------- Exam2.B.7.lm4 <- lm( formula = y~ a + a/b , data = DataExam2.B.7 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary(Exam2.B.7.lm4)
#> #> Call: #> lm(formula = y ~ a + a/b, data = DataExam2.B.7, method = "qr", #> model = TRUE, qr = TRUE, singular.ok = TRUE, contrasts = NULL) #> #> Residuals: #> Min 1Q Median 3Q Max #> -7.325 -1.769 -0.475 2.581 6.775 #> #> Coefficients: #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) 40.975 2.164 18.933 2.64e-10 *** #> a2 0.150 3.061 0.049 0.96172 #> a1:b2 -2.725 3.061 -0.890 0.39078 #> a2:b2 -9.600 3.061 -3.137 0.00859 ** #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Residual standard error: 4.328 on 12 degrees of freedom #> Multiple R-squared: 0.5188, Adjusted R-squared: 0.3985 #> F-statistic: 4.313 on 3 and 12 DF, p-value: 0.02787 #>
Exam2.B.7.lm4 <- lm( formula = y~ a + a*b , data = DataExam2.B.7 # , subset # , weights # , na.action , method = "qr" , model = TRUE # , x = FALSE # , y = FALSE , qr = TRUE , singular.ok = TRUE , contrasts = NULL # , offset # , ... ) summary(Exam2.B.7.lm4)
#> #> Call: #> lm(formula = y ~ a + a * b, data = DataExam2.B.7, method = "qr", #> model = TRUE, qr = TRUE, singular.ok = TRUE, contrasts = NULL) #> #> Residuals: #> Min 1Q Median 3Q Max #> -7.325 -1.769 -0.475 2.581 6.775 #> #> Coefficients: #> Estimate Std. Error t value Pr(>|t|) #> (Intercept) 40.975 2.164 18.933 2.64e-10 *** #> a2 0.150 3.061 0.049 0.962 #> b2 -2.725 3.061 -0.890 0.391 #> a2:b2 -6.875 4.328 -1.588 0.138 #> --- #> Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 #> #> Residual standard error: 4.328 on 12 degrees of freedom #> Multiple R-squared: 0.5188, Adjusted R-squared: 0.3985 #> F-statistic: 4.313 on 3 and 12 DF, p-value: 0.02787 #>