postsamp: MCMC Simulation from the Posterior Distribution of the Latent...

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

Description

postsamp implements Markov chain Monte Carlo (MCMC) algorithms to simulate realizations from the posterior distribution of the latent trait of an item response model. The distribution is conditional on a single response vector or a subset of response vectors.

Usage

1
postsamp(fmodel, y, method = "metrop", control = list(), ...)

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

A m-dimensional vector or a s by m matrix of item responses, where in the latter case the posterior is computed by conditioning on the event that the response pattern is one of the s response patterns in y. .

method

The sampler used. Currently the options are a random-walk Metropolis sampler (method = 'metrop') or an adaptive random-walk Metropolis sampler (method = 'adapt'). Both samplers use a normal proposal distribution. The default is method = 'mcmc'.

control

List of options for the sampler. See the help file for the sampler used for details. For method = 'metrop' see metrop and for method = 'adapt' see Metro_Hastings.

...

Additional arguments to be pased to fmodel.

Details

This function uses MCMC samplers from the mcmc and MHadaptive packages, using the functions metrop and Metro_Hastings for random-walk (method = 'metrop') and adaptive random-walk (method = 'adapt') Metropolis samplers, respectively. Default options are used by postsamp except that the default burn-in samples is set to zero and the number of samples is set to 1000.

Value

out

List of the output from the sampler. See the help file for the sampler specified in method for details.

Warning

Sampling from the posterior distribution of the latent trait of an item response model typically exhibits quick convergence and efficient mixing. However as with any MCMC algorithm it is important to check the performance of the algorithm. In some cases adjustment of the scale of the proposal density may be necessary to achieve a suitable acceptance rate.

Author(s)

Timothy R. Johnson

See Also

See metrop and Metro_Hastings for details on the samplers.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# simulating 10000 realizations from the posterior distribution from
# a partial credit model using a non-adaptive Metropolis algorithm
zeta <- postsamp(fmodelpcm, c(0,1,2,1,0), bpar = matrix(0, 5, 2),
   control = list(nbatch = 10000))
plot(zeta$batch, type = "l") # trace plot

# simulating 10000 realizations from the posterior distribution from
# a partial credit model using an adaptive Metropolis algorithm
zeta <- postsamp(fmodelpcm, c(0,1,2,1,0), bpar = matrix(0, 5, 2),
   control = list(iterations = 10000), method = 'adapt')
plot(zeta$trace, type = "l") # trace plot

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

Related to postsamp in ltbayes...