library(ltm) library(mirt) data <- read.csv("neuroticism500.csv", header = T, row.names = 1) head(data) ######################### # Graded response model # ######################### # Fit Graded Response Model using library ltm in R. # Provide table with discrimination and location parameters for each item. ?grm (fit.grm2 <- grm(data)) summary(fit.grm2) coef(fit.grm2) # using mirt library fit.grm2.mirt <- mirt(data, 1, itemtype = "graded") coef(fit.grm2.mirt, simplify = T) # Fit 1PL version of Graded Response Model (with equal discriminations for all items). # Provide table with discrimination and location parameters for each item. (fit.grm1 <- grm(data, constrained = TRUE)) coef(fit.grm1) # s mirtem s <- 'F = 1-5 CONSTRAIN = (1-5, a1)' s <- mirt.model(s) fit.grm1.mirt <- mirt(data, s, itemtype = "graded") coef(fit.grm1.mirt, simplify = T) # Use some criteria to decide between these two models. anova(fit.grm1, fit.grm2) # using mirt library anova(fit.grm1.mirt, fit.grm2.mirt) # Plot Category Response Curves for all items (provide 5 figures) par(mfrow = c(2, 3)) plot(fit.grm2) par(mfrow = c(1, 1)) # using mirt plot(fit.grm2.mirt, type = "trace") plot(fit.grm2.mirt, type = "trace", facet_items = F) # Looking at the figures, suggest at least one response category in at least one item # that might be good to merge with another category. # Plot Item Information Curves, preferably all in one plot. plot(fit.grm2, type = "IIC", items = NULL) # Which item is the most informative for average respondent? # using mirt plot(fit.grm2.mirt, type = "infotrace", facet_items = F) # Plot Test information Function. plot(fit.grm2, type = "IIC", items = 0) # For what type of respondents is the instrument most informative? # using mirt plot(fit.grm2.mirt, type = "info") # Provide table with response patterns, estimated latent trait scores (factor scores) # and their standard errors for first 10 respondents. factor.scores(fit.grm2, resp.patterns = data)$score.dat[1:10, ] ########################################### # Generalized Partial Credit Model (GPCM) # ########################################### # Fit Generalized Partial Credit Model using library ltm in R. # Provide table with discrimination and location parameters for each item. ?gpcm (fit.gpcm <- gpcm(data, constraint = "gpcm")) summary(fit.gpcm) coef(fit.gpcm) # using mirt fit.gpcm.mirt <- mirt(data, 1, itemtype = "gpcm") coef(fit.gpcm.mirt, simplify = T) # Fit 1PL version of Generalized Partial Credit Model # (with equal discriminations for all items). # Provide table with discrimination and location parameters for each item. (fit.gpcm1pl <- gpcm(data, constraint = "1PL")) coef(fit.gpcm1pl) # using mirt s <- 'F = 1-5 CONSTRAIN = (1-5, a1)' s <- mirt.model(s) fit.gpcm1pl.mirt <- mirt(data, s, itemtype = "gpcm") coef(fit.gpcm1pl.mirt, simplify = T) # Use some criteria to decide between these two models. anova(fit.gpcm1pl, fit.gpcm) # using mirt anova(fit.gpcm1pl.mirt, fit.gpcm.mirt) # Plot Category Response Curves for all items (in 5 figures). par(mfrow = c(2, 3)) plot(fit.gpcm) par(mfrow = c(1, 1)) # using mirt plot(fit.gpcm.mirt, type = "trace") plot(fit.gpcm.mirt, type = "trace", facet_items = F) # Plot Item Information Curves, preferably all in one plot. plot(fit.gpcm, type = "IIC", items = NULL) # using mirt plot(fit.gpcm.mirt, type = "infotrace", facet_items = F) # Plot Test information Function. plot(fit.gpcm, type = "IIC", items = 0) # s mirtem plot(fit.gpcm.mirt, type = "info") # Use some criteria to decide between GRM and GPCM. AIC(fit.grm2) AIC(fit.gpcm) BIC(fit.grm2) BIC(fit.gpcm) ################# # Nominal model # ################# # using mirt fit.nomi.mirt <- mirt(data, 1, itemtype = "nominal") coef(fit.nomi.mirt, simplify = T) # ICC plot(fit.nomi.mirt, type = "trace") plot(fit.nomi.mirt, type = "trace", facet_items = F) # IIC plot(fit.nomi.mirt, type = "infotrace", facet_items = F) # TIF plot(fit.nomi.mirt, type = "info")