MCMCirtHier1d            package:MCMCpack            R Documentation

_M_a_r_k_o_v _C_h_a_i_n _M_o_n_t_e _C_a_r_l_o _f_o_r _H_i_e_r_a_r_c_h_i_c_a_l _O_n_e _D_i_m_e_n_s_i_o_n_a_l _I_t_e_m _R_e_s_p_o_n_s_e _T_h_e_o_r_y
_M_o_d_e_l, _C_o_v_a_r_i_a_t_e_s _P_r_e_d_i_c_t_i_n_g _L_a_t_e_n_t _I_d_e_a_l _P_o_i_n_t (_A_b_i_l_i_t_y)

_D_e_s_c_r_i_p_t_i_o_n:

     This function generates a sample from the posterior distribution
     of a one dimensional item response theory (IRT) model, with
     multivariate Normal priors on the item parameters, and a
     Normal-Inverse Gamma hierarchical prior on subject ideal points
     (abilities).  The user supplies item-response data, subject
     covariates, and priors. Note that this identification strategy
     obviates the constraints used on theta in 'MCMCirt1d'. A sample
     from the posterior distribution is returned as an mcmc object,
     which can be subsequently analyzed with functions provided in the
     coda package.

     If you are interested in fitting  K-dimensional item response
     theory models, or would rather identify the model by placing
     constraints on the item parameters, please see 'MCMCirtKd'.

_U_s_a_g_e:

     MCMCirtHier1d(datamatrix, Xjdata,
                burnin = 1000, mcmc = 20000, thin=1,
                verbose = 0, seed = NA,
                theta.start = NA, a.start = NA, b.start = NA,
                beta.start=NA, b0=0, B0=.01, c0=.001, d0=.001,
                ab0=0, AB0=.25, store.item = FALSE, store.ability=TRUE,
                drop.constant.items=TRUE,
                marginal.likelihood=c("none","Chib95"),
                px=TRUE,px_a0 = 10, px_b0=10,
                ... )  

_A_r_g_u_m_e_n_t_s:

datamatrix: The matrix of data.  Must be 0, 1, or missing values.   The
          rows of 'datamatrix' correspond to subjects and the columns
          correspond to items.

  Xjdata: A 'data.frame' containing second-level predictor covariates
          for ideal points theta. Predictors are modeled as a linear
          regression on the mean vector of theta; the posterior sample
          contains regression coefficients beta and common variance
          sigma^2. See Rivers (2003) for a thorough discussion of
          identification of IRT models.

  burnin: The number of burn-in iterations for the sampler.

    mcmc: The number of Gibbs iterations for the sampler.

    thin: The thinning interval used in the simulation.  The number of
          Gibbs 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 'verbose' is greater
          than 0 then every 'verbose'th iteration will be printed to
          the screen.

    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 'rep(12345,6)' is used).  The second
          element of  list is a positive substream number. See the
          MCMCpack  specification for more details.

theta.start: The starting values for the subject abilities (ideal
          points). This can either be a scalar or a column vector with
          dimension equal to the number of voters.   If this takes a
          scalar value, then that value will serve as the starting
          value for all of the thetas.  The default value of NA will
          choose the starting values based on an eigenvalue-eigenvector
          decomposition of the agreement score matrix formed from the
          'datamatrix'.

 a.start: The starting values for the a difficulty parameters. This can
          either be a scalar or a column vector with dimension equal to
          the number of items.   If this takes a scalar value, then
          that value will serve as the starting value for all a. The
          default value of NA will set the starting values based on a
          series of probit regressions that condition on the starting
          values of theta.

 b.start: The starting values for the b discrimination parameters. This
          can either be a scalar or a column vector with dimension
          equal to the number of items.   If this takes a scalar value,
          then that value will serve as the starting value for all b. 
          The default value of NA will set the starting values based on
          a series of probit regressions that condition on the starting
          values of theta.

