MCMCirtKdHet {MCMCpack} | R Documentation |
This function generates a sample from the posterior distribution of a heteroskedastic K-dimensional item response theory (IRT) model, with standard normal priors on the subject abilities (ideal points), normal priors on the item parameters, and inverse-gamma priors on subject error variances. To maintain identification and comparability with results of the homoskedastic estimator, the mean root subject error precision is constrained to one. The user supplies data and priors, and a sample from the posterior distribution is returned as an mcmc object, which can be subsequently analyzed with functions provided in the coda package.
MCMCirtKdHet(datamatrix, dimensions, item.constraints = list(), burnin = 1000, mcmc = 1000, thin = 1, verbose = 0, seed = NA, alphabeta.start = NA, b0 = 0, B0 = 0.04, c0 = 0, d0 = 0, store.item = FALSE, store.ability = TRUE, store.sigma = TRUE, drop.constant.items = TRUE)
datamatrix |
The matrix of data. Must be 0, 1, or NA. It is of dimensionality subjects by items. |
dimensions |
The number of dimensions in the latent space. |
item.constraints |
List of lists specifying possible equality
or simple inequality constraints on the item parameters. A typical
entry in the list has one of three forms: |
burnin |
The number of burn-in iterations for the sampler. |
mcmc |
The number of iterations for the sampler. |
thin |
The thinning interval used in the simulation. The number of iterations must be divisible by this value. |
verbose |
A switch which determines whether or not the progress of
the sampler is printed to the screen. If |
seed |
The seed for the random number generator. If NA, the Mersenne
Twister generator is used with default seed 12345; if an integer is
passed it is used to seed the Mersenne twister. The user can also
pass a list of length two to use the L'Ecuyer random number generator,
which is suitable for parallel computation. The first element of the
list is the L'Ecuyer seed, which is a vector of length six or NA (if NA
a default seed of |
alphabeta.start |
The starting values for the
alpha and beta difficulty and
discrimination parameters. If |
b0 |
The prior means of the alpha and beta difficulty and discrimination parameters, stacked for all items. If a scalar is passed, it is used as the prior mean for all items. |
B0 |
The prior precisions (inverse variances) of the independent normal prior on the item parameters. Can be either a scalar or a matrix of dimension (K+1) x items. |
c0 |
The first parameter of the inverse gamma prior on the subject-specific variance parameters. This can be thought of as the number of bills that the prior information is equivalent to. This scalar value is common across all subjects (legislators) and defaults to an uninformative prior. NOTE: regardless of the value provided, identification is provided by a constraint on the mean root subject specific variance. |
d0 |
The second parameter of the inverse gamma prior on the subject-specific variance parameters. This can be thought of as the sum of square error that the prior information is equivalent to. This scalar value is common across all subjects (legislators) and defaults to an uninformative prior. NOTE: regardless of the value provided, identification is provided by a constraint on the mean root subject specific variance. |
store.item |
A switch that determines whether or not to store the item parameters for posterior analysis. NOTE: In applications with many items this takes an enormous amount of memory. If you have many items and want to want to store the item parameters you may want to thin the chain heavily. By default, the item parameters are not stored. |
store.ability |
A switch that determines whether or not to store the subject abilities for posterior analysis. NOTE: In applications with many subjects this takes an enormous amount of memory. If you have many subjects and want to want to store the ability parameters you may want to thin the chain heavily. By default, the ability parameters are all stored. |
store.sigma |
A switch that determines whether or not to store the subject-specific variances for posterior analysis. NOTE: In applications with many subjects this takes an enormous amount of memory. If you have many subjects and want to want to store the ability parameters you may want to thin the chain heavily. By default, the subject-specific variance parameters are all stored. |
drop.constant.items |
A switch that determines whether or not items that have no variation should be deleted before fitting the model. Default = TRUE. |
An mcmc object that contains the posterior sample. This object can be summarized by functions provided by the coda package.
Benjamin E. Lauderdale, blauderd@princeton.edu, http://www.princeton.edu/~blauderd/.
Modified from MCMCirtKd
and MCMCordfactanal
. Suggestions for additional options are welcome.
Benjamin E. Lauderdale. 2010. “Unpredictable Voters in Ideal Point Estimation” Political Analysis. 18: 151-171.
plot.mcmc
,summary.mcmc
,
MCMCirtKd
## Not run: data(Senate) Y <- as.matrix(Senate[,6:677]) Hompost <- MCMCirtKd(Y,1,b0=0,B0=0.04,burn=1000,mcmc=1000,thin=1,verbose=250) Hetpost <- MCMCirtKdHet(Y,1,b0=0,B0=0.04,burn=1000,mcmc=1000,thin=1,verbose=250) SenatorNames <- Senate[,5] HomoskedasticIdealPointEstimates <- colMeans(Hompost)[1:102] HeteroskedasticIdealPointEstimates <- colMeans(Hetpost)[1:102] HeteroskedasticSigmaEstimates <- colMeans(Hetpost)[103:204] plot(HomoskedasticIdealPointEstimates, HeteroskedasticIdealPointEstimates, cex= HeteroskedasticSigmaEstimates,xlab="Ideal Points (Homoskedastic)", ylab="Ideal Points (Heteroskedastic)", main="Comparison of Ideal Point Estimates for the 106th Senate", xlim=c(-2.5,2.5),ylim=c(-2.5,2.5)) for (i in 1:102){ if (rank(-HeteroskedasticSigmaEstimates)[i] <= 10){ text(HomoskedasticIdealPointEstimates[i], HeteroskedasticIdealPointEstimates[i],SenatorNames[i], pos=3-sign(HomoskedasticIdealPointEstimates[i]),cex=0.75) } } legend(x="topleft",legend=c("Point sizes proportional to estimated legislator", "variance under heteroskedastic model.","Some legislators with large variance have", "more extreme estimated ideal points under the","heteroskedastic model because their", "deviations from the party line are attributable","to idiosyncrasy rather than moderation."),cex=0.5) ## End(Not run)