My code below for replication purposes. I’ve created a two parameter model using the ltm package. I’ve also used the factor.scores function to calculate a z1 value for each response, which is the second to last row in the “response_pattern” object below.
My question is, how can I extract the z1 value from response_pattern object so that it is a vector that I can use elsewhere? It should be a vector of length 12, one z1 for each response.
item1 <- cbind(1,0,1,0,1,1,0,0,0,0,1,0)
item2 <- cbind(0,0,0,1,0,1,0,1,0,0,1,0)
item3 <- cbind(1,0,1,0,1,1,0,1,1,0,0,0)
item4 <- cbind(0,0,1,1,0,1,0,0,0,1,1,1)
Items <- matrix(c(item1, item2, item3, item4), ncol=4)
library(ltm)
fit <- ltm(Items ~ z1) # two parameter IRT model
response_pattern <- factor.scores(fit, resp.patterns = Items, method = "EB", return.MIvalues = TRUE) #Gets a z score for each response
response_pattern
Thanks!
?stris one of the most useful tools in your R toolkit.