rmnpGibbs {bayesm} | R Documentation |
Gibbs Sampler for Multinomial Probit
Description
rmnpGibbs
implements the McCulloch/Rossi Gibbs Sampler for the multinomial probit model.
Usage
rmnpGibbs(Data, Prior, Mcmc)
Arguments
Data |
list(y, X, p) |
Prior |
list(betabar, A, nu, V) |
Mcmc |
list(R, keep, nprint, beta0, sigma0) |
Details
Model and Priors
with
.
Note:
and
are
.
if
for
and
where
means elements of
other than the
th.
, if all
is not identified. However,
/sqrt(
) and
/
are identified. See reference or example below for details.
Argument Details
Data = list(y, X, p)
y: | vector of multinomial outcomes (1, ..., p) |
X: | design matrix. To make matrix use createX with DIFF=TRUE |
p: | number of alternatives |
Prior = list(betabar, A, nu, V)
[optional]
betabar: | prior mean (def: 0) |
A: | prior precision matrix (def: 0.01*I) |
nu: | d.f. parameter for Inverted Wishart prior (def: (p-1)+3) |
V: | PDS location parameter for Inverted Wishart prior (def: nu*I) |
Mcmc = list(R, keep, nprint, beta0, sigma0)
[only R
required]
R: | number of MCMC draws |
keep: | MCMC thinning parameter -- keep every keep th draw (def: 1) |
nprint: | print the estimated time remaining for every nprint 'th draw (def: 100, set to 0 for no print) |
beta0: | initial value for beta (def: 0) |
sigma0: | initial value for sigma (def: I) |
Value
A list containing:
betadraw |
|
sigmadraw |
|
Author(s)
Peter Rossi, Anderson School, UCLA, perossichi@gmail.com.
References
For further discussion, see Chapter 4, Bayesian Statistics and Marketing by Rossi, Allenby, and McCulloch.
See Also
Examples
if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=2000} else {R=10}
set.seed(66)
simmnp = function(X, p, n, beta, sigma) {
indmax = function(x) {which(max(x)==x)}
Xbeta = X%*%beta
w = as.vector(crossprod(chol(sigma),matrix(rnorm((p-1)*n),ncol=n))) + Xbeta
w = matrix(w, ncol=(p-1), byrow=TRUE)
maxw = apply(w, 1, max)
y = apply(w, 1, indmax)
y = ifelse(maxw < 0, p, y)
return(list(y=y, X=X, beta=beta, sigma=sigma))
}
p = 3
n = 500
beta = c(-1,1,1,2)
Sigma = matrix(c(1, 0.5, 0.5, 1), ncol=2)
k = length(beta)
X1 = matrix(runif(n*p,min=0,max=2),ncol=p)
X2 = matrix(runif(n*p,min=0,max=2),ncol=p)
X = createX(p, na=2, nd=NULL, Xa=cbind(X1,X2), Xd=NULL, DIFF=TRUE, base=p)
simout = simmnp(X,p,500,beta,Sigma)
Data1 = list(p=p, y=simout$y, X=simout$X)
Mcmc1 = list(R=R, keep=1)
out = rmnpGibbs(Data=Data1, Mcmc=Mcmc1)
cat(" Summary of Betadraws ", fill=TRUE)
betatilde = out$betadraw / sqrt(out$sigmadraw[,1])
attributes(betatilde)$class = "bayesm.mat"
summary(betatilde, tvalues=beta)
cat(" Summary of Sigmadraws ", fill=TRUE)
sigmadraw = out$sigmadraw / out$sigmadraw[,1]
attributes(sigmadraw)$class = "bayesm.var"
summary(sigmadraw, tvalues=as.vector(Sigma[upper.tri(Sigma,diag=TRUE)]))
## plotting examples
if(0){plot(betatilde,tvalues=beta)}