sim_lvm: Simulating data with Latent Variable Modeling

View source: R/sim_lvm.R

sim_lvmR Documentation

Simulating data with Latent Variable Modeling

Description

sim_lvm can simulate data with continuous latent variables (factors) and continuous or categorical observed variables, plus a MIMIC-type structure. One can also include an error covariance (local dependence) structure. Categorical observed variables are generated with latent continuous responses normally distributed and equally spaced within [-3,3].

Usage

sim_lvm(
  N = 1000,
  lam = 0.7,
  K = 3,
  J = 18,
  cpf = 0,
  lac = 0.3,
  phi = 0.3,
  ecr = 0,
  necw = K,
  necb = K,
  P = 0,
  phix = 0,
  b = 0,
  lam1 = 0,
  K1 = 0,
  J1 = 0,
  b1 = 0,
  phi1 = 0,
  ilvl = NULL,
  cati = NULL,
  noc = c(4),
  misp = 0,
  fac_score = FALSE,
  rseed = 333,
  digits = 4
)

Arguments

N

Sample size.

lam

Loading value (for major loadings) or matrix (J \times K).

K

Number of factors (if lam is a value).

J

Number of items (if lam is a value).

cpf

Number of cross-loadings per factor (if lam is a value).

lac

Cross-loading value (if lam is a value).

phi

Factor correlation scalar or matrix, or error correlations (for MIMIC-type model).

ecr

Error covariance (local dependence) value.

necw

Number of within-factor local dependence.

necb

Number of between-factor local dependence.

P

Number of observable predictors (for MIMIC-type model).

phix

Observable predictor correlation value or matrix (for MIMIC-type model).

b

Coefficients of observable predictors (for MIMIC-type model), value or K \times P.

lam1

Loading value (for major loadings) or matrix (J1 \times K1) for latent predictors (for MIMIC-type model).

K1

Number of latent predictors (if lam is a value, for MIMIC-type model).

J1

Number of items latent predictors (if lam is a value, for MIMIC-type model).

b1

Coefficients of latent predictors (for MIMIC-type model), value or K \times K1

phi1

Latent predictor correlation scalar or matrix (for MIMIC-type model).

ilvl

Specified levels of all items (i.e., need to specify Item 1 to J+P+J1); Any value smaller than 2 is considered as continuous item.

cati

The set of polytomous items in sequence number (i.e., can be any number set in between 1 and J+P); NULL for no and -1 for all (if ilvl=NULL).

noc

Number of levels for polytomous items.

misp

Proportion of missingness.

fac_score

Output factor score or not.

rseed

An integer for the random seed.

digits

Number of significant digits to print when printing numeric values.

Value

An object of class list containing the data, loadings, factor correlations, local dependence, and other information. The data consists of J items for the factors, P items for observable predictors, and J1 items for latent predictors.

Examples


# for continuous data with cross-loadings and local dependence effect .3
out <- sim_lvm(N=1000,K=3,J=18,lam = .7, lac=.3,ecr=.3)
summary(out$dat)
out$lam
out$loc_dep

# for categorical data with cross-loadings .4 and 10% missingness
out <- sim_lvm(N=1000,K=3,J=18,lam = .7, lac=.4,cati=-1,noc=4,misp=.1)
summary(out$dat)
out$lam
out$loc_dep


Jinsong-Chen/LAWBL documentation built on Aug. 31, 2022, 10:01 a.m.