if (FALSE) {
#############################################################################
# EXAMPLE 1: Path model data.bifie01
#############################################################################
data(data.bifie01)
dat <- data.bifie01
# create dataset with replicate weights and plausible values
bifieobj <- BIFIEsurvey::BIFIE.data.jack( data=dat, jktype="JK_TIMSS",
jkzone="JKCZONE", jkrep="JKCREP", wgt="TOTWGT",
pv_vars=c("ASMMAT","ASSSCI") )
#**************************************************************
#*** Model 1: Path model
lavmodel1 <- "
ASMMAT ~ ASBG07A + ASBG07B + ASBM03 + ASBM02A + ASBM02E
# define latent variable with 2nd and 3rd item in reversed scoring
ASBM03=~ 1*ASBM03A + (-1)*ASBM03B + (-1)*ASBM03C + 1*ASBM03D
ASBG07A ~ ASBM02E
ASBG07A ~~ .2*ASBG07A # measurement error variance of .20
ASBM02E ~~ .45*ASBM02E # measurement error variance of .45
ASBM02E ~ ASBM02A + ASBM02B
"
#--- Model 1a: model calculated by gender
mod1a <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel1, group="female" )
summary(mod1a)
#--- Model 1b: Input of some known reliabilities
reliability <- c( "ASBM02B"=.6, "ASBM02A"=.8 )
mod1b <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel1, reliability=reliability)
summary(mod1b)
#**************************************************************
#*** Model 2: Linear regression with errors in predictors
# specify lavaan model
lavmodel2 <- "
ASMMAT ~ ASBG07A + ASBG07B + ASBM03A
ASBG07A ~~ .2*ASBG07A
"
mod2 <- BIFIEsurvey::BIFIE.pathmodel( bifieobj, lavmodel2 )
summary(mod2)
}
Run the code above in your browser using DataLab