library(mirt)
# convert nominal data to integers and the original labels with correct answers
data_with_key <- nominal_to_int(HCItest[, 1:20], HCIkey)
# build model definition for {mirt} using the returned list from above
nrm_def <- obtain_nrm_def(data_with_key)
# fit the nominal model using the obtained model definition in `pars` argument
fit <- mirt(data_with_key$Data, 1, "nominal", pars = nrm_def)
Run the code above in your browser using DataLab