posttrace: Trace the Profile of the Log-Posterior Distribution of the...

Description Usage Arguments Details Value Note Author(s) See Also Examples

Description

posttrace computes the (unnormalized) log-posterior distribution of the latent trait of an item response model in a given interval.

Usage

1
2
posttrace(fmodel, y, zeta = seq(zmin, zmax, length = length), 
   zmin = -3, zmax = 3, length = 100, ...)

Arguments

fmodel

Function with first argument zeta which returns a list of the (unnormalized) natural logarithm of the posterior distribution evaluted at zeta. This must be returned as a list with the named object post.

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.

zeta

Vector of values of the latent trait at which to compute the log-posterior density. By default this is a sequence of length values from zmin to zmax.

zmin

Minimum value of the latent trait at which to compute the log-posterior density.

zmax

Maximum value of the latent trait at which to compute the log-posterior density.

length

Length of vector of latent trait values between zmin and zmax.

...

Additional arguments to be passed to fmodel.

Details

The primary purpose of this function is in preparing data for plotting the profile of the posterior density or likelihood (if the prior is uniform) for the latent trait. This can be useful for visual inspection of the profile posterior/liklelihood for modes and curvature.

Value

zeta

Returns the argument zeta.

post

The log-posterior density at each each value of zeta.

Note

Note that the posterior is the unnormalized posterior distribution. The normalized posterior distribution can be approximated by a density estimate based on a sample of realizations generated using postsamp.

Author(s)

Timothy R. Johnson

See Also

See postsamp for simulating realizations from the posterior distribution to use to estimate the normalized posterior density.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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

# profile of log-likelihood distribution given a sum score of 3
tmp <- posttrace(fmodel3pl, patterns(5, 2, 3), apar = alph, bpar = beta, cpar = gamm,
	prior = function(z) 1)
with(tmp, plot(zeta, post, type = "l"))

# profile of log-posterior distribution (normal prior) given a sum score of 3
tmp <- posttrace(fmodel3pl, patterns(5, 2, 3), apar = alph, bpar = beta, cpar = gamm)
with(tmp, plot(zeta, post, type = "l"))

Example output

Loading required package: mcmc
Loading required package: MHadaptive
Loading required package: MASS
Loading required package: numDeriv

ltbayes documentation built on May 2, 2019, 12:40 p.m.

Related to posttrace in ltbayes...