simulate_latent_growth_curve {mxsem}R Documentation

simulate_latent_growth_curve

Description

simulate data for a latent growth curve model with five measurement occasions. The time-distance between these occasions differs between subjects.

Usage

simulate_latent_growth_curve(N = 100)

Arguments

N

sample size

Value

data set with columns y1-y5 (observations) and t_1-t_5 (time of observation)

Examples

set.seed(123)
dataset <- simulate_latent_growth_curve(N = 100)

model <- "
  I =~ 1*y1 + 1*y2 + 1*y3 + 1*y4 + 1*y5
  S =~ data.t_1 * y1 + data.t_2 * y2 + data.t_3 * y3 + data.t_4 * y4 + data.t_5 * y5

  I ~ int*1
  S ~ slp*1

  # set intercepts of manifest variables to zero
  y1 ~ 0*1; y2 ~ 0*1; y3 ~ 0*1; y4 ~ 0*1; y5 ~ 0*1;
  "

mod <- mxsem(model = model,
             data = dataset) |>
  mxTryHard()

[Package mxsem version 0.1.0 Index]