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.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
library(pwr)
library(MASS)
library(agricolae)

Question 01

type<-c(rep(1,6),rep(2,6))
temp<-c(rep(seq(900,1000,50),4))
obs<-c(4.6,9.15,12.01,4.4,9.85,11.58,3.2,9.38,10.81,3.5,10.02,10.6)
type<-as.fixed(type)
temp<-as.fixed(temp)
dat<-data.frame(type,temp,obs)
dat
##    type temp   obs
## 1     1  900  4.60
## 2     1  950  9.15
## 3     1 1000 12.01
## 4     1  900  4.40
## 5     1  950  9.85
## 6     1 1000 11.58
## 7     2  900  3.20
## 8     2  950  9.38
## 9     2 1000 10.81
## 10    2  900  3.50
## 11    2  950 10.02
## 12    2 1000 10.60
mod<-aov(obs~type*temp,data=dat)
summary(mod)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## type         1   1.39    1.39  13.226   0.0109 *  
## temp         2 118.11   59.06 563.062 1.49e-07 ***
## type:temp    2   1.16    0.58   5.546   0.0433 *  
## Residuals    6   0.63    0.10                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qf(0.95,2,6)
## [1] 5.143253
qf(0.95,1,16)
## [1] 4.493998

Question 9

pos<-c(rep(1,9),rep(2,9))
temp<-c(rep(seq(800,850,25),6))
obs<-c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,
1004,532)
pos<-as.fixed(pos)
temp<-as.fixed(temp)
dat<-data.frame(pos,temp,obs)
dat
##    pos temp  obs
## 1    1  800  570
## 2    1  825 1063
## 3    1  850  565
## 4    1  800  565
## 5    1  825 1080
## 6    1  850  510
## 7    1  800  583
## 8    1  825 1043
## 9    1  850  590
## 10   2  800  528
## 11   2  825  988
## 12   2  850  526
## 13   2  800  547
## 14   2  825 1026
## 15   2  850  538
## 16   2  800  521
## 17   2  825 1004
## 18   2  850  532
mod1<-aov(obs~pos*temp,data=dat)
gad(mod1)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq  F value   Pr(>F)    
## pos       1   7160    7160   15.998 0.001762 ** 
## temp      2 945342  472671 1056.117 3.25e-14 ***
## pos:temp  2    818     409    0.914 0.427110    
## Residual 12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

9-A P values for position, temperature and their interactions are 0.00176, 3.25e-14 and 0.42711

pos<-c(rep(1,9),rep(2,9))
temp<-c(rep(seq(800,850,25),6))
obs<-c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,
1004,532)
pos<-as.random(pos)
temp<-as.random(temp)
dat<-data.frame(pos,temp,obs)
dat
##    pos temp  obs
## 1    1  800  570
## 2    1  825 1063
## 3    1  850  565
## 4    1  800  565
## 5    1  825 1080
## 6    1  850  510
## 7    1  800  583
## 8    1  825 1043
## 9    1  850  590
## 10   2  800  528
## 11   2  825  988
## 12   2  850  526
## 13   2  800  547
## 14   2  825 1026
## 15   2  850  538
## 16   2  800  521
## 17   2  825 1004
## 18   2  850  532
mod2<-aov(obs~pos*temp,data=dat)
gad(mod2)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq  F value    Pr(>F)    
## pos       1   7160    7160   17.504 0.0526583 .  
## temp      2 945342  472671 1155.518 0.0008647 ***
## pos:temp  2    818     409    0.914 0.4271101    
## Residual 12   5371     448                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

9-B P values for position, temperature and their interactions are 0.0526583, 0.0008647 and 0.4271101

pos<-c(rep(1,9),rep(2,9))
temp<-c(rep(seq(800,850,25),6))
obs<-c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,
1004,532)
pos<-as.fixed(pos)
temp<-as.random(temp)
dat<-data.frame(pos,temp,obs)
dat
##    pos temp  obs
## 1    1  800  570
## 2    1  825 1063
## 3    1  850  565
## 4    1  800  565
## 5    1  825 1080
## 6    1  850  510
## 7    1  800  583
## 8    1  825 1043
## 9    1  850  590
## 10   2  800  528
## 11   2  825  988
## 12   2  850  526
## 13   2  800  547
## 14   2  825 1026
## 15   2  850  538
## 16   2  800  521
## 17   2  825 1004
## 18   2  850  532
mod3<-aov(obs~pos*temp,data=dat)
gad(mod3)
## Analysis of Variance Table
## 
## Response: obs
##          Df Sum Sq Mean Sq  F value   Pr(>F)    
## pos       1   7160    7160   17.504  0.05266 .  
## temp      2 945342  472671 1056.117 3.25e-14 ***
## pos:temp  2    818     409    0.914  0.42711    
## Residual 12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

9-C P values for position, temperature and their interactions are 0.05266, 3.25e-14 and 0.42711

9-D

Similarity: p values and F value for interaction term (pos:temp) is same for part A,B and C also the interaction term is not significant in all the part A,B and C

