Question 9-10

Data:

library(GAD)
## Warning: package 'GAD' was built under R version 4.2.2
## 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.
Pos<- rep(c(rep(1,3), rep(2,3)),3)
Temp<-c(rep(1,6), rep(2,6), rep(3,6))
Obs_9<-c(570,565,583,528,547,521,1063,1080,1043,988,1026,1004,565,510,590,526,538,532)
Data_9<-data.frame(Pos,Temp,Obs_9)

Part A

Assume that both Temperature and Position are fixed effects.  Report p-values

Data_9$Pos<-as.fixed(Data_9$Pos)
Data_9$Temp<-as.fixed(Data_9$Temp)  

model_9A<-aov(Obs_9~Pos*Temp, data = Data_9)  
summary(model_9A)
##             Df Sum Sq Mean Sq  F value   Pr(>F)    
## Pos          1   7160    7160   15.998  0.00176 ** 
## Temp         2 945342  472671 1056.117 3.25e-14 ***
## Pos:Temp     2    818     409    0.914  0.42711    
## Residuals   12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Comment: P value for Position: 0.00176, P value for Temp : 3.25e-14 and for Interaction Position: Temp is 0.42711

Part B

Assume that both Temperature and Position are random effects.  Report p-values 

Data_9$Pos<-as.random(Data_9$Pos)
Data_9$Temp<-as.random(Data_9$Temp)  

model_9B<-aov(Obs_9~Pos*Temp, data = Data_9)  
summary(model_9B)
##             Df Sum Sq Mean Sq  F value   Pr(>F)    
## Pos          1   7160    7160   15.998  0.00176 ** 
## Temp         2 945342  472671 1056.117 3.25e-14 ***
## Pos:Temp     2    818     409    0.914  0.42711    
## Residuals   12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Comment: P value for Position: 0.00176, P value for Temp : 3.25e-14 and for Interaction Position: Temp is 0.42711

Part C

Assume the Position effect is fixed and the Temperature effect is random.  Report p-values

Data_9$Pos<-as.fixed(Data_9$Pos)
Data_9$Temp<-as.random(Data_9$Temp)  

model_9C<-aov(Obs_9~Pos*Temp, data = Data_9)  
summary(model_9C)
##             Df Sum Sq Mean Sq  F value   Pr(>F)    
## Pos          1   7160    7160   15.998  0.00176 ** 
## Temp         2 945342  472671 1056.117 3.25e-14 ***
## Pos:Temp     2    818     409    0.914  0.42711    
## Residuals   12   5371     448                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Comment: P value for Position: 0.00176, P value for Temp : 3.25e-14 and for Interaction Position: Temp is 0.42711

Part D

Comment on similarities and/or differences between the p-values in parts a,b,c.

Comment: As per above analysis, we found that there is no effect of having Fixed or Random effect of Position or Temperature on model. all p values are same for all kind of trials.