knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
knitr::opts_chunk$set(echo = TRUE)
library(lavaan)
library(semPlot)

Item Response Theory

Categorical Options

Item Response Theory

Issues

Item Response Theory

Item Response Theory

knitr::include_graphics("pictures/icc_example.png")

Item Response Theory

knitr::include_graphics("pictures/item_difficulty.png")

Item Response Theory

knitr::include_graphics("pictures/ability.png")

Item Response Theory

knitr::include_graphics("pictures/ability.png")

Item Response Theory

Polytomous IRT

Polytomous IRT

Polytomous IRT

Polytomous IRT

Polytomous IRT

IRT Examples

library(ltm)
library(mirt)
data(LSAT)
head(LSAT)

Two Parameter Logistic

# Data frame name ~ z1 for one latent variable
#irt.param to give it to you standardized
LSAT.model <- ltm(LSAT ~ z1,
                  IRT.param = TRUE)

2PL Output

coef(LSAT.model)

2PL Plots

plot(LSAT.model, type = "ICC") ## all items at once

2PL Plots

plot(LSAT.model, type = "IIC", items = 0) ## Test Information Function

2PL Other Options

factor.scores(LSAT.model)

Three Parameter Logistic

LSAT.model2 <- tpm(LSAT, #dataset
                   type = "latent.trait",
                   IRT.param = TRUE)

3PL Output

coef(LSAT.model2)

3PL Plots

plot(LSAT.model2, type = "ICC") ## all items at once

3PL Plots

plot(LSAT.model2, type = "IIC", items = 0) ## Test Information Function

3PL Other Options

factor.scores(LSAT.model2)

Compare Models

anova(LSAT.model, LSAT.model2)

Polytomous IRT

library(rio)
poly.data <- import("data/lecture_irt.csv")
poly.data <- na.omit(poly.data)

#reverse code
poly.data$Q99_9 = 8 - poly.data$Q99_9

#separate factors
poly.data1 = poly.data[ , c(1, 4, 5, 6, 9)]
poly.data2 = poly.data[ , c(2, 3, 7, 8, 10)]

Graded Partial Credit Model

gpcm.model1 <- mirt(data = poly.data1, #data
                    model = 1, #number of factors
                    itemtype = "gpcm") #poly model type

GPCM Output

summary(gpcm.model1) ##standardized coefficients 

GPCM Output

coef(gpcm.model1, IRTpars = T) ##coefficients

head(fscores(gpcm.model1)) ##factor scores

GPCM Plots

plot(gpcm.model1, type = "trace") ##curves for all items at once
itemplot(gpcm.model1, 5, type = "trace")

GPCM Plots

itemplot(gpcm.model1, 4, type = "info") ##IIC for each item
plot(gpcm.model1, type = "info") ##test information curve

GPCM Plots

plot(gpcm.model1) ##expected score curve

Summary



doomlab/learnSEM documentation built on Jan. 25, 2024, 2 p.m.