if (FALSE) {
#############################################################################
# EXAMPLE 1: data.lsem01 | Age differentiation and tested models
#############################################################################
data(data.lsem01, package="sirt")
dat <- data.lsem01
# specify lavaan model
lavmodel <- "
F=~ v1+v2+v3+v4+v5
F ~~ 1*F
"
# define grid of moderator variable age
moderator.grid <- seq(4,23,1)
#-- estimate LSEM with bandwidth 2
mod <- sirt::lsem.estimate( dat, moderator="age", moderator.grid=moderator.grid,
lavmodel=lavmodel, h=2, std.lv=TRUE)
summary(mod1)
#-- bootstrap model
bmod <- sirt::lsem.bootstrap(mod, R=200)
#-- test models
models <- list( "F=~v1"=y ~ m + I(m^2),
"F=~v2"=y ~ I( splines::bs(m, df=4) ) )
tmod <- sirt::lsem.test(mod=mod, bmod=bmod, models=models)
str(tmod)
sirt::print_digits(wald_test_global, 3)
sirt::print_digits(test_models, 3)
}
Run the code above in your browser using DataLab