# \donttest{
# Lagged correlations for all manifest variables, lags 0 to 3.
ctFitCovCheck(ctstantestfit, cor = TRUE, lags = 0:3, plot = TRUE)
# Lagged covariances for one manifest variable.
ctFitCovCheck(ctstantestfit, cor = FALSE, variables = "Y1", lags = 0:5,
plot = FALSE)
# Split the diagnostic by a time independent predictor in the fitted data.
gg <- ctFitCovCheck(ctstantestfit, cor = TRUE, splitby = "TI1", lags = 0:3)
print(gg[[1]])
# Use an external subject-level variable for the split.
splitdat <- unique(data.frame(ctstantestdat)[, "id", drop = FALSE])
splitdat$group <- rep(c("a", "b"), length.out = nrow(splitdat))
ctFitCovCheck(ctstantestfit, splitby = "group", splitdata = splitdat,
lags = 0:2)
# Split observations into early and late periods within each subject.
dat <- data.table::as.data.table(data.frame(ctstantestdat))
dat[, period := ifelse(time <= stats::median(time, na.rm = TRUE),
"early", "late"), by = id]
ctFitCovCheck(ctstantestfit, data = dat, splitby = "period",
split = "factor", lags = 0:2)
# }
Run the code above in your browser using DataLab