Required library:
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.
The mixed model equation is:
Yijk =μ + αi + (σβj(i) )^2 + εijk
μ = grand mean αi = Higher level Factor (Machine-fixed effect)
(σβj(i) )^2= Lower level Factor (Spindle-Random effect)
εijk = error
Null Hypothesis, Ho: αi = 0
(σβj(i))^2 = 0
Alternative hypothesis, Ha: αi ≠ 0
( (σβj(i) )^2 ≠ 0
Entering the data:
mac <- c(rep(1,8), rep(2,8), rep(3,8))
spind <- rep(c(rep(1,4), rep(2,4)), 3)
obs <- c(12,9,11,12,8,9,10,8,14,15,13,14,12,10,11,13,14,10,12,11,16,15,15,14)
dat <- data.frame(mac,spind, obs)
dat$mac <- as.fixed(dat$mac)
dat$spind <- as.random(dat$spind)
We now generate our linear model and check the gad summary:
model <- lm(obs~mac+spind%in%mac, data= dat)
gad(model)
## Analysis of Variance Table
##
## Response: obs
## Df Sum Sq Mean Sq F value Pr(>F)
## mac 2 55.75 27.8750 1.9114 0.2915630
## mac:spind 3 43.75 14.5833 9.9057 0.0004428 ***
## Residual 18 26.50 1.4722
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
From the output table we see that the machine is not significant since the P-value is larger than our cirtical p-value of 0.05. But the spindle nested in the machine is significant with p-value << 0.05. So we reject the null hypothesis for the nested lower level factor. Thus the lower level factor (spindle nested in machine is significant).
library(GAD)
mac <- c(rep(1,8), rep(2,8), rep(3,8))
spind <- rep(c(rep(1,4), rep(2,4)), 3)
obs <- c(12,9,11,12,8,9,10,8,14,15,13,14,12,10,11,13,14,10,12,11,16,15,15,14)
dat <- data.frame(mac,spind, obs)
dat$mac <- as.fixed(dat$mac)
dat$spind <- as.random(dat$spind)
model <- lm(obs~mac+spind%in%mac, data= dat)
gad(model)