This function calculates the empirical autocorrelation function for the within-subject residuals from a smn.lmm or smsn.lmm fit. The autocorrelation values are calculated using pairs of residuals within-subjects. The autocorrelation function is useful for investigating serial correlation models for discrete-time data, preferably equally spaced.
acfresid(object, maxLag, resLevel = "marginal", resType = "normalized",
calcCI = FALSE, levelCI, MCiter, seed)A data frame with columns lag, ACF, and n.used representing, respectively, the lag between residuals within a pair, the corresponding empirical autocorrelation, and the number of pairs used. If calcCI=TRUE, the data frame has two extra columns containing the confidence intervals for the conditionally independent model. The returned value inherits from class acfresid.
An object inheriting from class SMN or SMSN, representing
a fitted scale mixture of (skew) normal linear mixed model.
An optional integer giving the maximum lag for which the autocorrelation should be calculated. Defaults to maximum lag in the within-subject residuals.
"marginal" (default) or "conditional". An optional character string specifying which residual should be used. For details see residuals.SMN.
"response", "normalized" (default), or "modified". An optional character string specifying which type of residual should be used. For details see residuals.SMN.
TRUE or FALSE (default). A logical value indicating if Monte Carlo confidence intervals should be computed for the conditionally independent model, which can be used for testing if the autocorrelations are zero.
An optional numeric value in \((0,1)\) indicating the confidence level that should be used in the Monte Carlo confidence intervals. Default is 0.95.
An optional discrete value indicating the number of Monte Carlo samples that should be used to compute the confidence intervals. Default is 300.
An optional value used to specify seeds inside the function. Default is to use a random seed.
Fernanda L. Schumacher, Larissa A. Matos and Victor H. Lachos
Pinheiro, J. C. and Bates, D. M. (2000). Mixed-Effects Models in S and S-PLUS. Springer, New York, NY.
Schumacher, F. L., Matos, L. A., and Lachos, V. H. (2025). "skewlmm: An R Package for Fitting Skewed and Heavy-Tailed Linear Mixed Models." Journal of Statistical Software, 115(7), 1--32.
Schumacher, F. L., Lachos, V. H., and Matos, L. A. (2021). Scale mixture of skew-normal linear mixed models with within-subject serial dependence. Statistics in Medicine 40(7), 1790-1810.
smn.lmm, smsn.lmm, plot.acfresid
fm1 = smn.lmm(distance ~ age+Sex, data=nlme::Orthodont, groupVar="Subject")
acf1 = acfresid(fm1)
acf1
plot(acf1)
## computing simulated bands
acfCI = acfresid(fm1, calcCI=TRUE)
plot(acfCI)
Run the code above in your browser using DataLab