Learn R Programming

lavaSearch2 (version 1.0.0)

defineCategoricalLink: Identify Categorical Links in LVM

Description

Identify categorical links in latent variable models.

Usage

defineCategoricalLink(object, link, data)

# S3 method for lvm defineCategoricalLink(object, link = NULL, data = NULL)

Arguments

object

a lvm model.

link

the links to be analyzed. If NULL, all the coefficients from the lvm model are used instead.

data

the dataset that will be used to fit the model. If NULL, a simulated data will be generated from the model.

Examples

Run this code
# NOT RUN {
## linear model
m <- lvm(Y1~X1+X2,Y2~X1+X3)
categorical(m, K = 3) <- "X1"
try(defineCategoricalLink(m)) # error

categorical(m, K = 3, labels = 1:3) <- "X1"
defineCategoricalLink(m)
defineCategoricalLink(m, "Y~X1")
defineCategoricalLink(m, "X1:0|1")
defineCategoricalLink(m, "X1:1|2")
defineCategoricalLink(m, c("X1:0|1", "X1:1|2"))
defineCategoricalLink(m, c("Y~X1","Y~X2"))
defineCategoricalLink(m, c("Y~X2","Y~X1"))

## latent variable model
m <- lvm()
regression(m) <- c(y1,y2,y3)~u
regression(m) <- u~x1+x2
latent(m) <- ~u
covariance(m) <- y1~y2
categorical(m, labels = as.character(1:3)) <- "X1"

defineCategoricalLink(m)

# }

Run the code above in your browser using DataLab