Problems

  • Nested Designs using R

Setup

Setup Libraries

# Setup Libraries
library(dplyr)
library(tidyr)
library(readr)
library(knitr)
library(agricolae)
library(lawstat)
library(car)
library(GAD)
library(BSDA)
library(pwr)
library(WebPower)
library(ggplot2)
library(ggfortify)
library(ggpubr)

Nested Designs using R

A rocket propellant manufacturer is studying the burning rate of propellant from three production processes. Four batches of propellant are randomly selected from the output of each process, and three determinations of burning rate are made on each batch. The results follow. State the model equation and hypotheses to be tested. Perform the analysis and draw conclusions, using alpha=0.05 where applicable.

process    <- c(rep(1:3,each = 4,3))
batch      <- c(rep(1:4,9))
obs        <- c(rep(1:3,each = 4*3))
response   <- 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)

dat <- data.frame(process,batch,obs,response)
dat
##    process batch obs response
## 1        1     1   1       25
## 2        1     2   1       19
## 3        1     3   1       15
## 4        1     4   1       15
## 5        2     1   1       19
## 6        2     2   1       23
## 7        2     3   1       18
## 8        2     4   1       35
## 9        3     1   1       14
## 10       3     2   1       35
## 11       3     3   1       38
## 12       3     4   1       25
## 13       1     1   2       30
## 14       1     2   2       28
## 15       1     3   2       17
## 16       1     4   2       16
## 17       2     1   2       17
## 18       2     2   2       24
## 19       2     3   2       21
## 20       2     4   2       27
## 21       3     1   2       15
## 22       3     2   2       21
## 23       3     3   2       54
## 24       3     4   2       29
## 25       1     1   3       26
## 26       1     2   3       20
## 27       1     3   3       14
## 28       1     4   3       13
## 29       2     1   3       14
## 30       2     2   3       21
## 31       2     3   3       17
## 32       2     4   3       25
## 33       3     1   3       20
## 34       3     2   3       24
## 35       3     3   3       50
## 36       3     4   3       33
process <- as.fixed(process)
batch   <- as.random(batch)
obs     <- as.random(obs)

model <- lm(response~
              process +
              batch%in%process)
model
## 
## Call:
## lm(formula = response ~ process + batch %in% process)
## 
## Coefficients:
##     (Intercept)         process2         process3  process1:batch2  
##          27.000          -10.333          -10.667           -4.667  
## process2:batch2  process3:batch2  process1:batch3  process2:batch3  
##           6.000           10.333          -11.667            2.000  
## process3:batch3  process1:batch4  process2:batch4  process3:batch4  
##          31.000          -12.333           12.333           12.667
summary(model)
## 
## Call:
## lm(formula = response ~ process + batch %in% process)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -9.333 -2.083 -0.500  2.333  8.333 
## 
## Coefficients:
##                 Estimate Std. Error t value Pr(>|t|)    
## (Intercept)       27.000      2.511  10.752 1.17e-10 ***
## process2         -10.333      3.551  -2.910  0.00768 ** 
## process3         -10.667      3.551  -3.004  0.00615 ** 
## process1:batch2   -4.667      3.551  -1.314  0.20123    
## process2:batch2    6.000      3.551   1.690  0.10406    
## process3:batch2   10.333      3.551   2.910  0.00768 ** 
## process1:batch3  -11.667      3.551  -3.285  0.00312 ** 
## process2:batch3    2.000      3.551   0.563  0.57853    
## process3:batch3   31.000      3.551   8.729 6.51e-09 ***
## process1:batch4  -12.333      3.551  -3.473  0.00197 ** 
## process2:batch4   12.333      3.551   3.473  0.00197 ** 
## process3:batch4   12.667      3.551   3.567  0.00156 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.349 on 24 degrees of freedom
## Multiple R-squared:  0.8585, Adjusted R-squared:  0.7936 
## F-statistic: 13.23 on 11 and 24 DF,  p-value: 1.177e-07
autoplot(model)

gad(model)
## Analysis of Variance Table
## 
## Response: response
##               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

Source Code

# clear memory and environment
rm(list = ls())
gc()

# Flip 18
# IE 5342 - Dr. Timothy I. Matis
# Jesus R. Rosila Mares
# Nov 29 2021
# Problems:

# Nested Designs using R 

#-------------------------------------------------------------------------------
# Setup Libraries
library(dplyr)
library(tidyr)
library(readr)
library(knitr)
library(agricolae)
library(lawstat)
library(car)
library(GAD)
library(BSDA)
library(pwr)
library(WebPower)
library(ggplot2)
library(ggfortify)
library(ggpubr)
library(SixSigma)
library(DoE.base)
#-------------------------------------------------------------------------------
# 
# Nested Designs using R 
# 
# A rocket propellant manufacturer is studying the burning rate 
#   of propellant from three production processes. Four batches of
#   propellant are randomly selected from the output of each process,
#   and three determinations of burning rate are made on each batch.
#   The results follow. State the model equation and hypotheses to be tested.
#   Perform the analysis and draw conclusions, using alpha=0.05 where applicable.

process    <- c(rep(1:3,each = 4,3))
batch      <- c(rep(1:4,9))
obs        <- c(rep(1:3,each = 4*3))
response   <- 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)

dat <- data.frame(process,batch,obs,response)
dat

process <- as.fixed(process)
batch   <- as.random(batch)
obs     <- as.random(obs)

model <- lm(response~
              process +
              batch%in%process)
model
summary(model)
autoplot(model)
gad(model)
#-------------------------------------------------------------------------------