This function simulate data from univariate latent change score model parameter estimates using simulateData.

sim_uni_lcsm(
  timepoints,
  model,
  model_param = NULL,
  var = "x",
  change_letter = "g",
  sample.nobs = 500,
  na_pct = 0,
  ...,
  return_lavaan_syntax = FALSE
)

Arguments

timepoints

See specify_uni_lcsm

model

See specify_uni_lcsm

model_param

List, specifying parameter estimates for the LCSM that has been specified in the argument 'model'

  • gamma_lx1: Mean of latent true scores x (Intercept),

  • sigma2_lx1: Variance of latent true scores x,

  • sigma2_ux: Variance of observed scores x,

  • alpha_g2: Mean of change factor (g2),

  • alpha_g3: Mean of change factor (g3),

  • sigma2_g2: Variance of constant change factor (g2).

  • sigma2_g3: Variance of constant change factor (g3),

  • sigma_g2lx1: Covariance of constant change factor (g2) with the initial true score x (lx1),

  • sigma_g3lx1: Covariance of constant change factor (g3) with the initial true score x (lx1),

  • sigma_g2g3: Covariance of change factors (g2 and g2),

  • phi_x: Autoregression of change scores x.

var

See specify_uni_lcsm

change_letter

See specify_uni_lcsm

sample.nobs

Numeric, number of cases to be simulated, see specify_uni_lcsm

na_pct

Numeric, percentage of random missing values in the simulated dataset [0,1]

...

Arguments to be passed on to simulateData

return_lavaan_syntax

Logical, if TRUE return the lavaan syntax used for simulating data. To make it look beautiful use the function cat.

Value

tibble

Examples

# Simulate data from univariate LCSM parameters sim_uni_lcsm(timepoints = 10, model = list(alpha_constant = TRUE, beta = FALSE, phi = TRUE), model_param = list(gamma_lx1 = 21, sigma2_lx1 = 1.5, sigma2_ux = .2, alpha_g2 = -.93, sigma2_g2 = .1, sigma_g2lx1 = .2, phi_x = .2), return_lavaan_syntax = FALSE, sample.nobs = 1000, na_pct = .3)
#> Parameter estimates for the data simulation are taken from the argument 'model_param'.
#> All parameter estimates for the LCSM have been specified in the argument 'model_param'.
#> # A tibble: 1,000 × 11 #> id x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 #> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1 23.0 NA 22.3 NA 20.1 NA NA 17.9 16.4 15.5 #> 2 2 22.2 21.1 NA 17.3 16.4 13.9 13.9 11.9 9.84 8.44 #> 3 3 21.8 21.1 19.0 17.0 16.9 14.7 13.2 NA 11.4 10.9 #> 4 4 21.0 20.4 20.7 NA 18.4 17.8 16.6 NA NA NA #> 5 5 21.9 21.8 NA 19.6 NA 17.8 16.4 15.6 14.5 13.2 #> 6 6 23.6 NA 22.3 NA 19.2 18.2 18.0 16.7 NA 13.8 #> 7 7 19.4 18.4 16.7 NA 14.7 13.6 12.3 10.2 9.59 8.21 #> 8 8 19.4 NA NA NA 16.1 13.4 13.5 13.1 12.3 11.4 #> 9 9 22.4 21.3 20.4 20.8 19.5 18.2 17.0 NA 15.7 NA #> 10 10 NA NA 19.6 19.1 18.6 17.9 16.1 NA 16.5 NA #> # … with 990 more rows