modelMatrices: Extract SEM model matrices

View source: R/modelMatrices.R

modelMatricesR Documentation

Extract SEM model matrices

Description

Create a "semMatriModel" object. Use semMatrixAlgebra to extract or compute with these models. The structure of "semMatriModel" objects is chosen such that they can be used to create a semPlotModel-class object using do.call in combination with ramModel, lisrelModel or mplusModel (not yet implemented). See details.

Usage

modelMatrices(object, model = "ram", endoOnly = FALSE)

Arguments

object

A "semPlotModel" object or any of the input types that can be used in semPlotModel directly.

model

Model to be used, "mplus", "ram" or "lisrel"

endoOnly

Only needed when the model is "lisrel", sets all variables to endogenous.

Details

The "lisrel" model uses the following matrix names: LY, TE, PS, BE, LX, TD, PH, GA, TY, TX, AL and KA. Regressions on manifest variables will cause dummy latents to be included in the model.

The "mplus" model uses the following matrix names: Lambda, Nu, Theta, Kappa, Alpha, Beta, Gamma and Psi.

The "ram" model uses the following matrix names: F, A and S.

Value

a "semMatriModel" object

Author(s)

Sacha Epskamp <mail@sachaepskamp.com>

See Also

semPlotModel semPlotModel-class semMatrixAlgebra lisrelModel ramModel

Examples

## Mplus user guide SEM example:
outfile <- tempfile(fileext=".out")
tryres <- try({
  download.file("http://www.statmodel.com/usersguide/chap5/ex5.11.html",outfile)
})

if (!is(tryres,"try-error")){
  # Plot model:
  semPaths(outfile, intercepts = FALSE)

  # Extract RAM:
  RAM <- modelMatrices(outfile, "ram")
  semPaths(do.call(ramModel, RAM), as.expression = "edges", intercepts = FALSE)

  # Extract LISREL:
  LISREL <- modelMatrices(outfile, "lisrel")
  semPaths(do.call(lisrelModel, LISREL), as.expression = "edges", intercepts = FALSE)
}

semPlot documentation built on Aug. 10, 2022, 9:06 a.m.