vec_rsquare {semhelpinghands}R Documentation

Wrapper Functions to Extract Information as a Vector

Description

A set of wrapper functions to extract information from a lavaan-class object and return a named vector.

Usage

vec_rsquare(object)

vec_sample_vcov(object)

vec_sample_var(object)

vec_est_var(object)

vec_est_se(object)

vec_def_var(object)

vec_def_se(object)

vec_lavTestLRT(
  object,
  ...,
  method = "default",
  A.method = "delta",
  scaled.shifted = TRUE,
  H1 = TRUE,
  model.names = NULL
)

vec_lavTestScore(
  object,
  add = NULL,
  release = NULL,
  univariate = TRUE,
  information = "expected"
)

vec_lavTestWald(object, constraints = NULL, prefix = NULL)

vec_compRelSEM(object, ...)

Arguments

object

A lavaan-class object.

...

Additional arguments to be passed to the original function.

method

An argument to be passed to lavaan::lavTestLRT(). Please refer to the help page of lavaan::lavTestLRT().

A.method

An argument to be passed lavaan::lavTestLRT(). Please refer to the help page of lavaan::lavTestLRT().

scaled.shifted

An argument to be passed to lavaan::lavTestLRT(). Please refer to the help page of lavaan::lavTestLRT().

H1

An argument to be passed to lavaan::lavTestLRT(). Please refer to the help page of lavaan::lavTestLRT().

model.names

An argument to be passed to lavaan::lavTestLRT(). Please refer to the help page of lavaan::lavTestLRT(). Unlike lavaan::lavTestLRT(), this argument is required, for the sake of naming the vector to be returned.

add

An argument to be passed to lavaan::lavTestScore(). Please refer to the help page of lavaan::lavTestScore().

release

An argument to be passed to lavaan::lavTestScore(). Please refer to the help page of lavaan::lavTestScore().

univariate

An argument to be passed to lavaan::lavTestScore(). Please refer to the help page of lavaan::lavTestScore().

information

An argument to be passed to lavaan::lavTestScore(). Please refer to the help page of lavaan::lavTestScore().

constraints

An argument to be passed to lavaan::lavTestWald(). Please refer to the help page of lavaan::lavTestWald().

prefix

Optional. A character string to be added as a prefix to names of the output. Default is NULL.

Details

This set of wrapper functions are for functions like lavaan::bootstrapLavaan() that require users to supply a function that receives a lavaan-class object and returns a vector of values.

All wrappers functions are designed to have the same form of output: a named numeric vector.

Many of the tasks of this set of wrappers can be performed by writing our own functions. The wrapper functions are developed just to save the coding time for some commonly requested information.

The wrapper functions are designed to be as simple to use as possible, with as few arguments as possible. If advanced control is needed, users are recommended to write their own wrappers.

Value

All of them return a named numeric vector.

Functions

Author(s)

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

See Also

lavaan::lavInspect()

Examples


# From the help page of lavaan::cfa().

library(lavaan)
HS.model <- '
visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9
'
fit <- cfa(HS.model, data = HolzingerSwineford1939)

vec_rsquare(fit)
vec_sample_vcov(fit)
vec_sample_var(fit)
vec_est_var(fit)
vec_est_se(fit)

HS.model.sem1 <- '
visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9
textual ~ a * visual
speed ~ b * textual
ab := a * b
'
fit_sem1 <- sem(HS.model.sem1, data = HolzingerSwineford1939)

HS.model.sem2 <- '
visual  =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed   =~ x7 + x8 + x9
textual ~ a * visual
speed ~ b * textual + cp * visual
ab := a * b
'
fit_sem2 <- sem(HS.model.sem2, data = HolzingerSwineford1939)

vec_def_var(fit_sem1)
vec_def_se(fit_sem1)

vec_lavTestLRT(fit_sem1, fit_sem2,
               model.names = c("No Direct", "Direct"))

vec_lavTestScore(fit_sem1,
                 add = "speed ~ visual")

vec_lavTestWald(fit_sem2,
                constraints = "cp == 0")

if (requireNamespace("semTools")) {
    vec_compRelSEM(fit)
  }



[Package semhelpinghands version 0.1.11 Index]