BMLogit                package:Baldur                R Documentation

_B_a_y_e_s_i_a_n _m_u_l_t_i_n_o_m_i_a_l _l_o_g_i_t _m_o_d_e_l

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

     'BMLogit' produces iid draws from the posterior density of a
     Bayesian multinomial logit model with a multivariate normal prior.

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

     BMLogit(y,X,alpha,mu,P,draws,Prec=FALSE,A=FALSE)

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

       y: n*m Matrix with counts for the m (m>=2) alternatives.  

       X: n*k Matrix with the values for the independent variables

   alpha: n*m Matrix added to the utilities of the various alternatives

      mu: (k(m-1))*1 Prior Mean Vector

       P: k(m-1)*k(m-1) Prior Precision Matrix (must be Positive
          definite) 

   draws: Number of desired draws from the posterior density 

    Prec: Optional logical argument with default Prec=FALSE.  If
          argument is set to TRUE,  the matrix P is treated as a prior
          precision matrix.

       A: Optional logical argument with default A=FALSE.  If argument
          is set to TRUE,  the function returns not only the simulated
          draws from the posterior density but also a vector with
          information  related to the acceptance rate for the
          underlying accept/reject procedure (see below).

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

     Makes use of the likelihood subgradient density accept/reject
     procedure of Nygren and Nygren (2006) in order to generate iid
     samples  from the posterior density of a Bayesian multinomial
     logit model. If the posterior density is close to multivariate
     normal,  then the expected number of draws should be approximately
     equal to $(2/sqrt{pi})^{k(m-1)}$.

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

     If A=FALSE, a matrix beta. If A=TRUE, a list containing the matrix
     beta and a matrix Accept.: 

   beta : draws*k(m-1) matrix with the iid draws for the model
          parameters.

  Accept: draws*1 matrix with the number of candidates for each draw
          that were required before acceptance in the accept/reject
          procedure.

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

     Kjell Nygren knygren@us.imshealth.com

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

     data(Contraceptives,package="Baldur")

     y<-as.matrix(Contraceptives[1:7,1:3])
     X<-matrix(1,nrow=7,ncol=3)
     X[,2]<-Contraceptives[,5]
     X[,3]<-Contraceptives[,5]*Contraceptives[,5]

     mu<-matrix(0,nrow=6,ncol=1)
     alpha<-matrix(0,nrow=7,ncol=3)
     P<-100*diag(6)

     draws<-1000

     set.seed(666)
     system.time(sim<-BMLogit(y,X,alpha,mu,P,draws))

