sim_lvm: Simulating data with Latent Variable Modeling

Description Usage Arguments Value Examples

View source: R/sim_lvm.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
sim_lvm(
  N = 1000,
  K = 3,
  ipf = 8,
  cpf = 2,
  lam = 0.7,
  lac = 0.3,
  phi = 0.5,
  ph1 = -1,
  ecr = 0,
  ome_out = FALSE,
  cati = NULL,
  noc = c(4),
  misp = 0,
  rseed = 333,
  necw = K,
  necb = K,
  add_ind = c(),
  add_la = 0.5,
  add_phi = 0,
  zero_it = 0,
  digits = 4
)

Arguments

N

Sample size.

K

Number of factors.

ipf

Items per factor.

cpf

Cross-loadings per factor.

lam

Number of formal iterations for posterior sampling.

lac

Number of iterations to update the sampling information.

phi

Homogeneous correlations between any two factors.

ph1

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

ecr

Residual correlation (local dependence).

ome_out

Output factor score or not.

cati

The set of categorical (polytomous) items in sequence number (i.e., 1 to J); NULL for no and -1 for all (default is NULL).

noc

Number of categories for categorical items

misp

Proportion of missingness.

rseed

An integer for the random seed.

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.

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# for continuous data with cross-loadings and local dependence effect .3
out <- sim_lvm(N=1000,K=3,ipf=6,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,ipf=6,lam = .7, lac=.4,cati=-1,noc=4,misp=.1)
summary(out$dat)
out$MLA
out$ofd_ind

LAWBL documentation built on April 2, 2021, 1:05 a.m.