1 Nested Designs using R

Input data:

library(GAD)
Process <- rep(c(rep(1,4),rep(2,4),rep(3,4)),3)
Batch <- rep(rep(c(1,2,3,4),3),3)
obs <- c(25,19,15,15,19,23,18,35,14,35,38,25,30,28,17,16,17,24,21,27,15,21,54,29,26,20,14,13,14,21,17,25,20,24,50,33)
data <- data.frame(Process,Batch,obs)
data
##    Process Batch obs
## 1        1     1  25
## 2        1     2  19
## 3        1     3  15
## 4        1     4  15
## 5        2     1  19
## 6        2     2  23
## 7        2     3  18
## 8        2     4  35
## 9        3     1  14
## 10       3     2  35
## 11       3     3  38
## 12       3     4  25
## 13       1     1  30
## 14       1     2  28
## 15       1     3  17
## 16       1     4  16
## 17       2     1  17
## 18       2     2  24
## 19       2     3  21
## 20       2     4  27
## 21       3     1  15
## 22       3     2  21
## 23       3     3  54
## 24       3     4  29
## 25       1     1  26
## 26       1     2  20
## 27       1     3  14
## 28       1     4  13
## 29       2     1  14
## 30       2     2  21
## 31       2     3  17
## 32       2     4  25
## 33       3     1  20
## 34       3     2  24
## 35       3     3  50
## 36       3     4  33

Model equation:

\[ \gamma_{ijk} = \mu + \alpha_{i} + \beta_{j(i))} + \epsilon_{ijk} \]

Hypothesis:

Factor process:

\(H_{o}\): \(\mu_{i1} = \mu_{i2} = \mu_{i3}\)

\(H_{a}\): at least one \(\mu\) is differrent

Factor Batch:

\(H_{o}\): \(\mu_{j1} = \mu_{j2} = \mu_{j3}\)

\(H_{a}\): at least one \(\mu\) is differrent

Build model and test:

Process <- as.fixed(Process)
Batch <- as.random(Batch)
model <- lm(obs ~ Process + Batch%in%Process)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: obs
##               Df  Sum Sq Mean Sq F value    Pr(>F)    
## Process        2  676.06  338.03  1.4643    0.2815    
## Process:Batch  9 2077.58  230.84 12.2031 5.477e-07 ***
## Residual      24  454.00   18.92                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

For factor process: P-value = 0.2815 > alpha (0.05). These is no evident to reject the Null hypothesis.

For factor batch: P-value = 5.477e-07 < alpha (0.05). Reject Null hypothesis.

2 Complete R Code

#Input data
library(GAD)
Process <- rep(c(rep(1,4),rep(2,4),rep(3,4)),3)
Batch <- rep(rep(c(1,2,3,4),3),3)
obs <- c(25,19,15,15,19,23,18,35,14,35,38,25,30,28,17,16,17,24,21,27,15,21,54,29,26,20,14,13,14,21,17,25,20,24,50,33)
data <- data.frame(Process,Batch,obs)
#Build model and test
Process <- as.fixed(Process)
Batch <- as.random(Batch)
model <- lm(obs ~ Process + Batch%in%Process)
GAD::gad(model)