Learn R Programming

ltbayes (version 0.3)

fmodel3pp: Latent Trait Posterior of the Three-Parameter Binary Probit Model

Description

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

Usage

fmodel3pp(zeta, y, apar, bpar, cpar, 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
apar
Vector of m "discrimination" parameters.
bpar
Vector of m "difficulty" parameters.
cpar
Vector of m lower asymptote (i.e., "guessing") 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.

Value

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

Details

The item response model is parameterized as $$P(Y_{ij} = 1|\zeta_i) = \gamma_j + (1 - \gamma_j) \Phi(-\alpha_j(\zeta_i - \beta_j)),$$ where $\Phi$ is the distribution function of a standard normal distribution, $\alpha_j$ is the discrimination parameter (apar), $\beta_j$ is the difficulty parameter (bpar), $0 \le \gamma_j < 1$ is the lower asymptote parameter (cpar), and $\zeta_i$ is the latent trait (zeta).

See Also

See fmodel1pp, fmodel2pp, and fmodel4pp for related models, and fmodel3pl for a logit variant of this model.

Examples

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

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

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

information(fmodel3pp, c(1,1,0,0,0), 
	apar = alph, bpar = beta, cpar = gamm) # Fisher information

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

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

Run the code above in your browser using DataLab