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
|
... |
Optional arguments to be
passed to
|
standardized |
Whether
standardized solution is needed. If
|
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 |
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()