runiregGibbs {bayesm} | R Documentation

## Gibbs Sampler for Univariate Regression

### Description

`runiregGibbs` implements a Gibbs Sampler to draw from posterior of a univariate regression with a conditionally conjugate prior.

### Usage

    runiregGibbs(Data, Prior, Mcmc)

### Arguments

`Data` | list(y,X)
`Prior` | list(betabar,A, nu, ssq)
`Mcmc` | list(sigmasq,R,keep)

### Details

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

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

`X`
  n x k Design Matrix
`y`
  n x 1 vector of observations
`betabar`
  k x 1 prior mean (def: 0)
`A`
  k x k prior precision matrix (def: .01I)
`nu`
  d.f. parm for Inverted Chi-square prior (def: 3)
`ssq`
  scale parm for Inverted Chi-square prior (def:var(y))
`R`
  number of MCMC draws
`keep`
  thinning parameter - keep every keepth draw

### Value

list of MCMC draws

`betadraw` | R x k array of betadraws
`sigmasqdraw` | R vector of sigma-sq draws

### Author(s)

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

### References

For further discussion, see Bayesian Statistics and Marketing by Rossi, Allenby and McCulloch, Chapter 3.
http://gsbwww.uchicago.edu/fac/peter.rossi/research/bsm.html

### See Also

`runireg`

### Examples

    if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=1000} else {R=10}
    set.seed(66)
    n=100
    X=cbind(rep(1,n),runif(n)); beta=c(1,2); sigsq=.25
    y=X%*%beta+rnorm(n,sd=sqrt(sigsq))

    A=diag(c(.05,.05)); betabar=c(0,0)
    nu=3; ssq=1.0

    Data=list(y=y,X=X); Mcmc=list(R=R,keep=1) ; Prior=list(A=A,betabar=betabar,nu=nu,ssq=ssq)
    out=runiregGibbs(Data=Data,Prior=Prior,Mcmc=Mcmc)
    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)))

[Package bayesm version 2.0-8 Index]