lavaan_defined {lavaanExtra}R Documentation

Extract relevant user-defined parameter (e.g., indirect or total effects) indices from lavaan model

Description

Extract relevant user-defined parameters (e.g., indirect or total effects) indices from lavaan model through lavaan::parameterEstimates and lavaan::standardizedsolution.

Usage

lavaan_defined(
  fit,
  underscores_to_symbol = "→",
  lhs_name = "User-Defined Parameter",
  rhs_name = "Paths",
  nice_table = FALSE,
  ...
)

Arguments

fit

lavaan fit object to extract fit indices from

underscores_to_symbol

Character to convert underscores to arrows in the first column, like for indirect effects. Default to the right arrow symbol, but can be set to NULL or "_", or to any other desired symbol. It is also possible to provide a vector of replacements if they they are not all the same.

lhs_name

Name of first column, referring to the left-hand side expression (lhs).

rhs_name

Name of first column, referring to the right-hand side expression (rhs).

nice_table

Logical, whether to print the table as a rempsyc::nice_table as well as print the reference values at the bottom of the table.

...

Arguments to be passed to rempsyc::nice_table

Value

A dataframe, including the indirect effect ("lhs"), corresponding paths ("rhs"), standardized regression coefficient ("std.all"), corresponding p-value, as well as the unstandardized regression coefficient ("est") and its confidence interval ("ci.lower", "ci.upper").

Examples


x <- paste0("x", 1:9)
(latent <- list(
  visual = x[1:3],
  textual = x[4:6],
  speed = x[7:9]
))

(mediation <- list(
  speed = "visual",
  textual = "visual",
  visual = c("ageyr", "grade")
))

(indirect <- list(
  IV = c("ageyr", "grade"),
  M = "visual",
  DV = c("speed", "textual")
))

HS.model <- write_lavaan(mediation,
  indirect = indirect,
  latent = latent, label = TRUE
)
cat(HS.model)

library(lavaan)
fit <- sem(HS.model, data = HolzingerSwineford1939)
lavaan_defined(fit, lhs_name = "Indirect Effect")


[Package lavaanExtra version 0.2.0 Index]