###load SAT12 and compute bifactor model with 3 specific factors
data(SAT12)
fulldata <- key2binary(SAT12,
key = c(1,4,5,2,3,1,2,1,3,1,2,4,2,1,5,3,4,4,1,4,3,3,4,1,3,5,1,3,1,5,4,5))
specific <- c(2,3,2,3,3,2,1,2,1,1,1,3,1,3,1,2,1,1,3,3,1,1,3,1,3,3,1,3,2,3,1,2)
mod1 <- bfactor(fulldata, specific)
coef(mod1)
###Try with guessing parameters added
guess <- rep(.1,32)
mod2 <- bfactor(fulldata, specific, guess = guess)
coef(mod2) #item 32 too difficult to include guessing par
#fix by imposing a weak intercept prior
mod3a <- bfactor(fulldata, specific, guess = guess, par.prior =
list(int = c(0,4), int.items = 32))
coef(mod3a)
#...or by removing guessing parameter
guess[32] <- 0
mod3b <- bfactor(fulldata, specific, guess = guess)
coef(mod3b)
Run the code above in your browser using DataLab