Last data update: 2014.03.03

R: Latent Trait Posterior of the Two-Parameter Binary Logistic...
fmodel2plR Documentation

Latent Trait Posterior of the Two-Parameter Binary Logistic Model

Description

fmodel2pl evaluates the (unnormalized) posterior density of the latent trait of a two-parameter binary logistic item response model with given prior distribution, and computes the probabilities for each item and response category given the latent trait.

Usage

fmodel2pl(zeta, y, apar, 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 0 or 1.

apar

Vector of m "discrimination" parameters.

bpar

Vector of m "difficulty" parameters.

prior

Function that evaluates the prior distribution of the latent trait. The default is a standard normal distribution.

...

Additional arguments to be passed to prior.

Details

The item response model is parameterized as

P(Y_{ij} = 1|ζ_i) = 1 / (1 + exp(-α_j(ζ_i - β_j))),

where α_j is the discrimination parameter (apar), β_j is the difficulty parameter (bpar), and ζ_i is the latent trait (zeta).

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

This function is designed to be called by other functions in the ltbayes package, but could be useful on its own. This function calls fmodel4pl since it is a special case.

Author(s)

Timothy R. Johnson

See Also

See fmodel1pl, fmodel3pl, and fmodel4pl for related models, and fmodel2pp for a probit variant of this model.

Examples

samp <- 5000 # samples from posterior distribution
burn <- 1000 # burn-in samples to discard

alph <- rep(1, 5)   # discrimination parameters
beta <- -2:2        # difficulty parameters

post <- postsamp(fmodel2pl, c(1,1,0,0,0), 
	apar = alph, 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(fmodel2pl, c(1,1,0,0,0), 
	apar = alph, bpar = beta),
	plot(zeta, post, type = "l")) # profile of log-posterior density

information(fmodel2pl, c(1,1,0,0,0), 
	apar = alph, bpar = beta) # Fisher information

with(post, mean(zeta)) # posterior mean
postmode(fmodel2pl, c(1,1,0,0,0), 
	apar = alph, bpar = beta) # posterior mode

with(post, quantile(zeta, probs = c(0.025, 0.975))) # posterior credibility interval
profileci(fmodel2pl, c(1,1,0,0,0), apar = alph, 
	bpar = beta) # profile likelihood confidence interval

Results