Learn R Programming

lavaSearch2 (version 1.0.0)

coefType: Extract the Specific Coefficient Bames or Positions in a LVM

Description

Extract the specific coefficient names or positions in a latent varable model.

Usage

coefType(x, ...)

# S3 method for lvm coefType(x, data = NULL, as.lava = TRUE, ...)

# S3 method for lvmfit coefType(x, as.lava = TRUE, ...)

# S3 method for multigroup coefType(x, as.lava = TRUE, ...)

coefCov(x, ...)

# S3 method for lvm coefCov(x, value = FALSE, keep.var = FALSE, ...)

# S3 method for lvmfit coefCov(x, value = FALSE, keep.var = FALSE, ...)

# S3 method for multigroup coefCov(x, value = FALSE, keep.var = FALSE, ...)

coefExtra(x, ...)

# S3 method for lvm coefExtra(x, value = FALSE, ...)

# S3 method for lvmfit coefExtra(x, value = FALSE, ...)

# S3 method for multigroup coefExtra(x, value = FALSE, ...)

coefIndexModel(x, ...)

# S3 method for lvm coefIndexModel(x, ...)

# S3 method for lvmfit coefIndexModel(x, ...)

# S3 method for multigroup coefIndexModel(x, ...)

# S3 method for multigroupfit coefIndexModel(x, ...)

coefIntercept(x, ...)

# S3 method for lvm coefIntercept(x, value = FALSE, ...)

# S3 method for lvmfit coefIntercept(x, value = FALSE, ...)

# S3 method for multigroup coefIntercept(x, value = FALSE, ...)

coefRef(x, ...)

# S3 method for lvmfit coefRef(x, value = FALSE, ...)

coefReg(x, ...)

# S3 method for lvm coefReg(x, value = FALSE, ...)

# S3 method for lvmfit coefReg(x, value = FALSE, ...)

# S3 method for multigroup coefReg(x, value = FALSE, ...)

coefVar(x, ...)

# S3 method for lvm coefVar(x, value = FALSE, ...)

# S3 method for lvmfit coefVar(x, value = FALSE, ...)

# S3 method for multigroup coefVar(x, value = FALSE, ...)

Arguments

x

a lvm model or a fitted lvm model

...

arguments to be passed to lava::coef

data

[optional] the dataset. Help to identify the categor

as.lava

export the type of parameters mimicking lava:::coef.

value

should the name of the coefficient be returned? Else return the coefficients

keep.var

should the variance parameters be returned?

Value

coefType either returns a data.frame:

  • 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. dichotimization).

  • 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 detailled decription of the type of link (see the details section)

  • lava: name of the parameter in lava

or a named vector containing the type of the links.

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\).

Examples

Run this code
# NOT RUN {
#### regression ####
m <- lvm(Y~X1+X2)
e <- estimate(m, sim(m, 1e2))

coefType(m)
coefType(e)

coefCov(m)
coefCov(m, value = TRUE)

coefCov(m, keep.var = TRUE)
coefCov(m, value = TRUE, keep.var = TRUE)

coefIndexModel(m)
coefIndexModel(e)

coefIntercept(m)
coefIntercept(m, value = TRUE)

coefReg(m)
coefReg(m, value = TRUE)

#### 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, sim(m.Sim, 1e2))

coefType(m)
coefType(e)

coefCov(m)
coefCov(m, value = TRUE) 

coefCov(m, keep.var = TRUE)
coefCov(m, value = TRUE, keep.var = TRUE)

coefExtra(m)

coefIndexModel(m)
coefIndexModel(e)

categorical(m, labels = as.character(1:3)) <- "X1"
coefExtra(m)
coefExtra(m, value = TRUE)

categorical(m, labels = as.character(1:3)) <- "x1"

coefType(m, as.lava = FALSE)

coefIntercept(m)
coefIntercept(m, value = TRUE)
coefIntercept(e)

coefReg(e, value = TRUE)

#### 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, sim(m,1e2))
coefType(m)
coef(e, level = 9)
coefType(e)

#### multigroup ####
m <- lvm(Y~X1+X2)
eG <- estimate(list(m,m), list(sim(m, 1e2),sim(m, 1e2)))
coefType(eG)
coef(eG)

coefIndexModel(eG)

# }

Run the code above in your browser using DataLab