library(DoE.base)
## Warning: package 'DoE.base' was built under R version 4.2.2
## Loading required package: grid
## Loading required package: conf.design
## Registered S3 method overwritten by 'DoE.base':
## method from
## factorize.factor conf.design
##
## Attaching package: 'DoE.base'
## The following objects are masked from 'package:stats':
##
## aov, lm
## The following object is masked from 'package:graphics':
##
## plot.design
## The following object is masked from 'package:base':
##
## lengths
A <- c(-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1,-1,1)
B <- c(-1,-1,1,1,-1,-1,1,1,-1,-1,1,1,-1,-1,1,1)
C <- c(-1,-1,-1,-1,1,1,1,1,-1,-1,-1,-1,1,1,1,1)
D <- c(-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1)
obs <- c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
data <- data.frame(A,B,C,D,obs)
mod <- lm(obs~A*B*C*D,data=data)
halfnormal(mod)
##
## Significant effects (alpha=0.05, Lenth method):
## [1] A A:C A:D D
From the plots, the factors A, C, D, A:C, and A:D are significant since they do not follow a normal line. In other words, they do not behave like a random error.
\[ H_o: \alpha\delta_{im}=0 \\ H_a: \alpha\delta_{im}\neq0 \]
\[ H_o: \alpha\gamma_{il}=0 \\ H_a: \alpha\gamma_{il}\neq0 \]
Where, \(\alpha\) is the main effect of A, \(\gamma\) is the main effect of C, \(\delta\) is the main effect of D.
mod2 <- lm(obs~A+C+D+A*C+A*D,data=data)
summary(mod2)
##
## Call:
## lm.default(formula = obs ~ A + C + D + A * C + A * D, data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1.6250 -0.9375 0.1250 0.8750 1.3750
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 17.3750 0.3187 54.520 1.04e-13 ***
## A 2.2500 0.3187 7.060 3.46e-05 ***
## C 1.0000 0.3187 3.138 0.010549 *
## D 1.6250 0.3187 5.099 0.000465 ***
## A:C -2.1250 0.3187 -6.668 5.58e-05 ***
## A:D 2.0000 0.3187 6.276 9.19e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.275 on 10 degrees of freedom
## Multiple R-squared: 0.9443, Adjusted R-squared: 0.9165
## F-statistic: 33.91 on 5 and 10 DF, p-value: 5.856e-06
From the test, we can assure now that the terms that remain the linear model equation, whiche are only five out of sixteen (A,C,D,A:C,A:D), are significant. All the p-values are lesser than alpha (\(\alpha=0.05\)).