Learn R Programming

ltbayes (version 0.3)

fmodelnrm: Latent Trait Posterior of the Nominal Response Model

Description

fmodelnrm evaluates the (unnormalized) posterior density of the latent trait of the nominal response model with given prior distribution, and computes the probabilities for each item and response category given the latent trait.

Usage

fmodelnrm(zeta, y, apar, bpar, prior = dnorm, ...)

Arguments

zeta
Latent trait value.
y
Matrix of size s by m of response patterns such that the posterior is computed by conditioning on the event that the response pattern is one of the s response patterns. For conditioning on a single response pattern s = 1 and so the matrix is 1 by m. Eleme
apar
Matrix of size m by r of "slope" parameters.
bpar
Matrix of size m by r of "intercept" 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 the prior distribution.

Value

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

Details

The nominal response model is parameterized here as $$P(Y_{ij} = y|\zeta_i) \propto \exp(\alpha_{jy}\zeta_i + \beta_{jy})$$ where $Y_{ij} = 0, 1,\dots,r-1$ and $\alpha_{jk}$ and $\beta_{jk}$ are the "slope" (apar) and "intercept" (bpar) parameters, respectively. The nominal response model is also sometimes called the nominal categories model and was first proposed by Bock (1972).

References

Bock, R. D. (1972). Estimating item parameters and latent ability when responses are scored in two or more nominal categories. Psychometrika, 37, 29-51.

Examples

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

alph <- matrix(c(-1, 0, 1), 5, 3, byrow = TRUE)
beta <- matrix(0, 5, 3)

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

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

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

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

Run the code above in your browser using DataLab