Learn R Programming

emIRT (version 0.0.14)

binIRT: Two-parameter Binary IRT estimation via EM

Description

binaryIRT estimates a binary IRT model with two response categories. Estimation is conducted using the EM algorithm described in the reference paper below. The algorithm will produce point estimates that are comparable to those of ideal, but will do so much more rapidly and also scale better with larger data sets.

Usage

binIRT(.rc, .starts = NULL, .priors = NULL, .D = 1L, .control = NULL,
  .anchor_subject = NULL, .anchor_outcomes = FALSE)

Value

An object of class binIRT.

means

list, containing several matrices of point estimates for the parameters corresponding to the inputs for the priors. The list should contain the following matrices.

x

A (N x 1) matrix of point estimates for the respondent ideal points \(x_i\).

beta

A (J x D+1 ) matrix of point estimates for the item parameters \(\alpha\) and \(\beta\).

vars

list, containing several matrices of variance estimates for parameters corresponding to the inputs for the priors. Note that these variances are those recovered via variational approximation, and in most cases they are known to be far too small and generally unusable. Better estimates of variances can be obtained manually via the parametric bootstrap. The list should contain the following matrices:

x

A (N x 1) matrix of variances for the respondent ideal points \(x_i\).

beta

A (J x D+1 ) matrix of variances for the item parameters \(\alpha\) and \(\beta\).

runtime

A list of fit results, with elements listed as follows:

iters

integer, number of iterations run.

conv

integer, convergence flag. Will return 1 if threshold reached, and 0 if maximum number of iterations reached.

threads

integer, number of threads used to estimated model.

tolerance

numeric, tolerance threshold for convergence. Identical to thresh argument in input to .control list.

n

Number of respondents in estimation, should correspond to number of rows in roll call matrix.

j

Number of items in estimation, should correspond to number of columns in roll call matrix.

d

Number of dimensions in estimation.

call

Function call used to generate output.

Arguments

.rc

a list object, in which .rc$votes is a matrix of numeric values containing the data to be scaled. Respondents are assumed to be on rows, and items assumed to be on columns, so the matrix is assumed to be of dimension (N x J). For each item, `1', and `-1' represent different responses (i.e. yes or no votes) with `0' as a missing data record.

.starts

a list containing several matrices of starting values for the parameters. The list should contain the following matrices:

alpha

A (J x 1) matrix of starting values for the item difficulty parameter \(alpha\).

beta

A (J x D) matrix of starting values for the item discrimination parameter \(\beta\).

x

An (N x D) matrix of starting values for the respondent ideal points \(x_i\).

.priors

list, containing several matrices of starting values for the parameters. The list should contain the following matrices:

x$mu

A (D x D) prior means matrix for respondent ideal points \(x_i\).

x$sigma

A (D x D) prior covariance matrix for respondent ideal points \(x_i\).

beta$mu

A (D+1 x 1) prior means matrix for \(\alpha_j\) and \(\beta_j\).

beta$sigma

A (D+1 x D+1) prior covariance matrix for \(\alpha_j\) and \(\beta_j\).

.D

integer, indicates number of dimensions to estimate. Only a 1 dimension is currently supported. If a higher dimensional model is requested, binIRT exits with an error.

.control

list, specifying some control functions for estimation. Options include the following:

threads

integer, indicating number of cores to use. Default is to use a single core, but more can be supported if more speed is desired.

verbose

boolean, indicating whether output during estimation should be verbose or not. Set FALSE by default.

thresh

numeric. Algorithm will run until all parameters have a correlation greater than (1 - threshold) across consecutive iterations. Set at 1e-6 by default.

maxit

integer. Sets the maximum number of iterations the algorithm can run. Set at 500 by default.

checkfreq

integer. Sets frequency of verbose output by number of iterations. Set at 50 by default.

asEM

boolean. Sets EM or variational EM algorithm. Set is TRUE.

.anchor_subject

integer, the index of the subect to be used in anchoring the orientation/polarity of the underlying latent dimensions. Defaults to NULL and no anchoring is done.

.anchor_outcomes

logical, should an outcomes-based metric be used to anchor the orientation of the underlying space. The outcomes-based anchoring uses a model-free/non-parametric approximation to quantify each item's difficulty and each subject's ability. The post-processing then rotates the model-dependent results to match the model-free polarity. Defaults to FALSE and no anchoring is done.

Author

Kosuke Imai imai@harvard.edu

James Lo lojames@usc.edu

Jonathan Olmsted jpolmsted@gmail.com

References

Kosuke Imai, James Lo, and Jonathan Olmsted ``Fast Estimation of Ideal Points with Massive Data.'' Working Paper. American Political Science Review, Vol. 110, No. 4 (December), pp. 631-656.

See Also

'convertRC', 'makePriors', 'getStarts'.

Examples

Run this code

## Data from 109th US Senate
data(s109)

## Convert data and make starts/priors for estimation
rc <- convertRC(s109)
p <- makePriors(rc$n, rc$m, 1)
s <- getStarts(rc$n, rc$m, 1)

## Conduct estimates
lout <- binIRT(.rc = rc,
                .starts = s,
                .priors = p,
                .control = {
                    list(threads = 1,
                         verbose = FALSE,
                         thresh = 1e-6
                         )
                }
                )

## Look at first 10 ideal point estimates
lout$means$x[1:10]


lout2 <- binIRT(.rc = rc,
                .starts = s,
                .priors = p,
                .control = {
                    list(threads = 1,
                         verbose = FALSE,
                         thresh = 1e-6
                         )
                },
                .anchor_subject = 2
                )
                                        # Rotates so that Sen. Sessions (R AL)
                                        # has more of the estimated trait

lout3 <- binIRT(.rc = rc,
                .starts = s,
                .priors = p,
                .control = {
                    list(threads = 1,
                         verbose = FALSE,
                         thresh = 1e-6
                         )
                },
                .anchor_subject = 10
                )
                                        # Rotates so that Sen. Boxer (D CA)
                                        # has more of the estimated trait

cor(lout2$means$x[, 1],
    lout3$means$x[, 1]
    )
                                        # = -1 --> same numbers, flipped
                                        # orientation

Run the code above in your browser using DataLab