sim: Simulate data for rosetta

Description Usage Arguments Value Examples

View source: R/sim.r

Description

This function simulates 'complete' and 'missing' datasets. For each independent dataset, one variable per domain will be set to missing.

Usage

1
2
3
4
5
sim(loading = matrix(c(0.9, 0.8, 0.7, rep(0, 9), 0.6, 0.7, 0.8, rep(0,
  9), 0.8, 0.9, 0.6), ncol = 3), correlation = matrix(c(1, 0.2, 0.4, 0.2,
  1, 0.3, 0.4, 0.3, 1), ncol = 3), factor_structure = list(a = c(1, 2,
  3), b = c(1, 2, 3), c = c(1, 2, 3)), n_rows = 1000, n_datasets = 3,
  seed = NULL)

Arguments

loading

The measurement model for x. The 'fx' argument as found in psych::sim.structure.

correlation

The structure matrix of the latent variables. The 'Phi' argument as found in psych::sim.structure.

factor_structure

A named list. The list names are the factor names. Each element is a character vector of feature names for the corresponding factor. Should be ordered corresponding to the rows of the 'loading' argument.

n_rows

An integer for the number of rows for each independent dataset.

n_datasets

An integer for the number of independent datasets.

seed

An integer for the seed.

Value

Returns a list that contains the complete data and missing data.

Examples

1
2
3
4
5
6
7
8
#----------------------------------------------------------------------------
# Data simulation example
#----------------------------------------------------------------------------
# By default, sim() will simulate 3 variables from 3 different domains.
d_sim <- sim()
str(d_sim)
complete_data <- d_sim$complete
missing_data <- d_sim$missing

bklamer/rosetta documentation built on Nov. 4, 2019, 7:31 a.m.