Learn R Programming

simsem (version 0.4-6)

bind: Specify matrices for Monte Carlo simulation of structural equation models

Description

Create SimMatrix or SimVector object that specifies
  1. Pattern of fixed/freed parameters for analysis
Population parameter values for data generation Any model misspecification (true population parameter is different than the one specified) for these parameters.

Usage

bind(free = NULL, popParam = NULL, misspec = NULL, symmetric = FALSE)
binds(free = NULL, popParam = NULL, misspec = NULL, symmetric = TRUE)

Arguments

free
Required matrix or vector where each element represents a fixed or freed parameter used for analysis with structural equation models. Parameters can be freed by setting the corresponding element in the matrix to NA, and can be fixed by settin
popParam
Optional matrix or vector of identical dimension to the free matrix whose elements contain population parameter values for data generation in simulation. For simlutation, each free parameter requires a population parameter value, which is a quoted numeric
misspec
Optional matrix or vector of identical dimension to the free matrix whose elements contain population parameter values for specifying misspecification. Elements of the misspec matrix contain population parameters that are added to parameters that are fixe
symmetric
Set as TRUE if the matrix created is symmetric (RPS/PS, RTE/TE). The function binds can also be used, which defaults to symmetric = TRUE

Value

  • SimMatrix or SimVector object that used for model specification for analysis and data generation in simsem.

code

model

Details

Bind is the first step in the bind -> model -> sim workflow of simsem, and this document outlines the user interface or language used to describe these simulations. This interface, while complex, enables a wide array of simulation specifications for structural equation models by building on LISREL-style parameter specifications. In simulations supported by simsem, a given parameter may be either fixed or freed for analysis, but may optionally also have a population value or distribution for data generation, or a value or distribution of misspecification. The purpose of bind is to stack these multiple meanings of a parameter into an object recognized by simsem, a SimMatrix. Each matrix in the Lisrel notation (e.g. LY, PS, TE, BE) becomes a SimMatrix, and is passed to the function model, which builds the data generation template and an analysis template (a lavaan parameter table), collectively forming a SimSem object, which can be passed to the function sim for simulation.

See Also

  • modelTo combine simMatrix objects into a complete data analysis and data generation template, which is aSimSemobject
generate To generate data using the simsem template. analyze To analyze real or generated data using the simsem template. loading <- matrix(0, 6, 2) loading[1:3, 1] <- NA loading[4:6, 2] <- NA loadingValues <- matrix(0, 6, 2) loadingValues[1:3, 1] <- 0.7 loadingValues[4:6, 2] <- 0.7 LY <- bind(loading, loadingValues) summary(LY) # Set both factor correlations to .05 latent.cor <- matrix(NA, 2, 2) diag(latent.cor) <- 1 RPS <- binds(latent.cor, 0.5) # Misspecify all error covarainces error.cor <- matrix(0, 6, 6) diag(error.cor) <- NA RTE <- binds(error.cor,1,"runif(1,-.05,.05)")