Q no 6.8

Model Equation for two factor interaction:

\(Y_{ijk} = \mu_i + \alpha_i + \beta_j + \alpha\beta_{ij} + \epsilon_{ijk}\)

Where

\(\alpha_i\) is Main Effects of Factor A (Time)

\(\beta_j\) is Main Effects of Factor B (Culture medium)

\(\alpha\beta_{ij}\) is Interaction effects of Factors A and Factors B

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
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.
time<-c(rep(12,12),rep(18,12))
culture<-c(rep(1,2),rep(2,2),rep(1,2),rep(2,2),rep(1,2),rep(2,2),rep(1,2),rep(2,2),rep(1,2),rep(2,2),rep(1,2),rep(2,2))
observation<-c(21,22,25,26,23,28,24,25,20,26,29,27,37,39,31,34,38,38,29,33,35,36,30,35)
time<-as.fixed(time)
culture<-as.fixed(culture)
dat<-data.frame(observation,time,culture)
model<-aov(observation~time+culture+time*culture)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: observation
##              Df Sum Sq Mean Sq  F value    Pr(>F)    
## time          1 590.04  590.04 115.5057 9.291e-10 ***
## culture       1   9.38    9.38   1.8352 0.1906172    
## time:culture  1  92.04   92.04  18.0179 0.0003969 ***
## Residual     20 102.17    5.11                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Here we can see that the p value of interaction between time and culture is less that alpha i.e 0.05 hence it is significant and we reject the null hypothesis

Interaction and Residual plots

interaction.plot(time,culture,observation)

plot(model)

From the above graphs we can see that it is normally distributed and the variance also looks a bit similar hence we can say that the model is adequate

Q 6.12

Factor Effects

Effect of a = 2*(a+ab-b-(1))/16

= -0.3185

Similarly effect at b = 2*(b+ab-a-(1))/16

=0.5872

Effect at ab = 2*(a+b-ab-(1))/16

= -0.28025

factorlevel<-c(rep(55,8),rep(58,8))
times<-c(rep(10,4),rep(15,4),rep(10,4),rep(15,4))
observation1<-c(14.037,16.165,13.972,13.907,14.821,14.757,14.843,14.878,13.880,13.860,14.032,13.914,14.888,14.921,14.415,14.932)
factorlevel<-as.fixed(factorlevel)
times<-as.fixed(times)
dat2<-data.frame(observation1,factorlevel,times)
model2<-aov(observation1~factorlevel+times+factorlevel*times)
GAD::gad(model2)
## Analysis of Variance Table
## 
## Response: observation1
##                   Df Sum Sq Mean Sq F value  Pr(>F)  
## factorlevel        1 0.4026 0.40259  1.2619 0.28327  
## times              1 1.3736 1.37358  4.3054 0.06016 .
## factorlevel:times  1 0.3170 0.31697  0.9935 0.33856  
## Residual          12 3.8285 0.31904                  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

B)Here we can see that all p values for main effects as well as interaction the p values are greater than 0.05 hence we can say that the effects are not significant

model3<-lm(observation1~factorlevel+times+factorlevel*times)
coef(model3)
##           (Intercept)         factorlevel58               times15 
##              14.52025              -0.59875               0.30450 
## factorlevel58:times15 
##               0.56300

C)Hence the regression equation for thickness is given above

plot(model2)

### D)From the above graphs we can see that the normality plot is not up to the mark hence the model is not adequate. ### hence the residuals causes concerns

6.21

FactorA<-rep(rep(c(-1,1),8),7)
FactorB<-rep(rep(c(1,1,-1,-1),4),7)
FactorC<-rep(rep(c(rep(1,4),rep(-1,4)),2),7)
FactorD<-rep(c(rep(1,8),rep(-1,8)),7)
Observation3<-c(10.0,0.0,4.0,0.0,0.0,5.0,6.5,16.5,4.5,19.5,15.0,41.5,8.0,21.5,0.0,18.0,18.0,16.5,6.0,10.0,0.0,20.5,18.5,4.5,18.0,18.0,16.0,39.0,4.5,10.5,0.0,5.0,14.0,4.5,1.0,34.0,18.5,18.0,7.5,0.0,14.5,16.0,8.5,6.5,6.5,6.5,0.0,7.0,12.5,17.5,14.5,11.0,19.5,20.0,6.0,23.5,10.0,5.5,0.0,3.5,10.0,0.0,4.5,10.0,19.0,20.5,12.0,25.5,16.0,29.5,0.0,8.0,0.0,10.0,0.5,7.0,13.0,15.5,1.0,32.5,16.0,17.5,14.0,21.5,15.0,19.0,10.0,8.0,17.5,7.0,9.0,8.5,41.0,24.0,4.0,18.5,18.5,33.0,5.0,0.0,11.0,10.0,0.0,8.0,6.0,36.0,3.0,36.0,14.0,16.0,6.5,8.0)
dat3<-data.frame(FactorA,FactorB,FactorC,FactorD,Observation3)
model4<-lm(Observation3~FactorA*FactorB*FactorC*FactorD,data=dat3)
halfnormal(model4)
## Warning in halfnormal.lm(model4): halfnormal not recommended for models with
## more residual df than model df
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] FactorA e74     e92     FactorB e53

