lavaanify
turns it into a table that represents the full
model as specified by the user. We refer to this table as the parameter table.lavaanify(model = NULL, meanstructure = FALSE, int.ov.free = FALSE,
int.lv.free = FALSE, orthogonal = FALSE, std.lv = FALSE,
fixed.x = TRUE, parameterization = "delta",
constraints = NULL, auto = FALSE, model.type = "sem",
auto.fix.first = FALSE, auto.fix.single = FALSE, auto.var = FALSE,
auto.cov.lv.x = FALSE, auto.cov.y = FALSE, auto.th = FALSE,
auto.delta = FALSE, varTable = NULL, ngroups = 1L, group.equal = NULL,
group.partial = NULL, group.w.free = FALSE,
debug = FALSE, warn = TRUE, as.data.frame. = TRUE)lavParTable(model = NULL, meanstructure = FALSE, int.ov.free = FALSE,
int.lv.free = FALSE, orthogonal = FALSE, std.lv = FALSE,
fixed.x = TRUE, parameterization = "delta",
constraints = NULL, auto = FALSE, model.type = "sem",
auto.fix.first = FALSE, auto.fix.single = FALSE, auto.var = FALSE,
auto.cov.lv.x = FALSE, auto.cov.y = FALSE, auto.th = FALSE,
auto.delta = FALSE, varTable = NULL, ngroups = 1L, group.equal = NULL,
group.partial = NULL, group.w.free = FALSE,
debug = FALSE, warn = TRUE, as.data.frame. = TRUE)
lavParseModelString(model.syntax = '', as.data.frame.=FALSE, warn=TRUE, debug=FALSE)
lavNames(object, type = "ov", group = NULL)
lavParseModelString
is also acceTRUE
, intercepts/means will be added to
the model both for both observed and latent variables.FALSE
, the intercepts of the observed variables
are fixed to zero.FALSE
, the intercepts of the latent variables
are fixed to zero.TRUE
, the exogenous latent variables
are assumed to be uncorrelated.TRUE
, the metric of each latent variable is
determined by fixing their variances to 1.0. If FALSE
, the metric
of each latent variable is determined by fixing the factor loading of the
first indicator to 1.0.TRUE
, the exogenous `x' covariates are considered
fixed variables and the means, variances and covariances of these variables
are fixed to their sample values. If FALSE
, they are considered
random, and the means, v"delta"
, the delta parameterization is used. If "theta"
,
the theta parameterization is used.TRUE
, the default values are used for the auto.*
arguments, depending on the value of model.type
."sem"
or "growth"
; only used if
auto=TRUE
.TRUE
, the factor loading of the first indicator
is set to 1.0 for every latent variable.TRUE
, the residual variance (if included)
of an observed indicator is set to zero if it is the only indicator of a
latent variable.TRUE
, the residual variances and the variances
of exogenous latent variables are included in the model and set free.TRUE
, the covariances of exogenous latent
variables are included in the model and set free.TRUE
, the covariances of dependent variables
(both observed and latent) are included in the model and set free.TRUE
, thresholds for limited dependent variables
are included in the model and set free.TRUE
, response scaling parameters for limited
dependent variables are included in the model and set free."loadings"
, "intercepts"
,
"means"
, "regressions"
, "residuals"
or
<TRUE
, the group frequencies are
considered to be free parameters in the model. In this case, a
Poisson model is fitted to estimate the group frequencies. If
FALSE
(the default), the group frequencies are fTRUE
, some (possibly harmless) warnings are printed
out.TRUE
, return the list of model parameters
as a data.frame
.TRUE
, debugging information is printed out.lavaanify
or lavParseModelString
, or an
object of class lavaan
.lavNames
. If type contains
"ov"
, only observed variable names are returned. If type contains
"lv"
, only latent variable names are returned. The "ov.x"
and "lv.x"
tlavNames
. If NULL
,
all groups (if any) are used. If an integer (vector), only names from those
groups are extracted. The group numbers are found in the group
column of the parameter table.x2
:y ~ x1 + 2.4*x2 + x3sqrt(10)
. Multiplying with NA
will force the corresponding parameter to be free.start()
, containing a numeric constant. For example:
y ~ x1 + start(1.0)*x2 + x3
Note that if a starting value is provided, the parameter is not
automatically considered to be free."=~"
, "~"
or "~~"
. The
third part is the name of the variable in the right-hand side of the formula
where the parameter was implied, or "1"
if it is an intercept. The three
parts are pasted together in a single string. For example, the name of the
fixed regression coefficient in the regression formula
y ~ x1 + 2.4*x2 + x3
is the string "y~x2"
.
The name of the parameter
corresponding to the covariance between two latent variables in the
formula f1 ~~ f2
is the string "f1~~f2"
.Although this automatic labeling of parameters is convenient, the user may
specify its own labels for specific parameters simply by pre-multiplying
the corresponding term (on the right hand side of the operator only) by
a character string (starting with a letter).
For example, in the formula f1 =~ x1 + x2 + mylabelx3
, the parameter
corresponding with the factor loading of
x3
will be named "mylabel"
.
"f1=~x3"
. An alternative way to specify
the label is as follows: f1 =~ x1 + x2 + label("mylabel")*x3
,
where the label is the argument of special function label()
;
this can be useful if the label contains a space, or an operator (like "~").
To constrain a parameter
to be equal to another target parameter, there are two ways. If you
have specified your own labels, you can use the fact that
equal labels imply equal parameter values.
If you rely on automatic parameter labels, you
can use the special function equal()
. The argument of
equal()
is the (automatic or user-specified) name of the target
parameter. For example, in the confirmatory factor analysis example below, the
intercepts of the three indicators of each latent variable are constrained to
be equal to each other. For the first three, we have used the default
names. For the last three, we have provided a custom label for the
y2a
intercept.
model <- '
# two latent variables with fixed loadings
f1 =~ 1*y1a + 1*y1b + 1*y1c
f2 =~ 1*y2a + 1*y2b + 1*y2c
# intercepts constrained to be equal # using the default names y1a ~ 1 y1b ~ equal("y1a~1") * 1 y1c ~ equal("y1a~1") * 1
# intercepts constrained to be equal # using a custom label y2a ~ int2*1 y2b ~ int2*1 y2c ~ int2*1 '
textual =~ x4 + start(c(1.2, 0.6))*x5 + x6
speed =~ x7 + x8 + c(x9.group1, x9.group2) * x9 ' In this example, the factor loading of the `x2' indicator is fixed to the value 0.5 for all groups. However, the factor loadings of the `x3' indicator are fixed to 0.6 and 0.8 for group 1 and group 2 respectively. The same logic is used for all modifiers. Note that character vectors can contain unquoted strings.
readLines
), or can be specified as a literal
string enclosed by single quotes as in the example below.
myModel <- '
# 1. latent variable definitions
f1 =~ y1 + y2 + y3
f2 =~ y4 + y5 + y6
f3 =~ y7 + y8 +
y9 + y10
f4 =~ y11 + y12 + y13! this is also a comment # 2. regressions f1 ~ f3 + f4 f2 ~ f4 y1 + y2 ~ x1 + x2 + x3
# 3. (co)variances y1 ~~ y1 y2 ~~ y4 + y5 f1 ~~ f2
# 4. intercepts f1 ~ 1; y5 ~ 1
# 5. thresholds y11 | t1 + t2 + t3 y12 | t1 y13 | t1 + t2
# 6. scaling factors y11 ~*~ y11 y12 ~*~ y12 y13 ~*~ y13
# 7. formative factors f5 <~ z1="" +="" z2="" z3="" z4="" '="" blank="" lines="" and="" comments="" can="" be="" used="" in="" between="" the="" formulas,="" formulas="" split="" over="" multiple lines.="" both="" sharp="" (#)="" exclamation="" (!)="" characters="" to="" start="" a="" comment.="" placed="" on="" single="" line="" if="" they="" are="" separated="" by="" semicolon="" (;).<="" p="">
There can be seven types of formula-like expressions in the model syntax:
"=~"
operator can be
used to define (continuous) latent variables. The name of the latent
variable is on the left of the"=~"
operator, while the terms
on the right, separated by"+"
operators, are the indicators
of the latent variable. The operator"=~"
can be read as ``is manifested by''.
"~"
operator specifies a regression.
The dependent variable is on the left of a"~"
operator and the
independent variables, separated by"+"
operators, are on the right.
These regression formulas are similar to the way ordinary linear regression
formulas are used in R, but they may include latent variables. Interaction
terms are currently not supported."~~"
(`double tilde') operator specifies
(residual) variances of an observed or latent variable, or a set of
covariances between one variable, and several other variables (either
observed or latent). Several variables, separated by"+"
operators can appear on the right. This way, several pairwise
(co)variances involving the same left-hand variable can be expressed in a
single expression. The distinction between variances and residual variances
is made automatically."~"
operator. On the right is
only the number"1"
representing the intercept. Including an intercept
formula in the model automatically impliesmeanstructure = TRUE
. The
distinction between intercepts and means is made automatically."|"
operator can be used to define the
thresholds of categorical endogenous variables (on the left hand side
of the operator). By convention, the
thresholds (on the right hand sided, separated by the"+"
operator,
are named"t1"
,"t2"
, etcetera."~*~"
operator defines a scale factor.
The variable name on the left hand side must be the same as the variable
name on the right hand side. Scale factors are used in the Delta
parameterization, in a multiple group analysis when factor indicators
are categorical."<~"< code="">operator can be used to define
a formative factor (on the right hand side of the operator), in a
similar why as a reflexive factor is defined (using the"=~"
operator). This is just syntax sugar to define a phantom latent
variable (equivalent to using"f =~ 0"
). And in addition, the
(residual) variance of the formative factor is fixed to zero.~"<>
"+"
operator, the formula is repeated for each
element on the left side (as for example in the third regression
formula in the example above). The only exception are scaling factors, where
only a single element is allowed on the left hand side. In the right-hand side of these formula-like expressions, each element can be
modified (using the "*"
operator) by either a numeric constant,
an expression resulting in a numeric constant, an expression resulting
in a character vector, or one
of three special functions: start()
, label()
and equal()
.
This provides the user with a mechanism to fix parameters, to provide
alternative starting values, to label the parameters, and to define equality
constraints among model parameters. All "*"
expressions are
referred to as modifiers. They are explained in more detail in the
following sections.