## Not run:
# data(data.fims.Aus.Jpn.scored)
# #*****
# # Model 1: Differential Item Functioning Gender for Australian students
#
# # extract Australian students
# scored <- data.fims.Aus.Jpn.scored[ data.fims.Aus.Jpn.scored$country == 1 , ]
#
# # select items
# items <- grep("M1" , colnames(data.fims.Aus.Jpn.scored) , value=TRUE)
# ## > items
# ## [1] "M1PTI1" "M1PTI2" "M1PTI3" "M1PTI6" "M1PTI7" "M1PTI11" "M1PTI12"
# ## [8] "M1PTI14" "M1PTI17" "M1PTI18" "M1PTI19" "M1PTI21" "M1PTI22" "M1PTI23"
#
# # Run partial credit model
# mod1 <- tam.mml(scored[,items])
#
# # extract values of the gender variable into a variable called "gender".
# gender <- scored[,"SEX"]
# # computes the test score for each student by calculating the row sum
# # of each student's scored responses.
# raw_score <- rowSums(scored[,items] )
#
# # compute the mean test score for each gender group: 1=male, and 2=female
# stats::aggregate(raw_score,by=list(gender),FUN=mean)
# # The mean test score is 6.12 for group 1 (males) and 6.27 for group 2 (females).
# # That is, the two groups performed similarly, with girls having a slightly
# # higher mean test score. The step of computing raw test scores is not necessary
# # for the IRT analyses. But it's always a good practice to explore the data
# # a little before delving into more complex analyses.
#
# # Facets analysis
# # To conduct a DIF analysis, we set up the variable "gender" as a facet and
# # re-run the IRT analysis.
# formulaA <- ~item+gender+item*gender # define facets analysis
# facets <- as.data.frame(gender) # data frame with student covariates
# # facets model for studying differential item functioning
# mod2 <- tam.mml.mfr( resp= scored[,items], facets= facets , formulaA = formulaA )
# summary(mod2)
# ## End(Not run)
Run the code above in your browser using DataLab