beta.start: The starting values for the beta regression coefficients
          that predict the means of ideal points theta. This can either
          be a scalar or a column vector with length equal to the
          number of covariates. If this takes a scalar value, then that
          value will serve as the starting value for all of the betas. 
          The default value of NA will set the starting values based on
          a linear regression of the covariates on (either provided or
          generated) 'theta.start'. 

      b0: The prior mean of beta. Can be either a scalar or a vector of
          length equal to the number of subject covariates. If a scalar
          all means with be set to the passed value.

      B0: The prior precision of beta.  This can either be a  scalar or
          a square matrix with dimensions equal to the number of betas.
            If this  takes a scalar value, then that value times an
          identity matrix serves as the prior precision of beta. A
          default proper but diffuse value of .01 ensures finite
          marginal likelihood for model comparison. A value of 0 is
          equivalent to an improper uniform prior for beta.

      c0: c0/2 is the shape parameter for the inverse Gamma prior on
          sigma^2 (the variance of theta). The amount of information in
          the inverse Gamma prior is something like that from c0
          pseudo-observations.

      d0: d0/2 is the scale parameter for the inverse Gamma prior on
          sigma^2 (the variance of  theta). In constructing the inverse
          Gamma prior, d0 acts like the sum of squared errors from the
          c0 pseudo-observations.

     ab0: The prior mean of '(a, b)'. Can be either a scalar or a
          2-vector. If a scalar both means will be set to the passed
          value. The prior mean is assumed to be the same across all
          items.

     AB0: The prior precision of '(a, b)'.This can either be ascalar or
          a 2 by 2 matrix. If this takes a scalar value, then that
          value times an identity matrix serves as the prior precision.
          The prior precision is assumed to be the same across all
          items.

store.item: A switch that determines whether or not to store the item
          parameters for posterior analysis.  _NOTE: In situations with
          many items storing the item parameters takes an enormous
          amount of memory, so 'store.item' should only be 'TRUE' if
          the chain is thinned heavily, or for applications with a
          small number of items_. By default, the item parameters are
          not stored.

store.ability: A switch that determines whether or not to store the
          ability parameters for posterior analysis.  _NOTE: In
          situations with many individuals storing the ability
          parameters takes an enormous amount of memory, so
          'store.ability' should only be 'TRUE' if the chain is thinned
          heavily, or for applications with a small number of
          individuals_. By default, ability parameters are 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.

marginal.likelihood: Should the marginal likelihood of the second-level
          model on ideal points be calculated using the method of Chib
          (1995)? It is stored as an attribute of the posterior 'mcmc'
          object and suitable for comparison using 'BayesFactor'.

      px: Use Parameter Expansion to reduce autocorrelation in the
          chain?  PX introduces an unidentified parameter alpha for the
          residual variance in the latent data (Liu and Wu 1999).
          Default = TRUE 

   px_a0: Prior shape parameter for the inverse-gamma distribution on
          alpha, the residual variance of the latent data. Default=10.

   px_b0: Prior scale parameter for the inverse-gamma distribution on
          alpha, the residual variance of the latent data. Default = 10 

     ...: further arguments to be passed

_D_e_t_a_i_l_s:

     'MCMCirtHier1d' simulates from the posterior distribution using
     standard Gibbs sampling using data augmentation (a Normal draw for
     the subject abilities, a multivariate Normal draw for
     (second-level) subject ability predictors, an Inverse-Gamma draw
     for the (second-level) variance of subject abilities, a
     multivariate Normal draw for the item parameters, and a truncated
     Normal draw for the latent utilities). The simulation proper is
     done in compiled C++ code to maximize efficiency.  Please consult
     the coda documentation for a comprehensive list of functions that
     can be used to analyze the posterior sample.

     The model takes the following form.  We assume that each subject
     has an subject ability (ideal point) denoted theta_j and that each
     item has a difficulty parameter a_i and discrimination parameter
     b_i.  The observed choice by subject j on item i is the observed
     data matrix which is (I * J).  We assume that the choice is
     dictated by an unobserved utility: 

                z_ij = -a_i + b_i*theta_j + epsilon_ij

     Where the errors are assumed to be distributed standard Normal.
     This constitutes the measurement or level-1 model. The subject
     abilities (ideal points) are modeled by a second level Normal
     linear predictor for subject covariates 'Xjdata', with common
     variance sigma^2. The parameters of interest are the subject
     abilities (ideal points), item parameters, and second-level
     coefficients.

     We assume the following priors.  For the subject abilities (ideal
     points):

                       theta_j ~ N(t0, T0^{-1})

     For the item parameters, the prior is:

               [alpha_i beta_i]' ~ N_2 (ab0, AB0^{-1})


     The model is identified by the proper priors on the item
     parameters and constraints placed on the ability parameters.

     As is the case with all measurement models, make sure that you
     have plenty of free memory, especially when storing the item
     parameters.

