rmnlIndepMetrop {bayesm} | R Documentation |
rmnIndepMetrop
implements Independence Metropolis for the MNL.
rmnlIndepMetrop(Data, Prior, Mcmc)
Data |
list(p,y,X) |
Prior |
list(A,betabar) optional |
Mcmc |
list(R,keep,nu) |
Model: y ~ MNL(X,beta). Pr(y=j) = exp(x_j'beta)/sum_k{e^{x_k'beta}}.
Prior: beta ~ N(betabar,A^{-1})
list arguments contain:
p
y
X
A
betabar
R
keep
nu
a list containing:
betadraw |
R/keep x nvar array of beta draws |
loglike |
R/keep vector of loglike values for each draw |
acceptr |
acceptance rate of Metropolis draws |
Peter Rossi, Graduate School of Business, University of Chicago, Peter.Rossi@ChicagoGsb.edu.
For further discussion, see Bayesian Statistics and Marketing
by Rossi, Allenby and McCulloch, Chapter 5.
http://gsbwww.uchicago.edu/fac/peter.rossi/research/bsm.html
## if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=2000} else {R=10} set.seed(66) n=200; p=3; beta=c(1,-1,1.5,.5) simout=simmnl(p,n,beta) A=diag(c(rep(.01,length(beta)))); betabar=rep(0,length(beta)) Data=list(y=simout$y,X=simout$X,p=p); Mcmc=list(R=R,keep=1) ; Prior=list(A=A,betabar=betabar) out=rmnlIndepMetrop(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)