group_estimates {semhelpinghands}R Documentation

Group Estimates By Dependent or Independent Variables

Description

Groups parameter estimates or other information such as p-values into a table with dependent variables as columns and independent variables as rows, or a transpose of this table.

Usage

group_by_dvs(
  object,
  ...,
  col_name = "est",
  add_prefix = TRUE,
  group_first = FALSE,
  use_standardizedSolution = FALSE
)

group_by_ivs(
  object,
  ...,
  col_name = "est",
  add_prefix = TRUE,
  group_first = FALSE,
  use_standardizedSolution = FALSE
)

Arguments

object

A lavaan object or the output of lavaan::parameterEstimates() or lavaan::standardizedSolution().

...

Optional arguments to be passed to lavaan::parameterEstimates(). Ignored if object is an output of lavaan::parameterEstimates() or lavaan::standardizedSolution().

col_name

The column name of information to be grouped. Default is "est". It accepts only one name.

add_prefix

If TRUE, the default, col_name will be added as prefix to the column names of the output.

group_first

If TRUE, the rows will be grouped by groups first and then by independent variables Ignored if the model has only one group. Default is FALSE.

use_standardizedSolution

If TRUE and object is not an estimates table, then lavaan::standardizedSolution() will be used to generate the table. If FALSE, the default, then lavaan::parameterEstimates() will be used if necessary.

Details

It gets a lavaan object or the output of lavaan::parameterEstimates() or lavaan::standardizedSolution() and group selected columns by "dependent" variables group_by_dvs() or by "independent" variables group_by_ivs().

"Dependent" variables are defined as variables on the left hand side of the operator ~.

"Independent" variables are defined as variables on the right hand side of the operator ~.

Note that a variable can both be a "dependent" variable and an "independent" variable in a model.

Value

A data-frame-like object of the class est_table.

Author(s)

Shu Fai Cheung https://orcid.org/0000-0002-9871-9448

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)
model <-
'
m ~ a*x
y ~ b*m
ab := a*b
'

fit <- sem(model, data = dat, fixed.x = FALSE)
parameterEstimates(fit)

# Group by DVs
group_by_dvs(fit)

# Group by IVs
group_by_ivs(fit)


[Package semhelpinghands version 0.1.11 Index]