_V_a_l_u_e:

     An 'mcmc' object that contains the sample from the posterior
     distribution. This object can be summarized by functions provided
     by the coda package. If 'marginal.likelihood = "Chib95"' the
     object will have attribute 'logmarglike'.

_A_u_t_h_o_r(_s):

     Michael Malecki, malecki@wustl.edu, <URL:
     http://malecki.wustl.edu>.

_R_e_f_e_r_e_n_c_e_s:

     James H. Albert. 1992. ``Bayesian Estimation of Normal Ogive Item
     Response  Curves Using Gibbs Sampling." _Journal of Educational
     Statistics_.   17: 251-269.

     Joshua Clinton, Simon Jackman, and Douglas Rivers. 2004. ``The
     Statistical  Analysis of Roll Call Data."  _American Political
     Science Review_ 98: 355-370.

     Valen E. Johnson and James H. Albert. 1999. ``Ordinal Data
     Modeling."  Springer: New York.

     Liu, Jun S. and Ying Nian Wu. 1999. ``Parameter Expansion for Data
     Augmentation.'' _Journal of the American Statistical Association_
     94: 1264-1274.

     Daniel Pemstein, Kevin M. Quinn, and Andrew D. Martin.  2007.  
     _Scythe Statistical Library 1.0._ <URL: http://scythe.wustl.edu>.

     Martyn Plummer, Nicky Best, Kate Cowles, and Karen Vines. 2002.
     _Output Analysis and Diagnostics for MCMC (CODA)_. <URL:
     http://www-fis.iarc.fr/coda/>.

     Douglas Rivers.  2004.  ``Identification of Multidimensional
     Item-Response Models."  Stanford University, typescript.

_S_e_e _A_l_s_o:

     'plot.mcmc','summary.mcmc', 'MCMCirtKd'

_E_x_a_m_p_l_e_s:

        ## Not run: 
     data(SupremeCourt)

     Xjdata <- data.frame(presparty= c(1,1,0,1,1,1,1,0,0),
                          sex= c(0,0,1,0,0,0,0,1,0))

     ## Parameter Expansion reduces autocorrelation.
       posterior1 <- MCMCirtHier1d(t(SupremeCourt),
                        burnin=50000, mcmc=10000, thin=20, 
                        verbose=10000,
                        Xjdata=Xjdata,
                        marginal.likelihood="Chib95",
                        px=TRUE)

     ## But, you can always turn it off.
       posterior2 <- MCMCirtHier1d(t(SupremeCourt),
                        burnin=50000, mcmc=10000, thin=20, 
                        verbose=10000,
                        Xjdata=Xjdata,
                        #marginal.likelihood="Chib95",
                        px=FALSE)
     ## Note that the hierarchical model has greater autocorrelation than 
     ## the naive IRT model.
       posterior0 <- MCMCirt1d(t(SupremeCourt),
                             theta.constraints=list(Scalia="+", Ginsburg="-"),
                             B0.alpha=.2, B0.beta=.2,
                             burnin=50000, mcmc=100000, thin=100, verbose=10000,
                             store.item=FALSE)

     ## Randomly 10
     ## the variance of the (unidentified) latent parameter alpha.

     scMiss <- SupremeCourt
     scMiss[matrix(as.logical(rbinom( nrow(SupremeCourt)*ncol(SupremeCourt), 1, .1)), dim(SupremeCourt))] <- NA

        posterior1.miss <- MCMCirtHier1d(t(scMiss),
                        burnin=80000, mcmc=10000, thin=20, 
                        verbose=10000,
                        Xjdata=Xjdata,
                        marginal.likelihood="Chib95",
                        px=TRUE)

        ## End(Not run)

