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.
t <- c(800,825,850)
temp <- rep(t,6)
pos <- c(rep(1,9),rep(2,9))
obs <- c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
data <- data.frame(temp, pos,obs)
data$temp <- as.fixed(data$temp)
data$pos <- as.fixed(data$pos)
model <- aov(obs~temp+pos+temp*pos,data=data)
gad(model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## temp 2 945342 472671 1056.117 3.25e-14 ***
## pos 1 7160 7160 15.998 0.001762 **
## temp:pos 2 818 409 0.914 0.427110
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
data$temp <- as.random(data$temp)
data$pos <- as.random(data$pos)
model <- aov(obs~temp+pos+temp*pos,data=data)
gad(model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## temp 2 945342 472671 1155.518 0.0008647 ***
## pos 1 7160 7160 17.504 0.0526583 .
## temp:pos 2 818 409 0.914 0.4271101
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
data$temp <- as.random(data$temp)
data$pos <- as.fixed(data$pos)
model <- aov(obs~temp+pos+temp*pos,data=data)
gad(model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## temp 2 945342 472671 1056.117 3.25e-14 ***
## pos 1 7160 7160 17.504 0.05266 .
## temp:pos 2 818 409 0.914 0.42711
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
The fixed effect model divides the Mean Square of each main effect and the interaction effect by the Mean Square Error.
Differently for the random effect model, the Mean Square of each main effect has to be divided by the Mean Square Error of the interaction in order to achieve an F distribution centered in one under Ho.
Lastly, the for a Mixed Effect Model, we have to divide ONLY the fixed factor for the Mean Square of the Interaction and the random effect for the mean square error.
Therefore, the differences and similarities regarding the p-values come from how to approach the different factors in order to grant coherense in the model. For instance, the p-value of the position in the mixed model is equal to the random model, even though in the first it is a fixed effect. The same is happening for the temperature in the mixed model and in the fixed model, since they are also calculated in the same way.