extractData {lavaSearch2} | R Documentation |
Extract Data From a Latent Variable Model
Description
Extract data from a latent variable model.
Usage
extractData(object, design.matrix, as.data.frame, envir, rm.na)
## S3 method for class 'lvmfit'
extractData(
object,
design.matrix = FALSE,
as.data.frame = TRUE,
envir = environment(),
rm.na = TRUE
)
Arguments
object |
the fitted model. |
design.matrix |
[logical] should the data be extracted after transformation (e.g. conversion of categorical variables to dummy variables)? Otherwise the original data will be returned. |
as.data.frame |
[logical] should the output be converted into a |
envir |
[environment] the environment from which to search the data. |
rm.na |
[logical] should the lines containing missing values in the dataset be removed? |
Value
a dataset.
Examples
#### simulate data ####
set.seed(10)
n <- 101
Y1 <- rnorm(n, mean = 0)
Y2 <- rnorm(n, mean = 0.3)
Id <- findInterval(runif(n), seq(0.1,1,0.1))
data.df <- rbind(data.frame(Y=Y1,G="1",Id = Id),
data.frame(Y=Y2,G="2",Id = Id)
)
#### latent variable model ####
library(lava)
e.lvm <- estimate(lvm(Y ~ G), data = data.df)
extractData(e.lvm)
extractData(e.lvm, design.matrix = TRUE)
[Package lavaSearch2 version 2.0.3 Index]