group_by_models {semhelpinghands} | R Documentation |
Group Estimates By Models
Description
Groups parameter estimates or other information such as p-values into a table with models as columns.
Usage
group_by_models(
object_list,
...,
col_names = "est",
group_first = FALSE,
model_first = TRUE,
use_standardizedSolution = FALSE
)
Arguments
object_list |
A named list of
lavaan objects, a named list
of the output of
|
... |
Optional arguments to be
passed to
|
col_names |
A vector of the
column names in the parameter
estimate tables to be included.
Default is |
group_first |
If |
model_first |
If |
use_standardizedSolution |
If |
Value
A data-frame-like object of
the class est_table
.
Author(s)
Shu Fai Cheung
https://orcid.org/0000-0002-9871-9448
Inspired by the proposal Rönkkö posted in a GitHub
https://github.com/simsem/semTools/issues/24#issue-235172313
for semTools
. I want something
simple for a quick overview and so
I wrote this function.
Examples
library(lavaan)
set.seed(5478374)
n <- 50
x <- runif(n) - .5
m <- .40 * x + rnorm(n, 0, sqrt(1 - .40))
y <- .30 * m + rnorm(n, 0, sqrt(1 - .30))
dat <- data.frame(x = x, y = y, m = m)
model1 <-
'
m ~ a*x
y ~ b*m
ab := a*b
'
fit1 <- sem(model1, data = dat, fixed.x = FALSE)
model2 <-
'
m ~ a*x
y ~ b*m + x
ab := a*b
'
fit2 <- sem(model2, data = dat, fixed.x = FALSE)
parameterEstimates(fit1)
parameterEstimates(fit2)
group_by_models(list(no_direct = fit1,
direct = fit2),
col_names = c("est", "pvalue"))
# Can also be used with some other functions in
# semhelpinghands
group_by_models(list(no_direct = fit1,
direct = fit2),
col_names = c("est", "pvalue")) |>
filter_by(op = "~")