# Four repeated measures on each of 30 subjects.
set.seed(113)
n <- 30; k <- 4
subj <- factor(rep(1:n, each = k))
tm <- factor(rep(1:k, times = n))
y <- as.vector(t(matrix(rnorm(n * k), n, k) +
rep(rnorm(n, 0, 1), each = k)))
d <- data.frame(y, subj, tm)
# All eight structures at once. Read the table by comparing AIC and BIC
# across rows, and use the likelihood-ratio test only for the nested
# comparison it reports, each structure against UN.
compare_cov_structures(d, outcome = "y", subject = "subj",
time = "tm")
# A subset, requested with lowercase aliases (matching is case
# insensitive).
compare_cov_structures(d, outcome = "y", subject = "subj",
time = "tm",
structures = c("cs", "csh", "ar1", "arh1"))
Run the code above in your browser using DataLab