createX                package:bayesm                R Documentation

_C_r_e_a_t_e _X _M_a_t_r_i_x _f_o_r _U_s_e _i_n _M_u_l_t_i_n_o_m_i_a_l _L_o_g_i_t _a_n_d _P_r_o_b_i_t _R_o_u_t_i_n_e_s

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

     'createX' makes up an X matrix in the form expected by Multinomial
     Logit ('rmnlIndepMetrop' and 'rhierMnlRwMixture') and Probit
     ('rmnpGibbs' and 'rmvpGibbs') routines.   Requires an array of
     alternative specific variables and/or an array of "demographics"
     or variables constant across alternatives which may vary across
     choice occasions.

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

     createX(p, na, nd, Xa, Xd, INT = TRUE, DIFF = FALSE, base = p)

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

       p: integer - number of choice alternatives 

      na: integer - number of alternative-specific vars in Xa  

      nd: integer - number of non-alternative specific vars 

      Xa: n x p*na matrix of alternative-specific vars 

      Xd: n x nd matrix of non-alternative specific vars 

     INT: logical flag for inclusion of intercepts 

    DIFF: logical flag for differencing wrt to base alternative 

    base: integer - index of base choice alternative 

     note: na,nd,Xa,Xd can be NULL to indicate lack of Xa or Xd
     variables.

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

     X matrix - n*(p-DIFF) x [(INT+nd)*(p-1) + na] matrix.

_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. 
      <URL:
     http://gsbwww.uchicago.edu/fac/peter.rossi/research/bsm.html>

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

     'rmnlIndepMetrop', 'rmnpGibbs'

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

     na=2; nd=1; p=3
     vec=c(1,1.5,.5,2,3,1,3,4.5,1.5)
     Xa=matrix(vec,byrow=TRUE,ncol=3)
     Xa=cbind(Xa,-Xa)
     Xd=matrix(c(-1,-2,-3),ncol=1)
     createX(p=p,na=na,nd=nd,Xa=Xa,Xd=Xd)
     createX(p=p,na=na,nd=nd,Xa=Xa,Xd=Xd,base=1)
     createX(p=p,na=na,nd=nd,Xa=Xa,Xd=Xd,DIFF=TRUE)
     createX(p=p,na=na,nd=nd,Xa=Xa,Xd=Xd,DIFF=TRUE,base=2)
     createX(p=p,na=na,nd=NULL,Xa=Xa,Xd=NULL)
     createX(p=p,na=NULL,nd=nd,Xa=NULL,Xd=Xd)

