Learn R Programming

ltbayes (version 0.3)

fmodelpcm: 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. Element
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.

Value

  • postThe log of the unnormalized posterior distribution evaluated at zeta.
  • probMatrix of size m by 2 array of item response probabilities.

Details

The parameterization of the partial credit model used here is $$P(Y_{ij} = y|\zeta_i) \propto \exp(y\zeta_i - \sum_{k=0}^y\beta_{jk})$$ for $y = 0, 1,\dots, r-1$ where $\beta_{j0} = 0$. The $\beta_{jk}$ are the item "difficulty" parameters and $\zeta_i$ is the latent trait. This model was proposed by Masters (1982).

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

Run this code
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

Run the code above in your browser using DataLab