# use 'nlminb' as optimizer
tpm2 <- tpm(LSAT, control = list(optimizer = "nlminb"))
# the three parameter model with equal
# discrimination parameter across items
# fix the guessing parameter for the third item to zero
tpm3 <- tpm(LSAT, type = "rasch", constraint = cbind(3, 1, 0))
## Factor Scores for the two-parameter logistic model
factor.scores(tpm1)
#coef
coef(tpm1)
#fitted
fitted(tpm1)
#annova
annova(tpm1,tpm2)
#vcov
vcov(tpm1)
sqrt(diag(vcov(tpm1))) # standard errors under additive parameterization
#item-fit statistics for the three parameter model
item.fit(tpm1)
#person-fit statistics for the three parameter model
person.fit(tpm1)
#margins
margins(tpm1)
margins(tpm1, "three")
#factor score
factor.scores(tpm1)
#summary
summary(tpm1)
#Computes the residuals for vectors of response patterns
residuals(tpm1)
residuals(tpm1, order = FALSE)
# Cronbach's alpha for the LSAT data-set
# with a Bootstrap 95% CI
cronbach.alpha(LSAT, CI = TRUE) #without bootsrap
cronbach.alpha(LSAT, CI = TRUE, B = 500)
#plot tpm
## Compare the Item Characteristic Curves for the LSAT data,
## under the constraint Rasch model, the unconstraint Rasch model,
## and the three parameter model assuming equal discrimination
## across items
par(mfrow = c(2, 2))
pl1 <- plot(rasch(LSAT, constr = cbind(length(LSAT) + 1, 1)))
text(2, 0.35, "Rasch model\nDiscrimination = 1")
pl2 <- plot(rasch(LSAT))
text(2, 0.35, "Rasch model")
pl3 <- plot(tpm(LSAT, type = "rasch", max.guessing = 1))
text(2, 0.35, "Rasch model\nwith Guessing parameter")
## Compare the Item Characteristic Curves for Item 4
## (you have to run the above first)
plot(range(pl1[, "z"]), c(0, 1), type = "n", xlab = "Ability",
ylab = "Probability", main = "Item Characteristic Curves - Item 4")
lines(pl1[, c("z", "Item 4")], lwd = 2, col = "black")
lines(pl2[, c("z", "Item 4")], lwd = 2, col = "red")
lines(pl3[, c("z", "Item 4")], lwd = 2, col = "blue")
legend("right", c("Rasch model Discrimination = 1", "Rasch model",
"Rasch model with\nGuessing parameter"), lwd = 2, col = c("black",
"red", "blue"), bty = "n")