Learn R Programming

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

simsem (version 0.2-8)

SIMulated Structural Equation Modeling.

Description

This package can be used to generate data using the structural equation modeling framework. This package is tailored to use those simulated data for various purposes, such as model fit evaluation, power analysis, or missing data handling and planning.

Copy Link

Version

Install

install.packages('simsem')

Monthly Downloads

847

Version

0.2-8

License

GPL (>= 2)

Maintainer

Sunthud Pornprasertmanit

Last Published

July 9th, 2012

Functions in simsem (0.2-8)

countMACS

Count the number of elements in the sufficient statistics
countFreeParameters

Count how many free parameters in the target object
extract

Extract a part of an object
extractOpenMxFit

Extract the fit indices reported by the OpenMx result
extractVectorNames

Extract a vector of parameter names based on specified elements
findIndMean

Find indicator total means from factor loading matrix, total factor mean, and indicator intercept.
findRowZero

Find rows in a matrix that all elements are zero in non-fixed subset rows and columns.
createFreeParameters

Create a free parameters object from a model specification
getCutoff

Find fit indices cutoff given a priori alpha level
getCutoffNested

Find fit indices cutoff for nested model comparison given a priori alpha level
kurtosis

Finding excessive kurtosis
isCorMatrix

Check whether a matrix is a possible correlation matrix
loadingFromAlpha

Find standardized factor loading from coefficient alpha
plotCutoffNested

Plot sampling distributions of the differences in fit indices between nested models with fit indices cutoffs
simData

Create a Data object
popDiscrepancy

Find the discrepancy value between two means and covariance matrices
simGeom

Create random geometric distribution object
simF

Create random F distribution object
simMissing

Construct a SimMissing object to create data with missingness and analyze missing data.
simMisspecCFA

Set of model misspecification for CFA model.
simLnorm

Create random log normal distribution object
simSetPath

Create a set of matrices of parameter and parameter values to generate and analyze data that belongs to Path analysis model
skew

Find skewness
validateObject

Validate whether the drawn parameters are good.
summaryMisspec

Provide summary of model misspecification imposed across replications
writeLavaanIndividualConstraint

Write a lavaan code for a given equality constraint for each parameter
MatrixSet-class

Class "MatrixSet"
SimDataOut-class

Class "SimDataOut"
SimParam-class

Class "SimParam"
constantVector

Create a constant vector object
divideObject

Make a division on each element of the object
extractMatrixNames

Extract a vector of parameter names based on specified rows and columns
expandMatrices

Expand the set of intercept and covariance matrices into the set of intercept/mean and covariance/correlation/variance objects
findFactorTotalVar

Find factor total variances from regression coefficient matrix, factor (residual) correlations, and factor residual variances
createData

Create data from model parameters
getPowerFit

Find power in rejecting alternative models based on fit indices criteria
isNullObject

Check whether the object is the NULL type of that class
isDefault

Check whether a vector object is default
plotQtile

Build a scatterplot with overlaying line of quantiles of predicted values
runMisspec

Draw actual parameters and model misspecification
simExp

Create random exponential distribution object
sortList

Sort two objects in a list
simGamma

Create random gamma distribution object
simNorm

Create random normal distribution object
simPois

Create random Poisson distribution object
symMatrix

Create symmetric simMatrix that save free parameters and starting values, as well as fixed values
writeLavaanNullCode

Write a lavaan code for a null model
standardize

Standardize the parameter estimates within an object
SimModel-class

Class "SimModel"
combineLatentCorExoEndo

Combine exogenous factor correlation and endogenous factor correlation into a single matrix
defaultStartingValues

Make ad hoc starting values
findphist

Find the density (likelihood) of a pair value in 2D Kernel Density Estimate
getPopulation

Extract the data generation population model underlying an object
getKeywords

List of all keywords used in the simsem package
miPool

Function to pool imputed results
printIfNotNull

Provide basic summary of each object if that object is not NULL.
runMI

Multiply impute and analyze data using lavaan
simBinom

Create random binomial distribution object
simT

Create random t distribution object
summaryPopulation

Summarize the data generation population model underlying an object
writeLavaanCode

Write a lavaan code given the matrices of free parameter
SimGenLabels-class

Class "SimGenLabels"
cleanSimResult

Extract only converged replications in the result object
findIndTotalVar

Find indicator total variances from factor loading matrix, total factor covariance, and indicator residual variances.
freeVector

Create a free parameters vector with a starting values in a vector object
isMeanConstraint

Check whether all rownames in a constraint matrix containing symbols of means vectors
plotMisfit