### A)From the above graph we can see that factorA and Factor B are significant. Hence FactorA and FactorB affects the performance(i.e Length of putt and type of putt)

model5<-aov(Observation3~FactorA*FactorB,data=dat3)
summary(model5)
##                  Df Sum Sq Mean Sq F value  Pr(>F)   
## FactorA           1    917   917.1  10.969 0.00126 **
## FactorB           1    388   388.1   4.642 0.03342 * 
## FactorA:FactorB   1    219   218.7   2.615 0.10875   
## Residuals       108   9030    83.6                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(model5)

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

### B)From the above summary we can say that the Factor A and Factor B has p value less than 0.05 hence they are significant ### And from the graph we can say that that the normality plot looks good and hence the model is adequate

6.34

a<-c(-1,1)
A<-rep(a,8)
b<-c(-1,-1,1,1)
B<-rep(b,4)
c<-c(rep(-1,4),rep(1,4))
C<-rep(c,2)
D<-c(rep(-1,8),rep(1,8))
Observation4<-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.30)
dat4<-data.frame(Observation4,A,B,C,D)
model6<-lm(Observation4~A*B*C*D,data = dat4)
coef(model6)
## (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
halfnormal(model6)
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] A     B     A:B   A:B:C

### From Above graph we can see that A,B,AB are signicicant ABC is given significant but by looking at the diagram it seems unsignificant hence cosidring it as not significant

AA<-as.fixed(dat4$A)
BB<-as.fixed(dat4$B)
dat5<-data.frame(Observation4,AA,BB)
model7<-aov(Observation4~AA*BB,data = dat5)
GAD::gad(model7)
## Analysis of Variance Table
## 
## Response: Observation4
##          Df  Sum Sq Mean Sq F value    Pr(>F)    
## AA        1 159.833 159.833 333.088 4.049e-10 ***
## BB        1  36.090  36.090  75.211 1.630e-06 ***
## AA:BB     1  18.297  18.297  38.130 4.763e-05 ***
## Residual 12   5.758   0.480                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(model7)

From the above graph of normal probability plot the data does not look like like its normally distributed hence the model is not adequate

Doing log transform

LogObservation<-log(Observation4)
dat6<-data.frame(LogObservation,A,B,C,D)
model8<-lm(LogObservation~A*B*C*D,data = dat6)
coef(model8)
##  (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
halfnormal(model8)
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] A     B     A:B:C

### From the above graph we can see that A and B are Significant

dat7<-data.frame(LogObservation,AA,BB)
model9<-aov(LogObservation~AA+BB,data = dat7)
GAD::gad(model9)
## Analysis of Variance Table
## 
## Response: LogObservation
##          Df  Sum Sq Mean Sq F value    Pr(>F)    
## AA        1 10.5721 10.5721  962.95 1.408e-13 ***
## BB        1  1.5803  1.5803  143.94 2.095e-08 ***
## Residual 13  0.1427  0.0110                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
plot(model9)

From the above graph we can see that the model is adequate

dat8<-data.frame(LogObservation,A,B)
model10<-lm(LogObservation~A+B,data = dat8)
coef(model10)
## (Intercept)           A           B 
##   1.1854171   0.8128703  -0.3142776

The Model equation in terms of coded variables is log(resistivity) = 1.18+(0.81)A+(-0.314)B+epsilon ijk

6.39

a1<-c(-1,1)
b1<-c(-1,-1,1,1)
c1<-c(-1,-1,-1,-1,1,1,1,1)
d1<-c(-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1)
A1<-c(rep(a1,16))
B1<-c(rep(b1,8))
C1<-c(rep(c1,4))
D1<-c(rep(d1,2))
E1<-c(rep(-1,16),rep(1,16))
Observation5<-c(8.11,5.56,5.77,5.82,9.17,7.8,3.23,5.69,8.82,14.23,9.2,8.94,8.68,11.49,6.25,9.12,7.93,5,7.47,12,9.86,3.65,6.4,11.61,12.43,17.55,8.87,25.38,13.06,18.85,11.78,26.05)
dat9<-data.frame(A1,B1,C1,D1,E1,Observation5)
model11<-lm(Observation5~A1*B1*C1*D1*E1,data=dat9)
halfnormal(model11)
## 
## Significant effects (alpha=0.05, Lenth method):
##  [1] D1       E1       A1:D1    A1       D1:E1    B1:E1    A1:B1    A1:B1:E1 
## 
##  [9] A1:E1    A1:D1:E1

