Problem 9

Entering the data and sorting them out:

library(GAD)
## Warning: package 'GAD' was built under R version 4.1.3
## Loading required package: matrixStats
## Warning: package 'matrixStats' was built under R version 4.1.3
## Loading required package: R.methodsS3
## Warning: package 'R.methodsS3' was built under R version 4.1.3
## R.methodsS3 v1.8.2 (2022-06-13 22:00:14 UTC) successfully loaded. See ?R.methodsS3 for help.
obs9 <- c(570,  1063,   565,
          565,  1080,   510,
          583,  1043,   590,
          528,  988,    526,
          547,  1026,   538,
          521,  1004,   532)
temp9 <- rep(c(800,825,850),6)
position9 <- c(rep(1,9), rep(2,9))
temp9fixed <- as.fixed(temp9)
temp9random <- as.random(temp9)
position9fixed <- as.fixed(position9)
position9random <- as.random(position9)

answer 9(a):

model1 <- aov(obs9~temp9fixed*position9fixed)
gad(model1)
## Analysis of Variance Table
## 
## Response: obs9
##                           Df Sum Sq Mean Sq  F value   Pr(>F)    
## temp9fixed                 2 945342  472671 1056.117 3.25e-14 ***
## position9fixed             1   7160    7160   15.998 0.001762 ** 
## temp9fixed:position9fixed  2    818     409    0.914 0.427110    
## Residual                  12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For a significance level of alpha = 0.05, both the fixed temperature and position show significant main effects with p-value < 0.05. No significant 2-way interaction observed.

fixed temperature p-value = 3.25e-14

fixed position p-value = 0.001762

2-way interaction p-value = 0.427110

answer 9(b):

model2 <- aov(obs9~temp9random*position9random)
gad(model2)
## Analysis of Variance Table
## 
## Response: obs9
##                             Df Sum Sq Mean Sq  F value    Pr(>F)    
## temp9random                  2 945342  472671 1155.518 0.0008647 ***
## position9random              1   7160    7160   17.504 0.0526583 .  
## temp9random:position9random  2    818     409    0.914 0.4271101    
## Residual                    12   5371     448                       
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For a significance level of alpha = 0.05, only temperature shows significant main effects with p-value < 0.05. No significant 2-way interaction observed.

fixed temperature p-value = 0.0008647

fixed position p-value = 0.0526583

2-way interaction p-value = 0.427110

answer 9(c):

model3 <- aov(obs9~position9fixed*temp9random)
gad(model3)
## Analysis of Variance Table
## 
## Response: obs9
##                            Df Sum Sq Mean Sq  F value   Pr(>F)    
## position9fixed              1   7160    7160   17.504  0.05266 .  
## temp9random                 2 945342  472671 1056.117 3.25e-14 ***
## position9fixed:temp9random  2    818     409    0.914  0.42711    
## Residual                   12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For a significance level of alpha = 0.05, only temperature shows significant main effects with p-value < 0.05. No significant 2-way interaction observed.

fixed temperature p-value = 3.25e-14

fixed position p-value = 0.05266

2-way interaction p-value = 0.42711

answer 9(d):

When both the main effects are considered fixed, both of them show significant p-value < 0.05. When both of them are considered random effects, only temperature shows significant main effect with p-value < 0.05. When temperature is considered random and position fixed, the same case of only significant temperature main effect persists. So, whether both the factors are fixed or both random, or only temperature random-It is always a significant main effect. Position becomes a significant main effect only if it is considered a fixed effect with a fixed temperature.

In a the cases, the two-way interaction is always insignificant with p-value > 0.05.

Complete code chunk:

library(GAD)
obs9 <- c(570,  1063,   565,
          565,  1080,   510,
          583,  1043,   590,
          528,  988,    526,
          547,  1026,   538,
          521,  1004,   532)
temp9 <- rep(c(800,825,850),6)
position9 <- c(rep(1,9), rep(2,9))
temp9fixed <- as.fixed(temp9)
temp9random <- as.random(temp9)
position9fixed <- as.fixed(position9)
position9random <- as.random(position9)

model1 <- aov(obs9~temp9fixed*position9fixed)
gad(model1)

model2 <- aov(obs9~temp9random*position9random)
gad(model2)

model3 <- aov(obs9~position9fixed*temp9random)
gad(model3)