Learn R Programming

ltbayes (version 0.3)

postmode: Posterior Mode of the Posterior Distribution of the Latent Trait of an Item Response Model

Description

postmode numerically computes the posterior mode for a specified posterior distribution of the latent of an item response model.

Usage

postmode(fmodel, y, zmin = -5, zmax = 5, ...)

Arguments

fmodel
Function with first argument zeta which returns a list of the (unnormalized) natural logarithm of the posterior distribution evaluted at zeta and a m by r matrix of item category response probabilities. These must be named post and prob, respectively. The posterior should assume an (improper) uniform prior for zeta, and will impose this proper if fmodel has a prior argument.
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.
zmin
Minimum value of $\zeta$ to use in searching for the mode.
zmax
Maximum value of $\zeta$ to use in searching for the mode.
...
Additional arguments to pass to fmodel or optimize.

Value

zeta
The value of $\zeta$ that maximizes the posterior distribution.
post
The value of the log-posterior distribution at the mode.

Warning

Finding the mode is not guaranteed. Inspection of the profile of the posterior (perhaps by using posttrace) is recommended to verify that zmin and zmax are set appropriately. Problems can arise for posterior distributions that are multimodal or where no (finite) mode exists.

Details

This is basically wrapper for optimize to find the maximum of a log-posterior or log-likelihood function of a latent trait. Note that this is the MAP estimator, and also the MLE if the prior distribution is uniform.

See Also

See optimize for information on using this function.

Examples

Run this code
alph <- c(1.27,1.34,1.14,1,0.67)   # discrimination parameters
beta <- c(1.19,0.59,0.15,-0.59,-2) # difficulty parameters
gamm <- c(0.1,0.15,0.15,0.2,0.01)  # lower asymptote parameters

# MAP estimate given a sum score of 3
postmode(fmodel3pl, patterns(5, 2, 3), apar = alph, bpar = beta, cpar = gamm)

# MLE given a sum score of 3
postmode(fmodel3pl, patterns(5, 2, 3), apar = alph, bpar = beta, cpar = gamm,
	prior = function(z) 1)

Run the code above in your browser using DataLab