Question 9
# a.Assume that both Temperature and Position are fixed effects.
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.
Position<-c(rep(1,9),rep(2,9))
Temperature<-rep(seq(1,3),6)
observation<-c(570,1063,565,565,1080,510,583,1043,590,528,988,526,547,1026,538,521,1004,532)
Position<-as.fixed(Position)
Temperature<-as.fixed(Temperature)
dat<-c(Position,Temperature,observation)
model<-aov(observation~Position*Temperature)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## Position 1 7160 7160 15.998 0.00176 **
## Temperature 2 945342 472671 1056.117 3.25e-14 ***
## Position:Temperature 2 818 409 0.914 0.42711
## Residuals 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p value interaction 0.42711 which is greater than alpha so fail to
reject H0 null Hypothesis
The p-vales are as follows:
position p-value = 0.001762
Temperature p-value = 3.25e-14
position-temperature interaction p-value = 0.42711
position and temperature are significant at α=0.05
# b.Assume that both Temperature and Position are random effects
library(GAD)
Position1<-as.random(Position)
Temperature1<-as.random(Temperature)
dat2<-c(Position1,Temperature1,observation)
model1<-aov(observation~Position1*Temperature1)
gad(model1)
## Analysis of Variance Table
##
## Response: observation
## Df Sum Sq Mean Sq F value Pr(>F)
## Position1 1 7160 7160 17.504 0.0526583 .
## Temperature1 2 945342 472671 1155.518 0.0008647 ***
## Position1:Temperature1 2 818 409 0.914 0.4271101
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p value interaction 0.4271101 which is greater than alpha so fail to
reject H0 null Hypothesis
The p-vales are as follows:
position p-value = 0.0526583
Temperature p-value = 0.0008647
position-temperature interaction p-value = 0.4271101
position and temperature are significant at α=0.05
# c.Assume the Position effect is fixed and the Temperature effect is random. Report p-values
library(GAD)
Position<-as.fixed(Position)
Temperature2<-as.random(Temperature1)
dat3<-c(Position,Temperature2,observation)
model2<-aov(observation~Position*Temperature1)
gad(model2)
## Analysis of Variance Table
##
## Response: observation
## Df Sum Sq Mean Sq F value Pr(>F)
## Position 1 7160 7160 17.504 0.05266 .
## Temperature1 2 945342 472671 1056.117 3.25e-14 ***
## Position:Temperature1 2 818 409 0.914 0.42711
## Residual 12 5371 448
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
p value interaction 0.42711 which is greater than alpha so fail to
reject H0 null Hypothesis
The p-vales are as follows:
position p-value = 0.05266
Temperature p-value = 3.25e-14
position-temperature interaction p-value = 0.42711
position and temperature are significant at α=0.05
From the following a,b,c
Using Fixed for both Temperature and Position are significant at
level of signifance the p value is 0.42711
If the Temperature and Position are random effect it shows varitions
in the F and p values
if we change Position effect is fixed and the Temperature effect is
random shows varitions in the F and p values
and all other values are same
Comments: