Multilevel VAR Estimation for Multiple Time Series
The function mlVAR
computes estimates of the multivariate vector autoregression model. This model returns three stuctures: temporal effects (e.g., lag-1 regression weights), contemporaneous relationships (correlations or partial correlations) and between-subject effects (correlations and partial correlations). See details.
mlVAR(data, vars, idvar, lags = 1, dayvar, beepvar, estimator = c("default", "lmer", "lm","Mplus"), contemporaneous = c("default", "correlated", "orthogonal", "fixed", "unique"), temporal = c("default", "correlated", "orthogonal", "fixed", "unique"), nCores = 1, verbose = TRUE, compareToLags, scale = TRUE, scaleWithin = FALSE, AR = FALSE, MplusSave = TRUE, MplusName = "mlVAR", iterations = "(2000)", chains = nCores, signs, orthogonal )
data |
Data frame |
vars |
Vectors of variables to include in the analysis |
idvar |
String indicating the subject ID |
lags |
Vector indicating the lags to include |
dayvar |
String indicating assessment day. Adding this argument makes sure that the first measurement of a day is not regressed on the last measurement of the previous day. IMPORTANT: only add this if the data has multiple observations per day. |
beepvar |
Optional string indicating assessment beep per day. Adding this argument will cause non-consecutive beeps to be treated as missing! |
estimator |
The estimator to be used. |
contemporaneous |
How should the contemporaneous networks be estimated? These networks are always estimated post-hoc by investigating the residuals of the temporal models. |
temporal |
How should the temporal effects be estimated? |
nCores |
Number of cores to use in computation |
verbose |
Logical indicating if console messages and the progress bar should be shown. |
scale |
Logical, should variables be standardized before estimation? |
scaleWithin |
Logial, should variables be scaled within-person (set to |
compareToLags |
A vector indicating which lags to base the data on. If the model is to be compared with a model with multiple lags using |
AR |
Logical, should an auto-regression only model be fitted? |
MplusSave |
Logical, should the Mplus model file and output be saved? |
MplusName |
Name of the Mplus model file and output (without extensions) |
iterations |
The string used to define the number of iterations in Mplus |
chains |
Number of Mplus chains |
signs |
Optional matrix fixing the signs of contemporaneous correlations. Is estimated by running mlVAR with |
orthogonal |
Deprecated argument only added for backward competability. Ignore. |
This function estimates the multi-level VAR model to obtain temporal, contemporaneous and between-subject effects using nodewise estimation. Temporal and between-subject effects are obtained directly from the models and contemporaneous effects are estimated post-hoc by correlating the residuals. See arxiv.org/abs/1609.04156 for details.
Setting estimator = "Mplus"
will generate a Mplus model, run the analysis and read the results into R. Mplus 8 is required for this estimation. It is recommended to set contemporaneous = "fixed"
, though not required. For the estimation of contemporaneous random effects, the signs of contemporaneous *correlations * (not partial correlations) need be set (or estimated) via the signs
argument.
An mlVAR
object
Sacha Epskamp (mail@sachaepskamp.com)
Bringmann, L. F., Vissers, N., Wichers, M., Geschwind, N., Kuppens, P., Peeters, F., ... & Tuerlinckx, F. (2013). A network approach to psychopathology: New insights into clinical longitudinal data. PloS one, 8(4), e60188.
Hamaker, E. L., & Grasman, R. P. (2014). To center or not to center? Investigating inertia with a multilevel autoregressive model. Frontiers in psychology, 5.
Epskamp, S., Waldorp, L. J., Mottus, R., & Borsboom, D. (2017). Discovering Psychological Dynamics: The Gaussian Graphical Model in Cross-sectional and Time-series Data. arxiv.org/abs/1609.04156.
## Not run: ### Small example ### # Simulate data: Model <- mlVARsim(nPerson = 50, nNode = 3, nTime = 50, lag=1) # Estimate using correlated random effects: fit1 <- mlVAR(Model$Data, vars = Model$vars, idvar = Model$idvar, lags = 1, temporal = "correlated") # Print some pointers: print(fit1) # Summary of all parameter estimates: summary(fit1) # Compare temporal relationships: layout(t(1:2)) plot(Model, "temporal", title = "True temporal relationships", layout = "circle") plot(fit1, "temporal", title = "Estimated temporal relationships", layout = "circle") # Compare contemporaneous partial correlations: layout(t(1:2)) plot(Model, "contemporaneous", title = "True contemporaneous relationships", layout = "circle") plot(fit1, "contemporaneous", title = "Estimated contemporaneous relationships", layout = "circle") # Compare between-subjects partial correlations: layout(t(1:2)) plot(Model, "between", title = "True between-subjects relationships", layout = "circle") plot(fit1, "between", title = "Estimated between-subjects relationships", layout = "circle") # Run same model with non-correlated temporal relationships and fixed-effect model: fit2 <- mlVAR(Model$Data, vars = Model$vars, idvar = Model$idvar, lags = 1, temporal = "orthogonal") fit3 <- mlVAR(Model$Data, vars = Model$vars, idvar = Model$idvar, lags = 1, temporal = "fixed") # Compare models: mlVARcompare(fit1,fit2,fit3) # Inspect true parameter correlation matrix: Model$model$Omega$cor$mean # Even though correlations are high, orthogonal model works well often! ### Large example ### Model <- mlVARsim(nPerson = 100, nNode = 10, nTime = 100,lag=1) # Correlated random effects no longer practical. Use orthogonal or fixed: fit4 <- mlVAR(Model$Data, vars = Model$vars, idvar = Model$idvar, lags = 1, temporal = "orthogonal") fit5 <- mlVAR(Model$Data, vars = Model$vars, idvar = Model$idvar, lags = 1, temporal = "fixed") # Compare models: mlVARcompare(fit4, fit5) # Compare temporal relationships: layout(t(1:2)) plot(Model, "temporal", title = "True temporal relationships", layout = "circle") plot(fit4, "temporal", title = "Estimated temporal relationships", layout = "circle") # Compare contemporaneous partial correlations: layout(t(1:2)) plot(Model, "contemporaneous", title = "True contemporaneous relationships", layout = "circle") plot(fit4, "contemporaneous", title = "Estimated contemporaneous relationships", layout = "circle") # Compare between-subjects partial correlations: layout(t(1:2)) plot(Model, "between", title = "True between-subjects relationships", layout = "circle") plot(fit4, "between", title = "Estimated between-subjects relationships", layout = "circle") ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.