simstandard v0.3.0

0

Monthly downloads

0th

Percentile

Generate Standardized Data

Creates simulated data from structural equation models with standardized loading.

Readme

simstandard

CRAN
status Rdoc develVersion lifecycle Travis build
status AppVeyor build
status Coverage
status

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.

Functions in simstandard

Name Description
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
No Results!

Vignettes of simstandard

Name
ModelFigure.pdf
ModelFigure.svg
ModelFigure.tex
ModelFigureComplete.pdf
ModelFigureComplete.svg
ModelFigureComplete.tex
VignetteStyle.css
logo.png
simstandard_tutorial.Rmd
No Results!

Last month downloads

Details

License CC0
Encoding UTF-8
LazyData true
RoxygenNote 6.1.1
VignetteBuilder knitr
URL https://github.com/wjschne/simstandard
BugReports https://github.com/wjschne/simstandard/issues
NeedsCompilation no
Packaged 2019-01-05 06:55:10 UTC; renee
Repository CRAN
Date/Publication 2019-01-07 19:50:03 UTC

Include our badge in your README

[![Rdoc](http://www.rdocumentation.org/badges/version/simstandard)](http://www.rdocumentation.org/packages/simstandard)