Generate Standardized Data

Creates simulated data from structural equation models with standardized loading.


CRANstatus Rdoc develVersion lifecycle Travis buildstatus AppVeyor buildstatus Coveragestatus

Sometimes you have a structural model with standardized path coefficients, structural coefficients, and correlations, but you do not know the error and disturbance variances. The purpose of simstandard is to calculate these variances and then simulate multivariate normal data based on your model.

Installation

You can either install simstandard from CRAN or install the development version of simstandard from github.

Option 1: Install the most recent stable release from CRAN

You can install simstandard from CRAN by running this code:

install.packages("simstandard")

Option 2: Install the development version from GitHub

To install the development version of simstandard, you need to check if devtools is installed. If not, run this:

install.packages("devtools")

Once you are sure you have devtools installed, you can install the development version of simstandard from GitHub by running this code:

devtools::install_github("wjschne/simstandard")

Example

The simstandard package uses lavaan syntax to specify models.

library(simstandard)
model <- "
A =~ 0.5 * A1 + 0.8 * A2
B =~ 0.6 * B1 + 0.7 * B2
B ~ 0.8 * A
C ~~ 0.5 * A
"
data <- sim_standardized(m = model, n = 500)
 
knitr::kable(head(data), digits = 2)
A1 A2 B1 B2 C A B e_A1 e_A2 e_B1 e_B2 d_B
-1.22 0.58 1.08 1.43 0.48 -0.49 0.12 -0.97 0.97 1.00 1.35 0.51
-0.53 0.52 0.66 0.40 -0.76 1.77 0.41 -1.41 -0.90 0.41 0.11 -1.00
-0.08 0.35 1.21 2.25 0.27 0.44 0.65 -0.30 0.00 0.82 1.80 0.30
1.23 0.06 -2.34 -1.45 0.16 0.39 -0.63 1.04 -0.26 -1.96 -1.00 -0.95
-0.38 -0.86 -0.66 -2.23 -0.96 -1.69 -1.48 0.47 0.50 0.23 -1.19 -0.12
0.63 0.55 -0.65 -0.56 -0.02 0.22 -0.12 0.51 0.38 -0.58 -0.47 -0.30

See more in the tutorial for this package.

News

simstandard 0.3.0

  • Added the matrix2lavaan function to provide a convenient method of creating lavaan syntax from matrices.
  • Added the lav2ram function to extract standardized RAM matrices from a lavaan object.
  • The sim_standardized_matrices function has a new argument, composite_threshold. If this argument is specified, variables with loadings below the threshold are not used as indicators of the composite scores.
  • Removed the semPlot package from suggests list

simstandard 0.2.1

  • Fixed the method of finding indicators for composite variables. A composite now is only created from direct indicators unless the latent variable is a higher-order factor with no direct indicators.

simstandard 0.2.0

  • Added the fixed2free function, which takes a lavaan syntax model with fixed parameters and returns a lavaan syntax model in which all parameters are free.
  • Added the model_complete function, which takes a lavaan syntax model with standardized loadings, structure coefficients, and covariances, and returns a lavaan syntax model with all standardized coefficients, including standardized variances.
  • Added the add_factor_scores function, which adds predicted factor scores to a data.frame.

simstandard 0.1.0

  • Initial release

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("simstandard")

0.3.0 by W. Joel Schneider, 3 months ago


https://github.com/wjschne/simstandard


Report a bug at https://github.com/wjschne/simstandard/issues


Browse source code at https://github.com/cran/simstandard


Authors: W. Joel Schneider [aut, cre]


Documentation:   PDF Manual  


CC0 license


Imports lavaan, mvtnorm, tibble, stats, magrittr, rlang, purrr

Suggests knitr, rmarkdown, ggplot2, dplyr, tidyr, forcats, kableExtra, stringr, testthat, covr, badger


See at CRAN