rmnpGibbs               package:bayesm               R Documentation

_G_i_b_b_s _S_a_m_p_l_e_r _f_o_r _M_u_l_t_i_n_o_m_i_a_l _P_r_o_b_i_t

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

     'rmnpGibbs' implements the McCulloch/Rossi Gibbs Sampler for the
     multinomial probit model.

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

     rmnpGibbs(Data, Prior, Mcmc)

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

    Data: list(p, y, X)

   Prior: list(betabar,A,nu,V) (optional)

    Mcmc: list(beta0,sigma0,R,keep) (R required) 

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

     model:  
      w_i = X_ibeta + e.    e ~ N(0,Sigma).     note: w_i, e are (p-1)
     x 1.
      y_i = j,  if w_{ij} > max(0,w_{i,-j})  j=1,...,p-1.  w_{i,-j}
     means elements of w_i other than the jth. 
      y_i = p,  if all w_i < 0.

     priors:
      beta ~ N(betabar,A^{-1}) 
      Sigma ~ IW(nu,V)

     to make up X matrix use 'createX' with 'DIFF=TRUE'.

     List arguments contain  

   '_p' number of choices or possible multinomial outcomes

   '_y' n x 1 vector of multinomial outcomes

   '_X' n*(p-1) x k Design Matrix

   '_b_e_t_a_b_a_r' k x 1 prior mean (def: 0)

   '_A' k x k prior precision matrix (def: .01I) 

   '_n_u' d.f. parm for IWishart prior (def: (p-1) + 3)

   '_V' pds location parm for IWishart prior (def: nu*I)

   '_b_e_t_a_0' initial value for beta

   '_s_i_g_m_a_0' initial value for sigma 

   '_R' number of MCMC draws 

   '_k_e_e_p' thinning parameter - keep every keepth draw (def: 1)

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

     a list containing:  

betadraw : R/keep x k array of betadraws

sigmadraw: R/keep x (p-1)*(p-1) array of sigma draws - each row is in
          vector form

_N_o_t_e:

     beta is not identified.  beta/sqrt(sigma_{11}) and
     Sigma/sigma_{11} are.  See Allenby et al or example below for
     details.

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

     Peter Rossi, Graduate School of Business, University of Chicago,
     Peter.Rossi@ChicagoGsb.edu.

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

     For further discussion, see _Bayesian Statistics and Marketing_ by
     Rossi, Allenby and McCulloch, Chapter 4. 
      <URL:
     http://gsbwww.uchicago.edu/fac/peter.rossi/research/bsm.html>

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

     'rmvpGibbs'

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

     ##
     if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=2000} else {R=10}

     set.seed(66)
     p=3
     n=500
     beta=c(-1,1,1,2)
     Sigma=matrix(c(1,.5,.5,1),ncol=2)
     k=length(beta)
     x1=runif(n*(p-1),min=-1,max=1); x2=runif(n*(p-1),min=-1,max=1)
     I2=diag(rep(1,p-1)); xadd=rbind(I2)
     for(i in 2:n) { xadd=rbind(xadd,I2)}
     X=cbind(xadd,x1,x2)
     simout=simmnp(X,p,500,beta,Sigma)

     Data=list(p=p,y=simout$y,X=simout$X)
     Mcmc=list(R=R,keep=1)

     out=rmnpGibbs(Mcmc=Mcmc,Data=Data)

     cat(" Betadraws ",fill=TRUE)
     mat=apply(out$betadraw/sqrt(out$sigmadraw[,1]),2,quantile,probs=c(.01,.05,.5,.95,.99))
     mat=rbind(beta,mat); rownames(mat)[1]="beta"; print(mat)
     cat(" Sigmadraws ",fill=TRUE)
     mat=apply(out$sigmadraw/out$sigmadraw[,1],2,quantile,probs=c(.01,.05,.5,.95,.99))
     mat=rbind(as.vector(Sigma),mat); rownames(mat)[1]="sigma"; print(mat)

