Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lav_constraints

Utility Functions: Constraints


Description

Utility functions for equality and inequality constraints.

Usage

lav_constraints_parse(partable = NULL, constraints = NULL, theta = NULL, 
                     debug = FALSE)
lav_partable_constraints_ceq(partable, con = NULL, debug = FALSE, 
                             txtOnly = FALSE)
lav_partable_constraints_ciq(partable, con = NULL, debug = FALSE, 
                             txtOnly = FALSE)
lav_partable_constraints_def(partable, con = NULL, debug = FALSE, 
                             txtOnly = FALSE)

Arguments

partable

A lavaan parameter table.

constraints

A character string containing the constraints.

theta

A numeric vector. Optional vector with values for the model parameters in the parameter table.

debug

Logical. If TRUE, show debugging information.

con

An optional partable where the operator is one of ‘==’, ‘>’, ‘<’ or ‘:=’

txtOnly

Logical. If TRUE, only the body of the function is returned as a character string. If FALSE, a function is returned.

Details

This is a collection of lower-level constraint related functions that are used in the lavaan code. They are made public per request of package developers. Below is a brief description of what they do:

The lav_constraints_parse function parses the constraints specification (provided as a string, see example), and generates a list with useful information about the constraints.

The lav_partable_constraints_ceq function creates a function which takes the (unconstrained) parameter vector as input, and returns the slack values for each equality constraint. If the equality constraints hold perfectly, this function returns zeroes.

The lav_partable_constraints_ciq function creates a function which takes the (unconstrained) parameter vector as input, and returns the slack values for each inequality constraint.

The lav_partable_constraints_def function creates a function which takes the (unconstrained) parameter vector as input, and returns the computed values of the defined parameters.

Examples

myModel <- 'x1 ~ a*x2 + b*x3 + c*x4'
myParTable <- lavaanify(myModel, as.data.frame. = FALSE)
con <- ' a == 2*b
         b - c == 5 '
conInfo <- lav_constraints_parse(myParTable, constraints = con)

myModel2 <- 'x1 ~ a*x2 + b*x3 + c*x4
             a == 2*b
             b - c == 5 '
ceq <- lav_partable_constraints_ceq(partable = lavaanify(myModel2))
ceq( c(2,3,4) )

lavaan

Latent Variable Analysis

v0.6-10
GPL (>= 2)
Authors
Yves Rosseel [aut, cre] (<https://orcid.org/0000-0002-4129-4477>), Terrence D. Jorgensen [aut] (<https://orcid.org/0000-0001-5111-6773>), Nicholas Rockwood [aut] (<https://orcid.org/0000-0001-5931-183X>), Daniel Oberski [ctb], Jarrett Byrnes [ctb], Leonard Vanbrabant [ctb], Victoria Savalei [ctb], Ed Merkle [ctb], Michael Hallquist [ctb], Mijke Rhemtulla [ctb], Myrsini Katsikatsou [ctb], Mariska Barendse [ctb], Florian Scharf [ctb], Han Du [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.