lrt {semlrtp}R Documentation

Fix a Free Parameter to Zero and Do an LR Test

Description

Fix the designated free parameter to zero and do a likelihood ratio test.

Usage

lrt(
  fit,
  par_id,
  store_fit = FALSE,
  group = NULL,
  se_keep_bootstrap = FALSE,
  LRT_method = "default",
  scaled.shifted = TRUE,
  fallback_method = "satorra.2000"
)

Arguments

fit

A lavaan-class object.

par_id

It can be an integer. or a string. If it is an integer, it should be the row number of the free parameter in the parameter table of fit to be fixed to zero. If it is a string, it must be a valid lavaan model syntax for a parameter, or the label of a labelled parameter.

store_fit

Logical. If TRUE, fit will be stored in the output. Default is FALSE.

group

If a model syntax is used in par_id and the model is a multigroup model, this should be either the group label or the group number of the parameter.

se_keep_bootstrap

Logical. If TRUE and fit used bootstrapping standard error (with se = "bootstrap"), bootstrapping will also be use in fitting the restricted model. If FALSE, the default, then se will be set to "standard" if it is "bootstrap" in fit, to speed up the computation.

LRT_method

String. Passed to the method argument of lavaan::lavTestLRT(). Default is "default", and let lavaan::lavTestLRT() decide the method based on fit.

scaled.shifted

Logical. Used when the method used in lavaan::lavTestLRT() is "satorra.2000". Default is TRUE and a scaled and shifted test statistic is used, the same default of lavaan::lavTestLRT().

fallback_method

The default method of lavaan::lavTestLRT(), "satorra.bentler.2001", may sometimes fail. If failed, this function will call lavaan::lavTestLRT() again using fallback_method. which is "satorra.2000" by default.

Details

It fixes the designated free parameter in a lavaan output, refit the model, and do a likelihood ratio test comparing this model with the original model.

The model to be fixed is generated by fix_to_zero().

If the parameter to be fixed is a variance, related covariance(s), if any, will also be fixed to zero.

Users should usually call lrtp() directly instead of calling this function. It is exported for developers.

Value

A lrt-class object, which is a list with the following elements:

Author(s)

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

See Also

print.lrt() for its print-method, and lrtp() for the main function.

Examples

library(lavaan)
data(data_sem16)
mod <-
"
f1 =~ x1 + x2 + x3
f2 =~ x4 + x5 + x6
"
fit <- sem(mod, data_sem16)
# Fix the factor covariance to zero
out <- lrt(fit, par_id = 15)
out$lrt
parameterEstimates(fit)[15, ]
parameterEstimates(out$fix_to_zero$fit0)[15, ]

# Can use model syntax for par_id

out <- lrt(fit, par_id = "f1 =~ x3")
out$lrt


[Package semlrtp version 0.1.1 Index]