library(DoE.base)
## Warning: package 'DoE.base' was built under R version 4.5.2
## Loading required package: grid
## Loading required package: conf.design
## Warning: package 'conf.design' was built under R version 4.5.2
## 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)
yield = c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
dat<-data.frame(A,B,C,D,yield)
model = lm(yield~A*B*C*D, data=dat)
coef(model)
## (Intercept) A B C D
## 1.737500e+01 2.250000e+00 2.500000e-01 1.000000e+00 1.625000e+00
## A:B A:C B:C A:D B:D
## -3.750000e-01 -2.125000e+00 1.250000e-01 2.000000e+00 -1.027824e-16
## C:D A:B:C A:B:D A:C:D B:C:D
## -1.595946e-16 5.000000e-01 3.750000e-01 -1.250000e-01 -3.750000e-01
## A:B:C:D
## 5.000000e-01
halfnormal(model)
##
## Significant effects (alpha=0.05, Lenth method):
## [1] A A:C A:D D
After creating the normal plot, the highlighted terms are proven to be significant (A,D,A*C,A*D)
model2<-lm(yield~A+D+A*D+A*C, data=dat)
summary(model2)
##
## Call:
## lm.default(formula = yield ~ A + D + A * D + A * C, data = dat)
##
## 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 ***
## D 1.6250 0.3187 5.099 0.000465 ***
## C 1.0000 0.3187 3.138 0.010549 *
## A:D 2.0000 0.3187 6.276 9.19e-05 ***
## A:C -2.1250 0.3187 -6.668 5.58e-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
mod<-aov(model2)
summary(mod)
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 81.00 81.00 49.846 3.46e-05 ***
## D 1 42.25 42.25 26.000 0.000465 ***
## C 1 16.00 16.00 9.846 0.010549 *
## A:D 1 64.00 64.00 39.385 9.19e-05 ***
## A:C 1 72.25 72.25 44.462 5.58e-05 ***
## Residuals 10 16.25 1.62
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The factors shown above have one degree of freedom, and the significant factor. The non-significant terms were dropped, reducing the residuals to a total of ten.
library(DoE.base)
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)
yield = c(12,18,13,16,17,15,20,15,10,25,13,24,19,21,17,23)
dat<-data.frame(A,B,C,D,yield)
model = lm(yield~A*B*C*D, data=dat)
coef(model)
halfnormal(model)
model2<-lm(yield~A+D+A*D+A*C, data=dat)
summary(model2)
mod<-aov(model2)
summary(mod)