lav2nlsem {nlsem}R Documentation

Create a structural equation model from lavaan syntax

Description

Create model matrices from a string specifying a structural equation model in lavaan syntax.

Usage

  lav2nlsem(model, constraints=c("indirect", "direct1", "direct2"),
            class.spec="class")

Arguments

model

A description of the user-specified model. The model is described using the lavaan model syntax. See Details in ?model.syntax in lavaan for more information.

constraints

which should be set for a model with more than one latent class. See Details in ?specify_sem.

class.spec

String used to specify latent classes. Can be any string e.g. ‘class’, ‘mixture’, etc. Default is ‘class’.

Details

nlsem can only fit a certain group of models and it is only feasible to specify models in the lavaan syntax that can be fitted with nlsem; that means models with latent variables and latent interactions only.

Parameter restrictions in lavaan style can be used to some extent; meaning parameters can be fixed to a certain value with 1*x1. Equality restrictions are handled via the constraints argument and will be ignored in the lavaan syntax.

Value

Gives back an object of class singleClass, semm, or nsemm which can be fitted using em.

References

Rosseel, Y. (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1 - 36. doi:http://dx.doi.org/10.18637/jss.v048.i02

See Also

specify_sem, create_sem

Examples

# create model with three latent classes
lav.model <- '
          class: 1
          eta =~ y1 + y2 + y3 + y4
          xi1 =~ x1 + x2 + x3 + x4 + x5
          xi2 =~ x6 + x7 + x8 + x9 + x10 + x11

          eta ~ xi1 + xi2 + xi1:xi1

          class: 2
          eta =~ y1 + y2 + y3 + y4
          xi1 =~ x1 + x2 + x3 + x4 + x5
          xi2 =~ x6 + x7 + x8 + x9 + x10 + x11

          eta ~ xi1 + xi2 + xi1:xi2 + xi1:xi1

          class: 3
          eta =~ y1 + y2 + y3 + y4
          xi1 =~ x1 + x2 + x3 + x4 + x5
          xi2 =~ x6 + x7 + x8 + x9 + x10 + x11

          eta ~ xi1 + xi2 + xi1:xi2'

model <- lav2nlsem(lav.model, constraints = "direct1", class.spec = "class")

[Package nlsem version 0.8-1 Index]