coef(model11)
##    (Intercept)             A1             B1             C1             D1 
##     10.1803125      1.6159375      0.0434375     -0.0121875      2.9884375 
##             E1          A1:B1          A1:C1          B1:C1          A1:D1 
##      2.1878125      1.2365625     -0.0015625     -0.1953125      1.6665625 
##          B1:D1          C1:D1          A1:E1          B1:E1          C1:E1 
##     -0.0134375      0.0034375      1.0271875      1.2834375      0.3015625 
##          D1:E1       A1:B1:C1       A1:B1:D1       A1:C1:D1       B1:C1:D1 
##      1.3896875      0.2503125     -0.3453125     -0.0634375      0.3053125 
##       A1:B1:E1       A1:C1:E1       B1:C1:E1       A1:D1:E1       B1:D1:E1 
##      1.1853125     -0.2590625      0.1709375      0.9015625     -0.0396875 
##       C1:D1:E1    A1:B1:C1:D1    A1:B1:C1:E1    A1:B1:D1:E1    A1:C1:D1:E1 
##      0.3959375     -0.0740625     -0.1846875      0.4071875      0.1278125 
##    B1:C1:D1:E1 A1:B1:C1:D1:E1 
##     -0.0746875     -0.3553125

from above plot we can see that apart from C many of the others are significant

dat10<-data.frame(A1,B1,D1,E1,Observation5)
model12<-aov(Observation5~A1+B1+D1+E1+A1*B1+B1*E1+D1*E1+A1*D1+A1*E1+A1*B1*E1+A1*D1*E1,data = dat10)
plot(model12)

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

### From the above plot we can say that the model is adequate but because there is change in vriance our Assumption is wrong

C)

model13<-aov(Observation5~A1*B1*D1*E1,data = dat10)
halfnormal(model13)
## 
## Significant effects (alpha=0.05, Lenth method):
##  [1] D1       E1       A1:D1    A1       D1:E1    B1:E1    A1:B1    A1:B1:E1 
## 
##  [9] A1:E1    A1:D1:E1 e10

coef(model13)
## (Intercept)          A1          B1          D1          E1       A1:B1 
##  10.1803125   1.6159375   0.0434375   2.9884375   2.1878125   1.2365625 
##       A1:D1       B1:D1       A1:E1       B1:E1       D1:E1    A1:B1:D1 
##   1.6665625  -0.0134375   1.0271875   1.2834375   1.3896875  -0.3453125 
##    A1:B1:E1    A1:D1:E1    B1:D1:E1 A1:B1:D1:E1 
##   1.1853125   0.9015625  -0.0396875   0.4071875
summary(model13)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## A1           1  83.56   83.56  57.233 1.14e-06 ***
## B1           1   0.06    0.06   0.041 0.841418    
## D1           1 285.78  285.78 195.742 2.16e-10 ***
## E1           1 153.17  153.17 104.910 1.97e-08 ***
## A1:B1        1  48.93   48.93  33.514 2.77e-05 ***
## A1:D1        1  88.88   88.88  60.875 7.66e-07 ***
## B1:D1        1   0.01    0.01   0.004 0.950618    
## A1:E1        1  33.76   33.76  23.126 0.000193 ***
## B1:E1        1  52.71   52.71  36.103 1.82e-05 ***
## D1:E1        1  61.80   61.80  42.328 7.24e-06 ***
## A1:B1:D1     1   3.82    3.82   2.613 0.125501    
## A1:B1:E1     1  44.96   44.96  30.794 4.40e-05 ***
## A1:D1:E1     1  26.01   26.01  17.815 0.000650 ***
## B1:D1:E1     1   0.05    0.05   0.035 0.854935    
## A1:B1:D1:E1  1   5.31    5.31   3.634 0.074735 .  
## Residuals   16  23.36    1.46                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Factor C does not seem to be important

After removing factorc the design remains 2^4 design

We can see that there is no change in significant factors

model14<-lm(Observation5~A1+B1+D1+E1, data = dat10)
coef(model14)
## (Intercept)          A1          B1          D1          E1 
##  10.1803125   1.6159375   0.0434375   2.9884375   2.1878125

From the above model we can maximize the predicted response