BRegression              package:Baldur              R Documentation

_B_a_y_e_s_i_a_n _L_i_n_e_a_r _R_e_g_r_e_s_s_i_o_n _M_o_d_e_l

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

     'BRegression' produces iid draws from the posterior density of a
     Bayesian Regression model with a multivariate normal prior for the
     regression coefficients and a separate independent Gamma prior for
     the data precision.

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

     BRegression(y,X,mu,P,V0,n0,draws,Prec=FALSE,A=FALSE,maxiter=10000)

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

       y: n*1 Matrix with observed data values.  

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

      mu: k*1 Prior mean vector.

       P: k*k Prior variance-covariance matrix (must be Positive
          Definite). If Prec=TRUE,  this is instead treated as the
          prior precision matrix (inverse variance-covariance matrix).

      V0: Prior point estimate for data variance.

      n0: Number of prior "observations" for data variance.

   draws: Numeric variable containing number of desired draws from the
          posterior density. Non-integer values are rounded to the
          nearest integer.

    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).

 maxiter: Maximum number of candidates to be used by accept/reject
          procedure before terminating.

_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 Logit model with
     a multivariate normal prior.

     \author{ Kjell Nygren knygren@us.imshealth.com}

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

     # Bayesian Regression using Pearson's Height Data for Father-Son pairs

     data(Height, package = "Baldur")

     m<-1078
     nvars<-2

     y<-matrix(Height$Son,nrow=m,ncol=1)
     X<-matrix(0,nrow=m,ncol=nvars)
     mu<-matrix(0,nrow=nvars,ncol=1)
     X[,1]<-1
     X[,2]<-Height$Father[1:m]

     P<-100*diag(nvars)
     V0<-10
     n0<-3

     draws<-1000

     set.seed(666)

     system.time(out<-BRegression(y, X, mu, P, V0, n0, draws)) 

     mean(out$beta[,1])
     mean(out$beta[,2])

     mean(out$Var)

     sqrt(var(out$beta[,1]))
     sqrt(var(out$beta[,2]))
     sqrt(var(out$Var))

