Learn R Programming

ltbayes (version 0.3)

fmodelgrl: Latent Trait Posterior of the Logistic Graded Response Model

Description

fmodelgrl evaluates the (unnormalized) posterior density of the latent trait of a logistic graded response model with a given prior distribution, and computes the probability for each item and response category given the latent trait.

Usage

fmodelgrl(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. Element
apar
Vector of length m of "discrimination" parameters.
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 graded response model used here is $$P(Y_{ij} \ge y|\zeta_i) = 1/(1 + \exp(-\alpha_j(\zeta_i-\beta_{jy})))$$ for $y = 1,\dots,r-1$, where $\alpha_j$ and $\beta_{jk}$ are the "discrimination" and "difficulty" parameters, respectively, for the k-th cumulative item response function. Note that the difficulty parameters must meet the constraint that $\beta_{j,k+1} \ge \beta_{jk}$ for $k = 1,\dots,r-1$ so that all item response probabilities are non-negative. This model was first proposed by Samejima (1969, 1972).

References

Samejima, F. (1969). Estimation of ability using a response pattern of graded scores. Psychometrikka Monograph, No. 17. Samejima, F. (1972). A general model for free-response data. Psychometrika Monograph, No. 18.

See Also

See fmodelgrp for the probit variant of this model.

Examples

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

alph <- rep(1, 3)                           # discrimination parameters
beta <- matrix(c(-1,1), 3, 2, byrow = TRUE) # difficulty parameters

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

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

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

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

Run the code above in your browser using DataLab