evaluateLags | R Documentation |
This function creates the desired number of lags and tests consecutive models from a model with no lags (lag 0), lag 0 + lag1, etc. and reports model performance. This helps evaluate how many lags are needed.
evaluateLags(formula, lagvar, nlags = 0L, idvar, data, ...)
formula |
A |
lagvar |
A |
nlags |
An |
idvar |
A |
data |
A |
... |
Additional arguments passed to |
Currently only linear mixed effects models are allowed.
## these examples are slow to run
data(aces_daily, package = "JWileymisc")
evaluateLags(
"NegAff ~ Female + Age + BornAUS + (1 | UserID)",
"STRESS",
4L,
"UserID",
aces_daily)
## not run, more complex example with random slope, fails to converge
evaluateLags(
"NegAff ~ Female + Age + BornAUS + (1 + STRESS | UserID)",
"STRESS",
5L,
"UserID",
aces_daily)
## use different control to fit model and now converges
strictControl <- lme4::lmerControl(optCtrl = list(
algorithm = "NLOPT_LN_NELDERMEAD",
xtol_abs = 1e-10,
ftol_abs = 1e-10))
evaluateLags(
"NegAff ~ Female + Age + BornAUS + (1 + STRESS | UserID)",
"STRESS",
5L,
"UserID",
aces_daily,
control = strictControl)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.