mlts_sim {mlts} | R Documentation |
Simulate data from mlts model
Description
Simulate data from mlts model
Usage
mlts_sim(
model,
default = FALSE,
N,
TP,
burn.in = 50,
seed = NULL,
seed.true = 1,
btw.var.sds = NULL
)
Arguments
model |
|
default |
logical. If set to |
N |
integer Number of observational units. |
TP |
integer. Number of measurements per observational unit. |
burn.in |
integer. Length of ‘burn-in’ period. |
seed |
integer. Seed used for data generation. |
seed.true |
integer. Separate seed used for sampling of true population parameters values from plausible ranges for stationary time series. |
btw.var.sds |
named numeric vector. Provide standard deviation(s) for all exogenous
between-level variable(s) specified in |
Details
A function to generate data from an output of mlts_model
.
Value
An object of class "mlts_simdata"
.
The object is a list containing the following components:
model |
the model object passed to |
data |
a long format |
RE.pars |
a |
Examples
# build a simple vector-autoregressive mlts model with two time-series variables
var_model <- mlts_model(q = 2)
# simulate data from this model with default true values
# (true values are randomly drawn from normal distribution)
var_data <- mlts_sim(
model = var_model,
N = 50, TP = 30, # number of units and number of measurements per unit
default = TRUE # use default parameter values
)
# the data set is stored in .$data
head(var_data$data)
# individual parameter values are stored in .$RE.pars
head(var_data$RE.pars)
# if the mltssim-object is used in mlts_fit(), true values
# are added to the fitted object
fit <- mlts_fit(
model = var_model,
data = var_data,
id = "ID", ts = c("Y1", "Y2"), time = "time"
)
# inspect model with true values
head(fit$pop.pars.summary)