annotate_matrices: Annotate the Matrices of a 'lavaan' Model

View source: R/annotate_model.R

annotate_matricesR Documentation

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 class 'annotate_matrices'
print(x, ...)

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.

Details

This function annotates the model matrices in a 'lavaan'-class 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.

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.

Methods (by generic)

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

Author(s)

Shu Fai Cheung https://orcid.org/0000-0002-9871-9448

Examples


# 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)


sfcheung/semhelpinghands documentation built on Nov. 5, 2024, 7:05 p.m.