mlts_fit {mlts} | R Documentation |
Fit Bayesian Multilevel Manifest or Latent Time-Series Models
Description
Fit Bayesian Multilevel Manifest or Latent Time-Series Models
Usage
mlts_fit(
model,
data = NULL,
id,
ts,
covariates = NULL,
outcomes = NULL,
outcome_pred_btw = NULL,
center_covs = TRUE,
time = NULL,
tinterval = NULL,
beep = NULL,
days = NULL,
n_overnight_NAs,
na.rm = FALSE,
iter = 500,
chains = 2,
cores = 2,
monitor_person_pars = FALSE,
get_SD_latent = FALSE,
fit_model = TRUE,
print_message = TRUE,
print_warning = TRUE,
...
)
Arguments
model |
|
data |
An object of class |
id |
Character. The variable in |
ts |
Character. The variable(s) in |
covariates |
Named character vector. An optional named vector of
characters to refer to predictors of random effects as specified in the |
outcomes |
Named character vector. Similar to |
outcome_pred_btw |
Named character vector. Similar to |
center_covs |
Logical. Between-level covariates used as predictors of random effects
will be grand-mean centered before model fitting by default. Set |
time |
Character. The variable in |
tinterval |
The step interval for approximating equally spaced observations in time by insertion of missing values, to be specified with respect to the time stamp variable provided in time. Procedure for inserting missing values resembles the procedure for time shift transformation as described in Asparouhov, Hamaker, & Muthén (2018). |
beep |
Character. The variable in |
days |
Optional. If a running beep identifier is provided via the |
n_overnight_NAs |
Optional. The number of |
na.rm |
logical. Per default, missing values remain in the data and
will be imputed during model estimation. Set to |
iter |
A positive integer specifying the number of iterations for each chain (including 50% used as warmup). The default is 500. |
chains |
A positive integer specifying the number of Markov chains. The default is 2. |
cores |
The number of cores to use when executing the Markov chains in parallel.
The default is 2 (see |
monitor_person_pars |
Logical. Should person parameters (i.e., values of the latent variables) be stored? Default is FALSE. |
get_SD_latent |
Logical. Set to |
fit_model |
Logical. Set to FALSE to avoid fitting the model which may be helpful to inspect prepared data used for model estimation (default = TRUE). |
print_message |
Logical. Print messages based on defined inputs (default = TRUE). |
print_warning |
Logical. Print warnings based on defined inputs (default = TRUE). |
... |
Additional arguments passed to |
Value
An object of class mltsfit
.
The object is a list containing the following components:
model |
the model object passed to |
data |
the preprocessed data used for fitting the model |
param.labels |
a |
pop.pars.summary |
a |
person.pars.summary |
if |
standata |
a |
stanfit |
an object of class |
posteriors |
an |
References
Asparouhov, T., Hamaker, E. L., & Muthén, B. (2018). Dynamic Structural Equation Models. Structural Equation Modeling: A Multidisciplinary Journal, 25(3), 359–388. doi:10.1080/10705511.2017.1406803
Examples
# build simple vector-autoregressive mlts model for two time-series variables
var_model <- mlts_model(q = 2)
# fit model with (artificial) dataset ts_data
fit <- mlts_fit(
model = var_model,
data = ts_data,
ts = c("Y1", "Y2"), # time-series variables
id = "ID", # cluster identifier variable
time = "time", # time variable
tinterval = 1 # interval for approximation of equidistant measurements,
)
# inspect model summary
summary(fit)