Plot the population misfit in parameter result object
predProb

Function to get predicted probabilities from logistic regression
simSetSEM

Create a set of matrices of parameter and parameter values to generate and analyze data that belongs to SEM model
SimModelOut-class

Class "SimModelOut"
SimFunction-class

Class "SimFunction"
clean

Extract only converged replications in the result objects
drawParametersMisspec

Create parameter sets (with or without model misspecification) from the parameter with or without misspecification set
findTargetPower

Find a value of varying parameters that provides a given value of power.
getPowerFitNested

Find power in rejecting nested models based on the differences in fit indices
likRatioFit

Find the likelihood ratio (or Bayes factor) based on the bivariate distribution of fit indices
pValue

Find p-values (1 - percentile)
pValueCondCutoff

Find a p value when the target is conditional (valid) on a specific value of a predictor
plotCutoff

Plot sampling distributions of fit indices with fit indices cutoffs
plotLogisticFit

Plot multiple logistic curves for predicting whether rejecting a misspecified model
plotCutoffNonNested

Plot sampling distributions of the differences in fit indices between non-nested models with fit indices cutoffs
simEqualCon

Equality Constraint Object
reduceMatrices

Reduce the model constraint to data generation parameterization to analysis model parameterization.
simMatrix

Create simMatrix that save free parameters and starting values, as well as fixed values
simParamCFA

Create a set of matrices of parameters for analyzing data that belongs to CFA model.
toSimSet

Transform the analysis model object into the object for data generation
weightedMean

Calculate the weighted mean of a variable
checkInputValue

Check the value argument in the matrix, symmetric matrix, or vector objects
SimModelMIOut-class

Class "SimModelMIOut"
findFactorResidualVar

Find factor residual variances from regression coefficient matrix, factor (residual) correlations, and total factor variances
findIndIntercept

Find indicator intercepts from factor loading matrix, total factor mean, and indicator mean.
fitMeasuresChi

Find fit indices from the discrepancy values of the target model and null models.
findFactorMean

Find factor total means from regression coefficient matrix and factor intercept
plotOverHist

Plot multiple overlapping histograms
plotPowerFit

Plot sampling distributions of fit indices that visualize power of rejecting datasets underlying misspecified models
isVarianceConstraint

Check whether all rownames in a constraint matrix containing symbols of variance vectors
matchKeywords

Search for the keywords and check whether the specified text match one in the name vector
runFitParam

Build a parameter result object that the data-generation parameters are from the result of analyzing real data
simBeta

Create random beta distribution object
simCauchy

Create random Cauchy distribution object
simDataDist

Create a data distribution object.
simHyper

Create random hypergeometric distribution object
setPopulation

Set the data generation population model underlying an object
simMisspecPath

Set of model misspecification for Path analysis model.
simSetCFA

Create a set of matrices of parameter and parameter values to generate and analyze data that belongs to CFA model.
simVector

Create simVector that save free parameters and starting values, as well as fixed values
subtractObject

Make a subtraction of each element in an object
tagHeaders

Tag names to each element
twoTailedPValue

Find two-tailed p value from one-tailed p value
validateCovariance

Validate whether all elements provides a good covariance matrix
SimREqualCon-class

Class "SimREqualCon"
SimMatrix-class

Matrix object: Random parameters matrix
SimResult-class

Class "SimResult"
blankParameters

Change all elements in the non-null objects to be all NAs.
find2Dhist

Fit the 2D Kernel Density Estimate
SymMatrix-class

Symmetric matrix object: Random parameters symmetric matrix
findPossibleFactorCor

Find the appropriate position for freely estimated correlation (or covariance) given a regression coefficient matrix
findIndResidualVar

Find indicator residual variances from factor loading matrix, total factor covariance, and total indicator variances.
interpolate

Find the value of one vector relative to a value of another vector by interpolation
plotIndividualScatter

Plot an overlaying scatter plot visualizing the power of rejecting misspecified models
runLavaan

Run data by the model object by the lavaan package
startingValues

Find starting values by averaging random numbers
vectorizeObject

Change an object to a vector with labels
SimDataDist-class

Class "SimDataDist"
SimVector-class

Vector object: Random parameters vector
anova

Provide a comparison of nested models and nonnested models across replications
cov2corMod

Convert a covariance matrix to a correlation matrix
createImpliedMACS

Create model implied mean vector and covariance matrix
combineLoadingExoEndo

Combine factor loading from the exogenous and endogenous sides into a single matrix
fillParam

Fill in other objects based on the parameter values of current objects
multipleAllEqual

Test whether all objects are equal
run

