Learn R Programming

semhelpinghands (version 0.1.10)

annotate_matrices: Annotate the Matrices of a 'lavaan' Model

Description

Label the elements of the model matrices in a lavaan model.

Usage

annotate_matrices(fit)

# S3 method for annotate_matrices print(x, ...)

Value

annotate_matrices()

returns an annotate_matrices-class object, which is a list of model matrices, with elements annotated:

  • If a parameter is free, then it is represented by "lhs-op-rhs" according to the parameter estimate data frame.

  • If a parameter is fixed but appears in the parameter table, it is represented by "(lhs-op-rhs = x)" , x the value it is fixed to.

  • If a parameter is fixed to zero but not in the parameter table, then it is represented by 0.

The print-method return the input, x. It was called for its side-effect.

Arguments

fit

The output of lavaan::lavaan() or its wrappers, such as lavaan::cfa() and lavaan::sem().

x

A 'annotate_matrices'-class object. The output of annotate_matrices().

...

Optional arguments. To be passed to the default print method.

Methods (by generic)

  • print(annotate_matrices): The print method of the output of annotate_matrices()

Details

This function annotates the model matrices in a lavaan object. This function is not to be used in analysis. It is a learning tool, for learners to understand the relation between the model matrices and the model parameters.

It currently supports a single-level single-group model only.

Examples

Run this code

# Adapted from https://lavaan.ugent.be/tutorial/cfa.html

library(lavaan)
HS.model <- '
visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9
'
fit_cfa <- cfa(HS.model,
               data = HolzingerSwineford1939)
annotate_matrices(fit_cfa)

Run the code above in your browser using DataLab