Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

lav_data

lavaan data functions


Description

Utility functions related to the Data slot

Usage

# update data slot with new data (of the same size)
lav_data_update(lavdata = NULL, newX = NULL, BOOT.idx = NULL, lavoptions = NULL)

Arguments

lavdata

A lavdata object.

newX

A list of (new) data matrices (per group) of the same size. They will replace the data stored in the internal dataslot.

BOOT.idx

A list of integers. If bootstrapping was used to produce the data in newX, use these indices to adapt the remaining slots.

lavoptions

A named list. The Options lsot from a lavaan object.

Examples

# generate syntax for an independence model
HS.model <- ' visual  =~ x1 + x2 + x3
              textual =~ x4 + x5 + x6
              speed   =~ x7 + x8 + x9 '

fit <- cfa(HS.model, data=HolzingerSwineford1939)

# extract data slot and options
lavdata <- fit@Data
lavoptions <- lavInspect(fit, "options")

# create bootstrap sample
boot.idx <- sample(x = nobs(fit), size = nobs(fit), replace = TRUE)
newX <- list(lavdata@X[[1]][boot.idx,])

# generate update lavdata object
newdata <- lav_data_update(lavdata = lavdata, newX = newX, 
                           lavoptions = lavoptions)

lavaan

Latent Variable Analysis

v0.6-10
GPL (>= 2)
Authors
Yves Rosseel [aut, cre] (<https://orcid.org/0000-0002-4129-4477>), Terrence D. Jorgensen [aut] (<https://orcid.org/0000-0001-5111-6773>), Nicholas Rockwood [aut] (<https://orcid.org/0000-0001-5931-183X>), Daniel Oberski [ctb], Jarrett Byrnes [ctb], Leonard Vanbrabant [ctb], Victoria Savalei [ctb], Ed Merkle [ctb], Michael Hallquist [ctb], Mijke Rhemtulla [ctb], Myrsini Katsikatsou [ctb], Mariska Barendse [ctb], Florian Scharf [ctb], Han Du [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.