if (FALSE) {
#############################################################################
# EXAMPLE 1: Dataset reading from sirt package
#############################################################################
data(data.read,package="sirt")
resp <- data.read
#***
# Model 1a: Exploratory factor analysis with 2 factors
mod1a <- TAM::tam.fa( resp=resp, irtmodel="efa", nfactors=2 )
summary(mod1a)
# varimax rotation
stats::varimax(mod1a$B.stand)
# promax rotation
stats::promax(mod1a$B.stand)
# more rotations are included in the GPArotation package
library(GPArotation)
# geomin rotation oblique
GPArotation::geominQ( mod1a$B.stand )
# quartimin rotation
GPArotation::quartimin( mod1a$B.stand )
#***
# Model 1b: Rasch testlet model with 3 testlets
dims <- substring( colnames(resp),1,1 ) # define dimensions
mod1b <- TAM::tam.fa( resp=resp, irtmodel="bifactor1", dims=dims )
summary(mod1b)
#***
# Model 1c: Bifactor model
mod1c <- TAM::tam.fa( resp=resp, irtmodel="bifactor2", dims=dims )
summary(mod1c)
#***
# Model 1d: reestimate Model 1c but assume that items 3 and 5 do not load on
# specific factors
dims1 <- dims
dims1[c(3,5)] <- NA
mod1d <- TAM::tam.fa( resp=resp, irtmodel="bifactor2", dims=dims1 )
summary(mod1d)
#############################################################################
# EXAMPLE 2: Polytomous data
#############################################################################
data(data.timssAusTwn.scored, package="TAM")
dat <- data.timssAusTwn.scored
resp <- dat[, grep("M0", colnames(dat))]
#***
# Model 1a: Rasch testlet model with 2 testlets
dims <- c( rep(1,5), rep(2,6))
mod1a <- TAM::tam.fa( resp=resp, irtmodel="bifactor1", dims=dims )
summary(mod1a)
#***
# Model 1b: Bifactor model
mod1b <- TAM::tam.fa( resp=resp, irtmodel="bifactor2", dims=dims )
summary(mod1b)
}
Run the code above in your browser using DataLab