Difference: p values and F value for the position and the temperature differs in part A,B and C based on whether they are fixed or random. Since in random case, we are dividing mean squares of the factor by their interactions instead of dividing by MSE (if the factor is fixed)

Question 11

A<-c(-1,1)
B<-c(rep(-1,2),rep(1,2))
C<-c(rep(-1,4),rep(1,4))
D<-c(rep(-1,8),rep(1,8))
obs<-c(12,18,13,20,17,25,15,25,10,24,13,24,19,21,17,23)
dat<-data.frame(A,B,C,D,obs)
dat
##     A  B  C  D obs
## 1  -1 -1 -1 -1  12
## 2   1 -1 -1 -1  18
## 3  -1  1 -1 -1  13
## 4   1  1 -1 -1  20
## 5  -1 -1  1 -1  17
## 6   1 -1  1 -1  25
## 7  -1  1  1 -1  15
## 8   1  1  1 -1  25
## 9  -1 -1 -1  1  10
## 10  1 -1 -1  1  24
## 11 -1  1 -1  1  13
## 12  1  1 -1  1  24
## 13 -1 -1  1  1  19
## 14  1 -1  1  1  21
## 15 -1  1  1  1  17
## 16  1  1  1  1  23
mod4<-lm(obs~A*B*C*D,data=dat)
halfnormal(mod4)
## 
## Significant effects (alpha=0.05, Lenth method):
## [1] A     C     A:C:D

Question 11-A

A,C and A:C:D factors are significant

mod5<-lm(obs~A+C+D+A:C:D,data=dat)
summary(mod5)
## 
## Call:
## lm.default(formula = obs ~ A + C + D + A:C:D, data = dat)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -2.250 -1.000 -0.250  1.062  2.500 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  18.5000     0.4024  45.973 6.31e-14 ***
## A             4.0000     0.4024   9.940 7.85e-07 ***
## C             1.7500     0.4024   4.349  0.00116 ** 
## D             0.3750     0.4024   0.932  0.37140    
## A:C:D        -1.3750     0.4024  -3.417  0.00575 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.61 on 11 degrees of freedom
## Multiple R-squared:  0.9221, Adjusted R-squared:  0.8938 
## F-statistic: 32.57 on 4 and 11 DF,  p-value: 4.851e-06

Question 11-B Hypothesis H_0: (alphagammadelta)_ikl = 0 H_a: (alphagammadelta)_ikl != 0

From the summary, we see that the interaction term A:C:D is significant as the p value is less than alpha= 0.05 level of significance. so we reject the null hypothesis.

Question 13

process<-c(rep(1,12),rep(2,12),rep(3,12))
batch<-rep(c(rep(1,3),rep(2,3),rep(3,3),rep(4,3)),3)
obs<-c(25,30,26,19,28,20,15,17,14,15,16,13,29,27,24,23,24,21,28,21,27,35,27,25,24,25,20,35,21,24,38,34,30,25,29,33)
process<-as.fixed(process)
batch<-as.random(batch)
dat<-data.frame(process,batch,obs)
dat
##    process batch obs
## 1        1     1  25
## 2        1     1  30
## 3        1     1  26
## 4        1     2  19
## 5        1     2  28
## 6        1     2  20
## 7        1     3  15
## 8        1     3  17
## 9        1     3  14
## 10       1     4  15
## 11       1     4  16
## 12       1     4  13
## 13       2     1  29
## 14       2     1  27
## 15       2     1  24
## 16       2     2  23
## 17       2     2  24
## 18       2     2  21
## 19       2     3  28
## 20       2     3  21
## 21       2     3  27
## 22       2     4  35
## 23       2     4  27
## 24       2     4  25
## 25       3     1  24
## 26       3     1  25
## 27       3     1  20
## 28       3     2  35
## 29       3     2  21
## 30       3     2  24
## 31       3     3  38
## 32       3     3  34
## 33       3     3  30
## 34       3     4  25
## 35       3     4  29
## 36       3     4  33
mod6<-lm(obs~process+batch%in%process)
gad(mod6)
## Analysis of Variance Table
## 
## Response: obs
##               Df Sum Sq Mean Sq F value   Pr(>F)   
## process        2 446.06 223.028  3.5365 0.073563 . 
## process:batch  9 567.58  63.065  4.1965 0.002349 **
## Residual      24 360.67  15.028                    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

13-A Model equation \(Y_{ijk}\) = \(\mu + \alpha_i +\beta_{j(i)} + \epsilon_{ijk}\)

13-B

Hypothesis: \(H_0\) = \(\alpha_i = 0\)

\(H_a\) = \(\alpha_i \neq 0\)

\(H_0\) = \(\beta_{j(i)} = 0\)

\(H_a\) = \(\beta_{j(i)} \neq 0\)

13-C

From the summary, we see that the process factor is fixed and p value is higher than \(\alpha = 0.05\) so we fail to reject \(H_0\) and the factor process is not significant. But the nested factor batch is within the factor process, p value is less than \(\alpha = 0.05\) so we reject \(H_0\) and the nested factor batch is within the factor process is significant.