coefType {lavaSearch2} | R Documentation |
Extract the Type of Each Coefficient
Description
Extract the type of each coefficient of a lvm
object.
Usage
coefType(object, as.lava, ...)
## S3 method for class 'lvm'
coefType(object, as.lava = TRUE, data = NULL, ...)
## S3 method for class 'lvmfit'
coefType(object, as.lava = TRUE, ...)
## S3 method for class 'multigroup'
coefType(object, as.lava = TRUE, ...)
Arguments
object |
a |
as.lava |
[logical] export the type of coefficients mimicking |
... |
arguments to be passed to |
data |
[data.frame, optional] the dataset. Help to identify the categorical variables. |
Details
A lvm can be written as a measurement model:
Y_i = \nu + \Lambda \eta_i + K X_i + \epsilon_i
and a structural model:
\eta_i = \alpha + B \eta_i + \Gamma X_i + \zeta_i
where \Psi
is the variance covariance matrix of the residuals \zeta
and \Sigma
is the variance covariance matrix of the residuals \epsilon
.
coefType
either returns the Latin/Greek letter corresponding to the coefficients
or it groups them:
intercept:
\nu
and\alpha
.regression:
\Lambda
,K
,B
, and\Gamma
.covariance: extra-diagonal terms of
\Sigma
and\Psi
.variance: diagonal of
\Sigma
and\Psi
.
A link denotes a relationship between two variables. The coefficient are used to represent the strength of the association between two variable, i.e. the strength of a link. A coefficient may corresponds to the strength of one or several link.
Value
coefType
returns a data.frame
when as.lava=FALSE
:
name: name of the link
Y: outcome variable
X: regression variable in the design matrix (could be a transformation of the original variables, e.g. dichotomization).
data: original variable
type: type of link
value: if TRUE, the value of the link is set and not estimated.
marginal: if TRUE, the value of the link does not impact the estimation.
detail: a more detailed description of the type of link (see the details section)
lava: name of the coefficient in lava
When as.lava=TRUE
, coefType
returns a named vector containing the type of each coefficient.
Examples
#### regression ####
m <- lvm(Y~X1+X2)
e <- estimate(m, lava::sim(m, 1e2))
coefType(m)
coefType(e)
#### LVM ####
m <- lvm()
regression(m) <- c(y1,y2,y3)~u
regression(m) <- u~x1+x2
latent(m) <- ~u
covariance(m) <- y1~y2
m.Sim <- m
categorical(m.Sim, labels = c("a","b","c")) <- ~x2
e <- estimate(m, lava::sim(m.Sim, 1e2))
coefType(m)
coefType(e)
## additional categorical variables
categorical(m, labels = as.character(1:3)) <- "X1"
coefType(m, as.lava = FALSE)
#### LVM with constrains ####
m <- lvm(c(Y1~0+1*eta1,Y2~0+1*eta1,Y3~0+1*eta1,
Z1~0+1*eta2,Z2~0+1*eta2,Z3~0+1*eta2))
latent(m) <- ~eta1 + eta2
e <- estimate(m, lava::sim(m,1e2))
coefType(m)
coefType(e)
#### multigroup ####
m <- lvm(Y~X1+X2)
eG <- estimate(list(m,m), list(lava::sim(m, 1e2), lava::sim(m, 1e2)))
coefType(eG)