runireg                package:bayesm                R Documentation

_I_I_D _S_a_m_p_l_e_r _f_o_r _U_n_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:

     'runireg' implements an iid sampler to draw from the posterior of
     a univariate regression with a conjugate prior.

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

     runireg(Data, Prior, Mcmc)

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

    Data: list(y,X)

   Prior: list(betabar,A, nu, ssq) 

    Mcmc: list(R,keep)

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

     Model: y = Xbeta + e.  e ~ N(0,sigmasq). 

     Priors: beta ~ N(betabar,sigmasq*A^{-1}).  sigmasq ~
     (nu*ssq)/chisq_{nu}. List arguments contain  

   '_X' n x k Design Matrix

   '_y' n x 1 vector of observations 

   '_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 Inverted Chi-square prior (def: 3)

   '_s_s_q' scale parm for Inverted Chi-square prior (def: var(y))

   '_R' number of draws 

   '_k_e_e_p' thinning parameter - keep every keepth draw 

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

     list of iid draws 

betadraw : R x k array of betadraws 

sigmasqdraw : R vector of sigma-sq draws

_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:

     'runiregGibbs'

_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
     X=cbind(rep(1,n),runif(n)); beta=c(1,2); sigsq=.25
     y=X%*%beta+rnorm(n,sd=sqrt(sigsq))

     out=runireg(Data=list(y=y,X=X),Mcmc=list(R=R))
     cat(" betadraws ",fill=TRUE)
     mat=apply(out$betadraw,2,quantile,probs=c(.01,.05,.5,.95,.99))
     mat=rbind(beta,mat); rownames(mat)[1]="beta"; print(mat)
     cat(" Sigma-sq draws",fill=TRUE)
     cat(" sigma-sq= ",sigsq,fill=TRUE)
     print(quantile(out$sigmasqdraw,probs=c(.01,.05,.5,.95,.99)))

