add_sig {semhelpinghands}R Documentation

Add Significant Test Results

Description

It inserts columns to denote whether a parameter is significant.

Usage

add_sig(object, ..., standardized = FALSE, na_str = "", use = "pvalue")

Arguments

object

A lavaan object or the output of lavaan::parameterEstimates() or lavaan::standardizedSolution(). May also work on an est_table-class object returned by functions like group_by_dvs() but there is no guarantee.

...

Optional arguments to be passed to lavaan::parameterEstimates() or lavaan::standardizedSolution().

standardized

Whether standardized solution is needed. If TRUE, lavaan::standardizedSolution() will be called. If FALSE, the default, lavaan::parameterEstimates() will be called. Ignored if a table if estimates is supplied.

na_str

The string to be used for parameters with no significant tests. For example, fixed parameters. Default is "".

use

A character vector of one or more strings. If "pvalue" is in the vector, p-values will be used. If "ci" is in the vector, confidence intervals appeared in ci.lower and ci.upper will be used. If "boot.ci" is in the vector and the columns boot.ci.lower and boot.ci.upper are available, these columns will be used. Note that ci.lower and ci.upper can also be bootstrap confidence intervals in some tables if se = "boot" is used.

Details

The function calls lavaan::parameterEstimates() or lavaan::standardizedSolution() and checks the columns pvalue, ci.lower and ci.upper, and/or boot.ci.lower and boot.ci.upper and then inserts columns to denote for each parameter estimate whether it is significant based on the requested criteria.

Value

The output of lavaan::parameterEstimates() or lavaan::standardizedSolution(), with one or two columns inserted after the parameter estimates to denote the significant test results.

Author(s)

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

See Also

lavaan::parameterEstimates() and lavaan::standardizedSolution()

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)

# Add "*" based on 'pvalue'
add_sig(fit)

# Add "*" for standardized solution
add_sig(fit, standardized = TRUE)

# Add "*" based on confidence interval
add_sig(fit, use = "ci")

# Add "*" for standardized solution based on confidence interval
add_sig(fit, standardized = TRUE, use = "ci")

# Add "*" for standardized solution based on confidence interval
# and 'pvalue'.
add_sig(fit, standardized = TRUE, use = c("ci", "pvalue"))

# Can also accept a parameter estimates table
est <- parameterEstimates(fit)
add_sig(est)

# So it can be used with some other functions in semhelpinghands
add_sig(filter_by(est, op = "~"))

# Piping can also be used
est |> filter_by(op = "~") |>
       add_sig()


[Package semhelpinghands version 0.1.11 Index]