lav_constraints: Utility Functions: Constraints

Description Usage Arguments Details Examples

Description

Utility functions for equality and inequality constraints.

Usage

1
2
3
4
5
6
7
8

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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) )

yrosseel/lavaan documentation built on Dec. 14, 2018, 6:24 p.m.