Question 6.36

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)
Res<-c(1.92,11.28,1.09,5.75,2.13,9.53,1.03,5.35,1.60,11.73,1.16,4.68,2.16,9.11,1.07,5.3)
Dat5<-data.frame(A,B,C,D,Res)

(a) Estimate the factor effects.

library(DoE.base)
## 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
Mod5<-lm(Res~A*B*C*D, data = Dat5)
coef(Mod5)
## (Intercept)           A           B           C           D         A:B 
##    4.680625    3.160625   -1.501875   -0.220625   -0.079375   -1.069375 
##         A:C         B:C         A:D         B:D         C:D       A:B:C 
##   -0.298125    0.229375   -0.056875   -0.046875    0.029375    0.344375 
##       A:B:D       A:C:D       B:C:D     A:B:C:D 
##   -0.096875   -0.010625    0.094375    0.141875
The estimated factors are showed above.
(a) Plot the effect estimates on a normal probability plot and select a tentative model.
halfnormal(Mod5)
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] A     B     A:B   A:B:C

Analysis

Acording to the halfnormal plot Factors A, B, and the interactions A:B and A:B:C are significant.

(b) Fit the model identified in part (a)

library(GAD)
## Loading required package: matrixStats
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
Mod6<-aov(Res~A*B*C, data = Dat5)
summary(Mod6)          
##             Df Sum Sq Mean Sq  F value   Pr(>F)    
## A            1 159.83  159.83 1563.061 1.84e-10 ***
## B            1  36.09   36.09  352.937 6.66e-08 ***
## C            1   0.78    0.78    7.616  0.02468 *  
## A:B          1  18.30   18.30  178.933 9.33e-07 ***
## A:C          1   1.42    1.42   13.907  0.00579 ** 
## B:C          1   0.84    0.84    8.232  0.02085 *  
## A:B:C        1   1.90    1.90   18.556  0.00259 ** 
## Residuals    8   0.82    0.10                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Analysis

According to the analysis of variance of the model identified in part A we can see that:

The interactions of fators A, B, and interactions A:B and A:B:C were confirmed with the p-values (1.84e-10,6.66e-08,9.33e-07,0.00259) respectivelly.

In addition, we found that the Factor C has also a significant effect since p-value=0.02468, and the interaction B:C has also a significant effect since p-value=0.02085 under alpha = 0.05.

Analyze the residuals. Is there any indication of model inadequacy?

plot(Mod6)          

## hat values (leverages) are all = 0.5
##  and there are no factor predictors; no plot no. 5

Analysis

Analysing the normal probability plot of residuals we can see the normality assumption is not satisfactory. The plots of residual versus fitted has funnel shaped indicating non-constant variance.

(c) Repeat the analysis from parts (a) and (b) using ln (y) as the response variable. Is there an indication that the transformation has been useful?

ResTranf<-log(Res)
ResTranf
##  [1] 0.65232519 2.42303125 0.08617770 1.74919985 0.75612198 2.25444472
##  [7] 0.02955880 1.67709656 0.47000363 2.46214966 0.14842001 1.54329811
## [13] 0.77010822 2.20937271 0.06765865 1.66770682
Dat5A<-data.frame(A,B,C,D,ResTranf)
library(DoE.base)
Mod7<-lm(ResTranf~A*B*C*D, data = Dat5A)
halfnormal(Mod7)
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] A     B     A:B:C

Analysis

After transformation we have different results from part A. Acording to the halfnormal plot after transformation, Factors A, B, and the interaction A:B:C are significant. The interaction A:B after transformation is not significant.

verifying the model after transformation

Mod8<-aov(ResTranf~A*B*C, data = Dat5A)
summary(Mod8)          
##             Df Sum Sq Mean Sq  F value   Pr(>F)    
## A            1 10.572  10.572 1994.556 6.98e-11 ***
## B            1  1.580   1.580  298.147 1.29e-07 ***
## C            1  0.001   0.001    0.124  0.73386    
## A:B          1  0.010   0.010    1.839  0.21207    
## A:C          1  0.025   0.025    4.763  0.06063 .  
## B:C          1  0.000   0.000    0.054  0.82223    
## A:B:C        1  0.064   0.064   12.147  0.00826 ** 
## Residuals    8  0.042   0.005                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Analysis

The new analysis of variance agrees with the conclusions in the New part A (after transformation), confirming the significance only of Factors A, B, and the interaction A:B:C.

Analyze the residuals after transformation?

plot(Mod8)          

## hat values (leverages) are all = 0.5
##  and there are no factor predictors; no plot no. 5

We can also conclude that the transformation was useful, once the residual plots are much improved.

(d) Fit a model in terms of the coded variables that can be used to predict the resistivity.

coef(Mod7)
##  (Intercept)            A            B            C            D          A:B 
##  1.185417116  0.812870345 -0.314277554 -0.006408558 -0.018077390 -0.024684570 
##          A:C          B:C          A:D          B:D          C:D        A:B:C 
## -0.039723700 -0.004225796 -0.009578245  0.003708723  0.017780432  0.063434408 
##        A:B:D        A:C:D        B:C:D      A:B:C:D 
## -0.029875960 -0.003740235  0.003765760  0.031322043

Model:

\(Y = 1.18 +0.81X1-0.31X2\)

Allcode

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)
Res<-c(1.92,11.28,1.09,5.75,2.13,9.53,1.03,5.35,1.60,11.73,1.16,4.68,2.16,9.11,1.07,5.3)
Dat5<-data.frame(A,B,C,D,Res)
library(DoE.base)
Mod5<-lm(Res~A*B*C*D, data = Dat5)
coef(Mod5)
halfnormal(Mod5)
library(GAD)
Mod6<-aov(Res~A*B*C, data = Dat5)
summary(Mod6)          
plot(Mod6) 
ResTranf<-log(Res)
ResTranf
Dat5A<-data.frame(A,B,C,D,ResTranf)
library(DoE.base)
Mod7<-lm(ResTranf~A*B*C*D, data = Dat5A)
halfnormal(Mod7)
Mod8<-aov(ResTranf~A*B*C, data = Dat5A)
summary(Mod8) 
plot(Mod8)  
coef(Mod7)