Learn R Programming

⚠️There's a newer version (0.6.3) of this package.Take me there.

simstandard

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)
A1A2B1B2CABe_A1e_A2e_B1e_B2d_B
-1.220.581.081.430.48-0.490.12-0.970.971.001.350.51
-0.530.520.660.40-0.761.770.41-1.41-0.900.410.11-1.00
-0.080.351.212.250.270.440.65-0.300.000.821.800.30
1.230.06-2.34-1.450.160.39-0.631.04-0.26-1.96-1.00-0.95
-0.38-0.86-0.66-2.23-0.96-1.69-1.480.470.500.23-1.19-0.12
0.630.55-0.65-0.56-0.020.22-0.120.510.38-0.58-0.47-0.30

See more in the tutorial for this package.

Copy Link

Version

Install

install.packages('simstandard')

Monthly Downloads

389

Version

0.3.0

License

CC0

Issues

Pull Requests

Stars

Forks

Maintainer

W. Joel Schneider

Last Published

January 7th, 2019

Functions in simstandard (0.3.0)

add_factor_scores

Add factor scores to observed data
sim_standardized_matrices

Return model characteristics
%>%

Pipe operator
sim_standardized

Generates simulated data with standardized parameters.
matrix2lavaan

Create lavaan model syntax from matrix coefficients
model_complete

Function that takes a lavaan model with standardized paths and loadings and returns a complete lavaan model syntax with standardized variances
fixed2free

Remove fixed parameters from a lavaan model
lav2ram

Extract standardized RAM matrices from lavaan object
check_matrix2lavaan

Checks matrices for matrix2lavaan function