This function generates observed sample data from a specified factor model. It supports continuous or categorical indicators, missingness, correlated latent factors, optional cross-loadings, local dependence, and structured residual covariance. The function can simulate: - Standard CFA models - Bifactor models - MTMM models - Models with cross-loading perturbations - Models with local residual correlations - Categorical response data - Missing data mechanisms
sim_data(
N = 1000,
lam,
phi = 0.3,
ecm = NULL,
ecr = 0,
necw = 0,
necb = 0,
fixloading = 0,
Kg = 0,
std = T,
cati = NULL,
noc = c(4),
misp = 0,
fac_score = FALSE,
rseed = 333,
digits = 4
)Integer. Sample size.
Matrix. True loading
Numeric/Matrix. Correlation among latent factors.
Matrix. Residual covariance matrix. If NULL, generated internally.
Numeric. Residual correlation strength.
Integer. Number of residual covariance elements within blocks.
Integer. Number of residual covariance elements between blocks.
Logical or numeric indicator for identification constraints.
Integer. Number of general factors (0 corresponds to simple CFA).
Logical. Whether to standardize latent variables.
Numeric vector. The set of polytomous items in sequence number (i.e., can be any number set
in between 1 and J); NULL for no and -1 for all .
Numeric vector. Number of levels for polytomous items. (if categorical).
Numeric. Proportion of missingness..
Logical. Whether to return true latent factor scores.
Integer. Random seed for reproducibility.
Integer. Rounding precision of output.
A list containing:
Loading matrix used for data generation.
Latent factor correlation matrix.
common variance contributed by each factor.
Empirical item standard deviations.
residual (unique) variance proportion.
True latent factor scores (returned if fac_score = TRUE).
Simulated observed data matrix.
Identification constraint indicator for fixed loadings.
Logical flag indicating whether latent variables were standardized.
Data are generated according to the factor model:
X = Lambda F + epsilon