Extract relevant regression indices from lavaan model through
lavaan::parameterEstimates
with standardized = TRUE
. In this
case, the beta (B) represents the resulting std.all
column.
Arguments
- fit
lavaan fit object to extract fit indices from
- 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 outcome, predictor, standardized regression coefficient, and corresponding p-value.
Examples
(latent <- list(visual = paste0("x", 1:3),
textual = paste0("x", 4:6),
speed = paste0("x", 7:9)))
#> $visual
#> [1] "x1" "x2" "x3"
#>
#> $textual
#> [1] "x4" "x5" "x6"
#>
#> $speed
#> [1] "x7" "x8" "x9"
#>
(regression <- list(ageyr = c("visual", "textual", "speed"),
grade = c("visual", "textual", "speed")))
#> $ageyr
#> [1] "visual" "textual" "speed"
#>
#> $grade
#> [1] "visual" "textual" "speed"
#>
HS.model <- write_lavaan(latent = latent, regression = regression)
cat(HS.model)
#> ##################################################
#> # [-----Latent variables (measurement model)-----]
#>
#> visual =~ x1 + x2 + x3
#> textual =~ x4 + x5 + x6
#> speed =~ x7 + x8 + x9
#>
#> ##################################################
#> # [---------Regressions (Direct effects)---------]
#>
#> ageyr ~ visual + textual + speed
#> grade ~ visual + textual + speed
#>
library(lavaan)
fit <- lavaan(HS.model, data=HolzingerSwineford1939,
auto.var=TRUE, auto.fix.first=TRUE,
auto.cov.lv.x=TRUE)
lavaan_reg(fit)
#> Outcome Predictor B p
#> 10 ageyr visual -2.712 0.024
#> 11 ageyr textual 0.615 0.213
#> 12 ageyr speed 2.516 0.011
#> 13 grade visual -2.277 0.012
#> 14 grade textual 0.888 0.024
#> 15 grade speed 2.237 0.003