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)
run <- c(5,9,8,13,3,7,14,1,6,11,2,15,4,16,10,12)
dat <- data.frame(A, B, C, D, yield, run)
full <- lm(yield ~ A*B*C*D, data = dat)
effect <- 2 * coef(full)[-1]
round(effect, 3)
## A B C D A:B A:C B:C A:D B:D C:D
## 4.50 0.50 2.00 3.25 -0.75 -4.25 0.25 4.00 0.00 0.00
## A:B:C A:B:D A:C:D B:C:D A:B:C:D
## 1.00 0.75 -0.25 -0.75 1.00
z <- sort(abs(effect))
n <- length(z)
h <- qnorm(0.5 + 0.5 * ((1:n - 0.5)/n))
selected <- names(z) %in% c("A", "C", "D", "A:C", "A:D")
plot(h, z, pch = 19, col = ifelse(selected, "red", "blue"),
xlab = "Half-normal quantile", ylab = "Absolute effect (in pounds)",
main = "Half-normal plot of effect", ylim = c(0, 5.2))
text(h[selected], z[selected], labels = names(z)[selected],
pos = 3, cex = 0.85, col = "red")
small <- !selected
slope <- sum(h[small] *z[small])/sum(h[small]^2)
abline(a = 0, b = slope, lty = 2)
Here A, C, D, AC, AD are significant
Pool B, AB, BC, BD, CD, ABC, ABD, ACD, BCD, and ABCD into error.
model <- lm(yield ~ A + C + D + A:C + A:D, data = dat)
anova(model)
## Analysis of Variance Table
##
## Response: yield
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 81.00 81.000 49.8462 3.456e-05 ***
## C 1 16.00 16.000 9.8462 0.0105485 *
## D 1 42.25 42.250 26.0000 0.0004647 ***
## A:C 1 72.25 72.250 44.4615 5.583e-05 ***
## A:D 1 64.00 64.000 39.3846 9.193e-05 ***
## Residuals 10 16.25 1.625
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
\(SS_E = 16.25\), \(df_E = 10\), and \(MS_E = 1.625\).
We can infer that the effect of time depends on pressure and temperature. .