Learn R Programming

lavaSearch2 (version 1.0.0)

var2dummy: Convert Variable Names to Dummy Variables Names.

Description

When dealing with categorical variables, the estimate function convert the categorical variables into dummy variables. This function convert a set of variable names to their corresponding name in the model with dummy variables

Usage

var2dummy(x, ...)

# S3 method for list var2dummy(x, var, rm.first.factor = TRUE, ...)

# S3 method for lvm var2dummy(x, data = NULL, ...)

Arguments

x

a latent variable model.

...

additional arguments to be passed to lower levels functions.

var

the variable to be transformed.

rm.first.factor

should the first level of each categorical variable be ignored?

data

dataset according to which the model should be updated.

Examples

Run this code
# NOT RUN {
library(lava)

m <- lvm()
regression(m) <- c(y1,y2,y3)~u
regression(m) <- u ~ X1+X2
var2dummy(m, var = c("X1","X2"))
categorical(m,labels=c("M","F","MF")) <- ~X1
var2dummy(m, var = c("X1","X2"))
categorical(m,labels=c("1","2","3")) <- ~X2
var2dummy(m, var = c("X1","X2"))
# }

Run the code above in your browser using DataLab