R: Latent Trait Posterior for the Partial Credit Model
fmodelpcm
R Documentation
Latent Trait Posterior for the Partial Credit Model
Description
fmodelpcm evaluates the (unnormalized) posterior density of the latent trait of a partial credit item response model with a given prior distribution, and computes the probability for each item and response category given the latent trait.
Usage
fmodelpcm(zeta, y, bpar, prior = dnorm, ...)
Arguments
zeta
Latent trait value.
y
Vector of length m for a single response pattern, or matrix of size s by m of a set of s item response patterns. In the latter case the posterior is computed by conditioning on the event that the response pattern is one of the s response patterns. Elements of y should be integers from 0 to r-1 where r is the number of response categories.
bpar
Matrix of size m by r-1 of "difficulty" parameters.
prior
Function that evaluates the prior distribution of the latent trait. The default is the standard normal distribution.
...
Additional arguments to be passed to prior.
Details
The parameterization of the partial credit model used here is
for y = 0, 1,…, r-1 where β_{j0} = 0. The β_{jk} are the item "difficulty" parameters and ζ_i is the latent trait. This model was proposed by Masters (1982).
Value
post
The log of the unnormalized posterior distribution evaluated at zeta.
prob
Matrix of size m by 2 array of item response probabilities.
Note
The number of response categories (r) is inferred from the number of columns in bpar, not from the maximum value in y.
Author(s)
Timothy R. Johnson
References
Masters, G. N. (1982). A Rasch model for partial credit scoring. Psychometrika, 47, 149-174.
See Also
For the rating scale model as a special case use the function fmodelrsm.
Examples
samp <- 5000 # samples from posterior distribution
burn <- 1000 # burn-in samples to discard
beta <- matrix(0, 5, 2)
post <- postsamp(fmodelpcm, c(0,1,2,1,0), bpar = beta,
control = list(nbatch = samp + burn))
post <- data.frame(sample = 1:samp,
zeta = post$batch[(burn + 1):(samp + burn)])
with(post, plot(sample, zeta), type = "l") # trace plot of sampled realizations
with(post, plot(density(zeta, adjust = 2))) # density estimate of posterior distribution
with(posttrace(fmodelpcm, c(0,1,2,1,0), bpar = beta),
plot(zeta, post, type = "l")) # profile of log-posterior density
information(fmodelpcm, c(0,1,2,1,0), bpar = beta) # Fisher information
with(post, mean(zeta)) # posterior mean
postmode(fmodelpcm, c(0,1,2,1,0), bpar = beta) # posterior mode
with(post, quantile(zeta, probs = c(0.025, 0.975))) # posterior credibility interval
profileci(fmodelpcm, c(0,1,2,1,0), bpar = beta) # profile likelihood confidence interval