generate_data: Generate one dataset following the Bakk & Kuha (2018)...

View source: R/dgp.R

generate_dataR Documentation

Generate one dataset following the Bakk & Kuha (2018) simulation design

Description

Generate one dataset following the Bakk & Kuha (2018) simulation design

Usage

generate_data(
  n,
  separation = c("low", "mid", "high"),
  scenario = c("covariate", "distal"),
  params = bk2018_params,
  seed = NULL
)

Arguments

n

Integer. Sample size (paper uses 500, 1000, or 2000).

separation

Character. One of "low", "mid", "high". Maps to pi = 0.70, 0.80, 0.90 respectively.

scenario

Character. One of:

"covariate"

Zp (discrete, 1-5) predicts latent X with multinomial logit.

"distal"

Latent X predicts continuous Zo with linear regression.

params

List of population parameters. Defaults to bk2018_params.

seed

Integer or NULL. Optional random seed for reproducibility.

Value

A data.frame with columns:

Y1 .. Y6

Binary indicators (always present).

X

True latent class, integer 1-3 (not observed in practice).

Zp

Integer covariate 1-5 (scenario "covariate" only).

Zo

Continuous distal outcome (scenario "distal" only).

Examples

# Covariate scenario with high separation
d <- generate_data(n = 200, separation = "high", scenario = "covariate",
                   seed = 1)
head(d)
colMeans(d)

# Distal outcome scenario
d2 <- generate_data(n = 200, separation = "high", scenario = "distal",
                    seed = 2)
head(d2)

tseLCA documentation built on Nov. 11, 2026, 9:07 a.m.