Learn R Programming

parameters (version 0.2.0)

model_parameters.lavaan: Format CFA/SEM from the lavaan package

Description

Format CFA/SEM objects from the lavaan package (Rosseel, 2012).

Usage

# S3 method for lavaan
model_parameters(model, ci = 0.95,
  standardize = FALSE, type = c("regression", "correlation",
  "loading"), ...)

Arguments

model

CFA or SEM created by the lavaan::cfa or lavaan::sem functions.

ci

Confidence Interval (CI) level. Default to 0.95 (95%).

standardize

Add standardized parameters. Can be FALSE or a character indicating the standardization method (see parameters_standardize()), such as "refit", "2sd", "smart" or "classic". The two former are based on model refitting using a standardized version of data. It is the most accurate, although computationally heavy (as it must re-fit a second model). The "smart" and "classic" are post-hoc methods, fast, but inaccurate (especially if the model includes interactions).

type

What type of links to return. Can be "all" or some of c("regression", "correlation", "loading", "variance", "mean").

...

Arguments passed to or from other methods.

Value

A data.frame of indices related to the model's parameters.

References

  • Rosseel (2012). lavaan: An R Package for Structural Equation Modeling. Journal of Statistical Software, 48(2), 1-36.

Examples

Run this code
# NOT RUN {
library(parameters)

# lavaan -------------------------------------
library(lavaan)

# Confirmatory Factor Analysis (CFA) ---------

structure <- " visual  =~ x1 + x2 + x3
               textual =~ x4 + x5 + x6
               speed   =~ x7 + x8 + x9 "
model <- lavaan::cfa(structure, data = HolzingerSwineford1939)
model_parameters(model)
model_parameters(model, standardize = TRUE)

# Structural Equation Model (SEM) ------------

structure <- "
  # latent variable definitions
    ind60 =~ x1 + x2 + x3
    dem60 =~ y1 + a*y2 + b*y3 + c*y4
    dem65 =~ y5 + a*y6 + b*y7 + c*y8
  # regressions
    dem60 ~ ind60
    dem65 ~ ind60 + dem60
  # residual correlations
    y1 ~~ y5
    y2 ~~ y4 + y6
    y3 ~~ y7
    y4 ~~ y8
    y6 ~~ y8
"
model <- lavaan::sem(structure, data = PoliticalDemocracy)
model_parameters(model)
model_parameters(model, standardize = TRUE)
# }
# NOT RUN {
# blavaan ------------------------------------
# library(blavaan)

# model <- blavaan::bsem(structure, data=PoliticalDemocracy)
# model_parameters(model)
# model_parameters(model, standardize = TRUE)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab