2

I'm trying to replicate an analysis in a paper by Milliken (https://sci-hub.tw/10.1016/s0169-7161(03)22007-1, section 8) from SAS code to R. I'm quite stumped to be honest. It's a split plot repeated measure design where the correlation structure is a compound symmetry structure. Below is the data and SAS code and it's results.

Data

library(magrittr)
library(tidyr)
library(dplyr)
dta <- data.frame(
  tmp = c(rep(900, 3), rep(1000, 3), rep(1100, 3)),
  posit = rep(c("top", "mid", "bot"), 3),
  lot_1 = c(189, 211, 178, 213, 220, 197, 194, 212, 189),
  lot_2 = c(195, 206, 162, 199, 230, 198, 215, 208, 193),
  lot_3 = c(183, 210, 173, 189, 228, 202, 194, 201, 180),
  lot_4 = c(187, 223, 181, 183, 221, 168, 232, 215, 192),
  lot_5 = c(173, 191, 149, 202, 213, 151, 190, 198, 182)
)


dta <- dta %>% 
  tidyr::pivot_longer(., cols = c(lot_1, lot_2, lot_3, lot_4, lot_5), 
               names_to = "Lot") %>% 
  dplyr::mutate(Lot = as.factor(Lot), 
                tmp = as.factor(tmp), 
                lot_tmp = as.factor(paste0(Lot, "-", tmp)))

SAS Code

proc mixed data = dta cl covtest ic; 
class Posit temp lot; 
model thick = temp Posit Posit*temp/ddfm = kr; random lot; 
repeated posit/type = cs subject = lot*temp r rcorr

Output from SAS
enter image description here

R code attempt


## this works but isn't doing the same thing as above 
library(nlme)

m1 <- lme(
  value ~ temp + posit + temp:posit, 
  random = ~ 1 | lot ,
  correlation = corCompSymm(form=~1|lot),
  data = dta, method = "REML"
)


I'm stuck at this point on how to add a repeated structure to the posit factor.

Thank you for the help!

0 Answers0