Run a particular object in simsem package.
runRep

Run one replication within a big simulation study
summaryShort

Provide short summary of an object.
simMisspecSEM

Set of model misspecification for SEM model.
SimMissing-class

Class "SimMissing"
SimResultParam-class

Class "SimResultParam"
centralMoment

Calculate central moments of a variable
extractLavaanFit

Extract fit indices from the lavaan object
findPower

Find a value of independent variables that provides a given value of power.
getPower

Find power of model parameters
getCutoffNonNested

Find fit indices cutoff for non-nested model comparison given a priori alpha level
imposeMissing

Impose MAR, MCAR, planned missingness, or attrition on a data set
isRandom

Check whether the object contains any random parameters
makeLabels

Make parameter names for each element in matrices or vectors or the name for the whole object
pValueNonNested

Find p-values (1 - percentile) for a non-nested model comparison
plotPower

Make a power plot of a parameter given varying parameters
plotScatter

Plot overlaying scatter plots visualizing the power of rejecting misspecified models
reassignNames

Reassign the name of equality constraint
plotPowerSig

Plot multiple logistic curves given a significance result matrix
simParamPath

Create a set of matrices of parameters for analyzing data that belongs to Path analysis model
simResultParam

The constructor of the parameter result object
summaryFit

Provide summary of model fit across replications
summaryParam

Provide summary of parameter estimates and standard error across replications
ParameterSet

Class "VirtualRSet", "SimLabels" and "SimRSet"
SimEqualCon-class

Class "SimEqualCon"
VirtualDist-class

Distribution Objects
adjust

Change an element in SimMatrix, SymMatrix, or SimVector.
findFactorIntercept

Find factor intercept from regression coefficient matrix and factor total means
findFactorTotalCov

Find factor total covariance from regression coefficient matrix, factor residual covariance
findRecursiveSet

Group variables regarding the position in mediation chain
plot3DQtile

Build a persepctive plot or contour plot of a quantile of predicted values
plotDist

Plot a distribution of a distribution object or data distribution object
pValueNested

Find p-values (1 - percentile) for a nested model comparison
reduceConstraint

Reduce the model constraint to data generation parameterization to analysis model parameterization.
simParamSEM

Create a set of matrices of parameters for analyzing data that belongs to SEM model
simWeibull

Create random Weibull distribution object
toFunction

Export the distribution object to a function command in text that can be evaluated directly.
collapseExo

Collapse all exogenous variables and put all in endogenous side only.
combineObject

Combine by summing or binding two objects together.
combineMeasurementErrorExoEndo

Combine measurement error correlation from the exogenous and endogenous sides into a single matrix
SimMisspec-class

Class "SimMisspec"
getCondQtile

Get a quantile of a variable given values of predictors
continuousPower

Find power of model parameters when simulations have randomly varying parameters
SimData-class

Class "SimData"
combinePathExoEndo

Combine the regression coefficient matrices
constrainMatrices

Impose an equality constraint in an object
kStat

Calculate the k-statistic of a variable
Nullclass

Null Objects
simResult

Create simResult.
miPoolVector

Function to pool imputed results that saved in a matrix format
popMisfitMACS

Find population misfit by sufficient statistics
plotPowerFitDf

Plot sampling distributions of fit indices that visualize power of rejecting datasets underlying misspecified models
plotPowerFitNonNested

Plot power of rejecting a non-nested model based on a difference in fit index
simLogis

Create random logistic distribution object
miPoolChi

Function to pool chi-square statistics from the result from multiple imputation
plotPowerFitNested

Plot power of rejecting a nested model in a nested model comparison by each fit index
simModel

Create a model object
getPowerFitNonNested

Find power in rejecting non-nested models based on the differences in fit indices
SimSet-class

Class "SimSet"
revText

Reverse the proportion value by subtracting it from 1
pValueVariedCutoff

Find a p value when the cutoff is specified as a vector given the values of predictors
simFunction

Create function object
simNbinom

Create random negative binomial distribution object
overlapHist

Plot overlapping histograms
popMisfit

Calculate population misfit
simUnif

Create random uniform distribution object
simChisq

Create random chi-squared distribution object
runFit

Build a Monte Carlo simulation that the data-generation parameters are from the result of analyzing real data
writeLavaanConstraint

Write a lavaan code for a given set of equality constraints
whichMonotonic

Extract a part of a vector that is monotonically increasing or decreasing
validatePath

Validate whether the regression coefficient (or loading) matrix is good
drawParameters

Create parameter sets (with or without model misspecification) from the data object
setOpenMxObject

Rearrange starting values for OpenMx