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 based on factor analysis or item response models with different response formats (continuous or categorical), loading patterns and residual covariance (local dependence) structures.

Usage

sim_lvm(
  N = 1000,
  mla = NULL,
  K = 3,
  J = 18,
  cpf = 0,
  lam = 0.7,
  lac = 0.3,
  phi = 0.3,
  ph12 = -1,
  ecr = 0,
  P = 0,
  b = 0.3,
  K1 = 0,
  ph1 = 0.2,
  b1 = 0.3,
  ilvl = NULL,
  cati = NULL,
  noc = c(4),
  misp = 0,
  ome_out = FALSE,
  necw = K,
  necb = K,
  add_ind = c(),
  add_la = 0.5,
  add_phi = 0,
  zero_it = 0,
  rseed = 333,
  digits = 4
)

Arguments

N

Sample size.

mla

Population loading matrix.

K

Number of factors (if mla=NULL).

J

Number of items (if mla=NULL).

cpf

Number of cross-loadings per factor (if mla=NULL).

lam

Number of formal iterations for posterior sampling.

lac

Number of iterations to update the sampling information.

phi

Homogeneous correlations between any two factors.

ph12

Correlation between factor 1 and 2 (if it's different from phi.

ecr

Residual correlation (local dependence).

P

Number of observable predictors (for MIMIC model).

b

Coefficients of observable predictors (for MIMIC model).

K1

Number of latent predictors (for MIMIC model).

ph1

Correlations between latent predictors (for MIMIC model).

b1

Coefficients of latent predictors (for MIMIC model).

ilvl

Specified levels of all items (i.e., need to specify Item 1 to J+P); 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.

ome_out

Output factor score or not.

necw

Number of within-factor local dependence.

necb

Number of between-factor local dependence.

add_ind

(Additional) minor factor with cross-loadings.

add_la

Value of cross-loadings on (Additional) minor factor.

add_phi

Correlations between (Additional) minor factor and other factors.

zero_it

Surplus items with zero loading.

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, loading, and factorial correlation matrix.

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$MLA
out$ofd_ind

# 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$MLA
out$ofd_ind


LAWBL documentation built on May 16, 2022, 9:06 a.m.