lavaan_var {lavaanExtra}R Documentation

Extract relevant variance indices from lavaan model

Description

Extract relevant variance indices from lavaan model through lavaan::parameterEstimates (when estimate = "sigma", est column)) or lavaan::standardizedsolution (when estimate = "r2", est.std column). R2 values are then calculated as 1 - est.std, and the new p values for the R2, with the following formula: stats::pnorm((1 - est) / se).

Usage

lavaan_var(fit, estimate = "r2", nice_table = FALSE, ...)

Arguments

fit

lavaan fit object to extract covariance indices from

estimate

What estimate to use, either the standardized estimate ("r2", default), or unstandardized estimate ("sigma2").

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 of covariances/correlation, including the covaried variables, the covariance/correlation, and corresponding p-value.

Examples


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

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

(covariance <- list(speed = "textual", ageyr = "grade"))

HS.model <- write_lavaan(
  regression = regression, covariance = covariance,
  latent = latent, label = TRUE
)
cat(HS.model)

library(lavaan)
fit <- sem(HS.model, data = HolzingerSwineford1939)
lavaan_var(fit)


[Package lavaanExtra version 0.2.0 Index]