R code used for Simulations
# libraries that may be useful
             library(mirt)
library(dplyr)
library(ggplot2)
library(ggformula)
library(supernova)
library(lsr)
library(mosaic)
library(Lock5Data)
library(Lock5withR)
library(okcupiddata)
library(dslabs)
library(fivethirtyeight)
library(mirtCAT)
########################
# Define Item Parameters
########################
a <- matrix(c(4.72,3.93,3.79,4.29),ncol=1,byrow=TRUE)
d <- matrix(c(9.37,7.23,5.16,2.00,7.46,5.89,4.11,1.53,7.22,6.02,4.57,2.59,11.24,8.70,6.40,3.58),ncol=4,byrow=TRUE)

pars <- data.frame(a1=a, d=d)
colnames(pars) <- c('a1', paste0('d', 1:4))
head(pars)

#########################
# turn into mirt Object
#########################
obj <- generate.mirt_object(pars, 'graded')
coef(obj, simplify = TRUE)

#######################################
# Generate Data with a baseline theta
#########################################
BaseTheta <- matrix(?, 10000,1)  #True theta, N=10,000 cases
BaseDat <- simdata(a, d, 10000, itemtype = 'graded', Theta=BaseTheta, mins=1)
head(BaseDat)

###############################################################
### Estimate Factor Scores
###############################################################
BaseScores <- fscores(obj, method="EAP", response.pattern = BaseDat)
head(BaseScores,10)
tail(BaseScores,10)
dim(BaseScores)

###############################################################
hist(BaseScores[,5], xlim=c(-3,3), main="True Theta = ?", xlab="EAP Estimated Theta")