rIG: Simulation of non-normal data

View source: R/IG.R

rIGR Documentation

Simulation of non-normal data

Description

Backward-compatible wrapper that combines calibrate_ig and simulate in one call. New code should prefer the calibrate/simulate split so calibration can be reused.

Usage

rIG(N, sigma.target, skewness, excesskurtosis, reps = 1, typeA = "triang")

Arguments

N

Number of observations to simulate.

sigma.target

Target population covariance matrix.

skewness

Target skewness vector.

excesskurtosis

Target excess kurtosis vector.

reps

Number of simulated samples.

typeA

Either "triang" (default, triangular Cholesky factor) or "symm" (symmetric square root).

Value

A list of simulated samples.

Author(s)

Njål Foldnes (njal.foldnes@gmail.com)

References

Foldnes, N. and Olson, U. H. (2016). A simple simulation technique for nonnormal data with prespecified skewness, kurtosis, and covariance matrix. Multivariate behavioral research, 51(2-3), 207-219

Examples

set.seed(1234)
model <- '
 # measurement model
   ind60 =~ x1 + x2 + x3
   dem60 =~ y1 + y2 + y3 + y4
   dem65 =~ y5 + y6 + y7 + y8
 # regressions
   dem60 ~ ind60
   dem65 ~ ind60 + dem60
 # residual correlations
   y1 ~~ y5
   y2 ~~ y4 + y6
   y3 ~~ y7
   y4 ~~ y8
   y6 ~~ y8'
fit  <- lavaan::sem(model, data=lavaan::PoliticalDemocracy)
population.sigma <- lavaan::lavInspect(fit, "sigma.hat")
population.skew  <- c(0, 0, 0, 0, 1, 1, 1, 1, 2,2,2 )
population.excesskurt <- c( 1 , 1, 1, 1, 3, 3, 3, 3, 15, 15, 15)
my.samples <- rIG(N=10^3, sigma=population.sigma,
        skewness=population.skew,
        excesskurt=population.excesskurt,
        reps=5)

covsim documentation built on Oct. 29, 2026, 5:06 p.m.