Learn R Programming

lavaan (version 0.7-2)

lav_model_plotinfo: Get model information

Description

Extracts the information from a model that is needed to produce a plot.

Usage

lav_model_plotinfo(model = NULL, infile = NULL, varlv = FALSE)

Value

A structure 'plotinfo', which is a list with members nodes and edges. These are data.frames containing the data needed to create a diagram.

  1. nodes

    id

    character, identification of the node consisting of blok and naam.

    naam

    character, name of the node as specified in the model. For intercepts the name is "1vanXXXX", with XXXX the name of the regressed variable.

    tiepe

    character, type of node: ov (observed variable), lv (latent variable), varlv (variance as latent variable), cv (composite variable), wov (within level variable in multilevel model), bov (between level variable in multilevel model), const (intercept of regression).

    blok

    integer, level (0 if not a multilevel model).

  2. edges

    id

    integer, autoincrement identification of the edge.

    label

    character, label for the edge, made from the label specified in the model and the fixed (or estimated) value if present.

    van

    character, id of the starting node.

    naar

    character, id of the destination node.

    tiepe

    character, lavaan operator, with two exceptions: a (residual) variance is coded here as '~~~', and a regression introduced by varlv = TRUE is coded as '~.'.

Arguments

model

A character vector specifying the model in lavaan syntax or a list (or data.frame) with at least members lhs, op, rhs, label and fixed or a fitted lavaan object (in which case the ParTable object is extracted and column est is used as value to show). Should be NULL if infile is given.

infile

A character string specifying the file that contains the model syntax.

varlv

A logical indicating that the (residual) variance of a variable should be plotted as a separate latent variable (with a smaller circle than ordinary latent variables). In this case, a covariance between two such variables is plotted as a covariance between their variance latent variables.

Examples

Run this code
model <- 'alpha  =~ 1 * x1 + x2 + x3        # latent variable
          beta <~ x4 + x5 + x6              # composite
          gamma =~ 1 * x7 + x8 + x9         # latent variable
          Xi =~ 1 * x10 + x11 + x12 + x13   # latent variable
          # regressions
          Xi ~ v * alpha + t * beta + cc * 1
          alpha ~ tt * beta + ss * gamma + yy * Theta1
          # variances and covariances
          x2 ~~ cc25 * x5
          x3 ~~ cc36 * x6
          x3 ~~ cc34 * x4
          gamma ~~ 0.55 * gamma
          '
(test <- lav_model_plotinfo(model))

Run the code above in your browser using DataLab