Pr <- function(theta, it, D=1) {
a <- it[,1]
b <- it[,2]
c <- it[,3]
e <- exp(D * a * (theta - b))
c + (1 - c) * e/(1 + e)
}
### Set parameters to be mapped over
theta <- seq(-3.5,3.5,.1)
require(ggplot2)
### Plotting Item response functions
cfix=0
afix=1
presp <- data.frame(theta=rep(theta,3),
prob=c(Pr(theta, cbind(afix, -2, c=cfix)),
Pr(theta, cbind(afix, 0, c=cfix)),
Pr(theta, cbind(afix, 2, c=cfix))),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(presp,aes(x=theta, y=prob, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information response function when c=",cfix, " and a=", afix)) +
xlab(expression(theta))

### Plotting Item response functions
cfix=.2
afix=2
presp <- data.frame(theta=rep(theta,3),
prob=c(Pr(theta, cbind(afix, -2, c=cfix)),
Pr(theta, cbind(afix, 0, c=cfix)),
Pr(theta, cbind(afix, 2, c=cfix))),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(presp,aes(x=theta, y=prob, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information response function when c=",cfix, " and a=", afix)) +
xlab(expression(theta))

# Item information with regards to the estimate of person
# is a well known equation.
Itheta <- function(theta=theta, a=1,b=0,c=0, D=1) {
pi <- Pr(theta=theta, it=cbind(a,b,c),D)
a^2 * (pi-c)^2 * (1-pi) / ((1-c)^2*pi)
}
# Calculate the information about each item parameter
Ia <- function(theta=theta, a=1,b=0,c=0, D=1) {
pi <- Pr(theta=theta, it=cbind(a,b,c),D)
D^2/(1-c)^2*(theta-b)^2*(pi-c)^2*(1-pi)/pi
}
Ib <- function(theta=0, a=1,b=0,c=0, D=1) {
pi <- Pr(theta=theta, it=cbind(a,b,c),D)
(D*a*(pi-c)/(1-c))^2*(1-pi)/pi
}
Ic <- function(theta=0, a=1,b=0,c=0, D=1) {
pi <- Pr(theta=theta, it=cbind(a,b,c),D)
1/(1-c)^2*(1-pi)/pi
}
# Let's see these item information functions mapped out
### ---- Map out item information for latent ability theta
cfix=0
afix=1
ainfo <- data.frame(theta=rep(theta,3),
information=c(Itheta(theta, b=-2, a=afix, c=cfix),
Itheta(theta, b=0 , a=afix,c=cfix),
Itheta(theta, b=2 , a=afix,c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(ainfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for a when c=",cfix, " and a=", afix)) +
xlab(expression(theta))
### ---- Map out item information for latent ability theta
cfix=0
afix=2
ainfo <- data.frame(theta=rep(theta,3),
information=c(Itheta(theta, b=-2, a=afix, c=cfix),
Itheta(theta, b=0 , a=afix,c=cfix),
Itheta(theta, b=2 , a=afix,c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(ainfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for a when c=",cfix, " and a=", afix)) +
xlab(expression(theta))
### ---- Map out item information for latent ability theta
cfix=.5
afix=1
ainfo <- data.frame(theta=rep(theta,3),
information=c(Itheta(theta, b=-2, a=afix, c=cfix),
Itheta(theta, b=0 , a=afix,c=cfix),
Itheta(theta, b=2 , a=afix,c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(ainfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for a when c=",cfix, " and a=", afix)) +
xlab(expression(theta))
### ---- Map out item information for parameter a
# c=0
cfix=0
ainfo <- data.frame(theta=rep(theta,3),
information=c(Ia(theta, b=-2, c=cfix),
Ia(theta, b=0 , c=cfix),
Ia(theta, b=2 , c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(ainfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for a when c=",cfix)) +
xlab(expression(theta))
### ---- Map out item information for parameter a
# c=0.15
cfix=.15
ainfo <- data.frame(theta=rep(theta,3),
information=c(Ia(theta, b=-2, c=cfix),
Ia(theta, b=0 , c=cfix),
Ia(theta, b=2 , c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(ainfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for parameter a when c=",cfix)) +
xlab(expression(theta))
### ---- Map out item information for parameter b
# c=0
cfix=0
binfo <- data.frame(theta=rep(theta,3),
information=c(Ib(theta, b=-2, c=cfix),
Ib(theta, b=0 , c=cfix),
Ib(theta, b=2 , c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(binfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for parameter b when c=",cfix)) +
xlab(expression(theta))
### ---- Map out item information for parameter b
# c=0.15
cfix=.15
binfo <- data.frame(theta=rep(theta,3),
information=c(Ib(theta, b=-2, c=cfix),
Ib(theta, b=0 , c=cfix),
Ib(theta, b=2 , c=cfix)),
b=rep(c(-2,0,2),each=length(theta)))
ggplot(binfo,aes(x=theta, y=information, group=b, colour = b))+
geom_line(size=2) +
ggtitle(paste0("Information function for parameter b when c=",cfix)) +
xlab(expression(theta))
### ---- Map out item information for parameter c
# a=1, b=0
afix=1
bfix=0
cinfo <- data.frame(theta=rep(theta,3),
information=c(Ic(theta, c=.15 , a=afix),
Ic(theta, c=.3 , a=afix),
Ic(theta, c=.45 , a=afix)),
c=rep(c(.15,.3,.45),each=length(theta)))
ggplot(cinfo,aes(x=theta, y=information, group=c, colour = c))+
geom_line(size=2) +
ggtitle(
paste0("Information function for parameter c when a=",afix, " and b=", bfix)) +
xlab(expression(theta))
### ---- Map out item information for parameter c
# a=2, b=0
afix=2
bfix=0
cinfo <- data.frame(theta=rep(theta,3),
information=c(Ic(theta, c=.15 , a=afix),
Ic(theta, c=.3 , a=afix),
Ic(theta, c=.45 , a=afix)),
c=rep(c(.15,.3,.45),each=length(theta)))
ggplot(cinfo,aes(x=theta, y=information, group=c, colour = c))+
geom_line(size=2) +
ggtitle(
paste0("Information function for parameter c when a=",afix, " and b=", bfix)) +
xlab(expression(theta))