rmultireg               package:bayesm               R Documentation

_D_r_a_w _f_r_o_m _t_h_e _P_o_s_t_e_r_i_o_r _o_f _a _M_u_l_t_i_v_a_r_i_a_t_e _R_e_g_r_e_s_s_i_o_n

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

     ' rmultireg' draws from the posterior of a Multivariate Regression
     model with a natural conjugate prior.

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

     rmultireg(Y, X, Bbar, A, nu, V)

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

       Y: n x m matrix of observations on m dep vars 

       X: n x k matrix of observations on indep vars (supply intercept) 

    Bbar: k x m matrix of prior mean of regression coefficients 

       A: k x k Prior precision matrix 

      nu: d.f. parameter for Sigma 

       V: m x m pdf location parameter for prior on Sigma 

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

     Model: Y=XB+U.  cov(u_i) = Sigma.  B is k x m matrix of
     coefficients. Sigma is m x m covariance.

     Priors:  beta given Sigma  ~ N(betabar,Sigma (x) A^{-1}). 
     betabar=vec(Bbar);  beta = vec(B) 
      Sigma ~ IW(nu,V).

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

     A list of the components of a draw from the posterior 

      B : draw of regression coefficient matrix 

  Sigma : draw of Sigma 

_W_a_r_n_i_n_g:

     This routine is a utility routine that does *not* check the input
     arguments for proper dimensions and type.

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

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

     'rmultiregfp','init.rmultiregfp'

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

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

     set.seed(66)
     n=200
     m=2
     X=cbind(rep(1,n),runif(n))
     k=ncol(X)
     B=matrix(c(1,2,-1,3),ncol=m)
     Sigma=matrix(c(1,.5,.5,1),ncol=m); RSigma=chol(Sigma)
     Y=X%*%B+matrix(rnorm(m*n),ncol=m)%*%RSigma

     betabar=rep(0,k*m);Bbar=matrix(betabar,ncol=m)
     A=diag(rep(.01,k))
     nu=3; V=nu*diag(m)

     betadraw=matrix(double(R*k*m),ncol=k*m)
     Sigmadraw=matrix(double(R*m*m),ncol=m*m)
     for (rep in 1:R) 
        {out=rmultireg(Y,X,Bbar,A,nu,V);betadraw[rep,]=out$B
         Sigmadraw[rep,]=out$Sigma}

     cat(" Betadraws ",fill=TRUE)
     mat=apply(betadraw,2,quantile,probs=c(.01,.05,.5,.95,.99))
     mat=rbind(as.vector(B),mat); rownames(mat)[1]="beta"
     print(mat)
     cat(" Sigma draws",fill=TRUE)
     mat=apply(Sigmadraw,2,quantile,probs=c(.01,.05,.5,.95,.99))
     mat=rbind(as.vector(Sigma),mat); rownames(mat)[1]="Sigma"
     print(mat)

