rbprobitGibbs: Gibbs Sampler (Albert and Chib) for Binary Probit

Description Usage Arguments Details Value Author(s) References See Also Examples

View source: R/rbprobitgibbs_rcpp.r

Description

rbprobitGibbs implements the Albert and Chib Gibbs Sampler for the binary probit model.

Usage

1
rbprobitGibbs(Data, Prior, Mcmc)

Arguments

Data

list(y, X)

Prior

list(betabar, A)

Mcmc

list(R, keep, nprint)

Details

Model and Priors

z = Xβ + e with e ~ N(0, I)
y = 1 if z > 0

β ~ N(betabar, A^{-1})

Argument Details

Data = list(y, X)

y: n x 1 vector of 0/1 outcomes
X: n x k design matrix

Prior = list(betabar, A) [optional]

betabar: k x 1 prior mean (def: 0)
A: k x k prior precision matrix (def: 0.01*I)

Mcmc = list(R, keep, nprint) [only R required]

R: number of MCMC draws
keep: MCMC thinning parameter -- keep every keepth draw (def: 1)
nprint: print the estimated time remaining for every nprint'th draw (def: 100, set to 0 for no print)

Value

A list containing:

betadraw

R/keep x k matrix of betadraws

Author(s)

Peter Rossi, Anderson School, UCLA, [email protected].

References

For further discussion, see Chapter 3, Bayesian Statistics and Marketing by Rossi, Allenby, and McCulloch.
http://www.perossi.org/home/bsm-1

See Also

rmnpGibbs

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=2000} else {R=10}
set.seed(66)

## function to simulate from binary probit including x variable
simbprobit = function(X, beta) {
  y = ifelse((X%*%beta + rnorm(nrow(X)))<0, 0, 1)
  list(X=X, y=y, beta=beta)
}

nobs = 200
X = cbind(rep(1,nobs), runif(nobs), runif(nobs))
beta = c(0,1,-1)
nvar = ncol(X)
simout = simbprobit(X, beta)

Data1 = list(X=simout$X, y=simout$y)
Mcmc1 = list(R=R, keep=1)

out = rbprobitGibbs(Data=Data1, Mcmc=Mcmc1)
summary(out$betadraw, tvalues=beta)

## plotting example
if(0){plot(out$betadraw, tvalues=beta)}

Example output

 
Starting Gibbs Sampler for Binary Probit Model
   with  200  observations
Table of y Values
y
  0   1 
 90 110 
 
Prior Parms: 
betabar
[1] 0 0 0
A
     [,1] [,2] [,3]
[1,] 0.01 0.00 0.00
[2,] 0.00 0.01 0.00
[3,] 0.00 0.00 0.01
 
MCMC parms: 
R=  10  keep=  1  nprint=  100
 
 MCMC Iteration (est time to end - min) 
 Total Time Elapsed: 0.00 
fewer than 100 draws submitted 

bayesm documentation built on Dec. 21, 2018, 9:04 a.m.