rhierMnlRwMixture {rpud}R Documentation

MCMC Algorithm for Hierarchical Multinomial Logit with Mixture of Normals Heterogeneity

Description

rhierMnlRwMixture is a MCMC algorithm for a hierarchical multinomial logit with a mixture of normals heterogeneity distribution. This is a hybrid Gibbs Sampler with a RW Metropolis step for the MNL coefficients for each panel unit.

Usage

rhierMnlRwMixture(Data, Prior, Mcmc, output)

Arguments

Data

list(p,lgtdata,Z) ( Z is optional)

Prior

list(a,deltabar,Ad,mubar,Amu,nu,V,ncomp) (all but ncomp are optional)

Mcmc

list(s,w,R,keep,chains) (R required)

output

binary output format.

Details

Model:
y_i ~ MNL(X_i,beta_i). i=1,..., length(lgtdata). theta_i is nvar x 1.

beta_i= ZDelta[i,] + u_i.
Note: here ZDelta refers to Z%*%D, ZDelta[i,] is ith row of this product.
Delta is an nz x nvar array.

u_i ~ N(mu_{ind},Sigma_{ind}). ind ~ multinomial(pvec).

Priors:
pvec ~ dirichlet (a)
delta= vec(Delta) ~ N(deltabar,A_d^{-1})
mu_j ~ N(mubar,Sigma_j (x) Amu^{-1})
Sigma_j ~ IW(nu,V)

Lists contain:

Value

For default format: a list containing

llkdraw

R/keep array of log likelikelhood of draws

betadraw

R/keep x nvar x nlgt array of draws of betas

Deltadraw

R/keep x nvar x nz array of Delta draws, first row is initial value

probdraw

R/keep x ncomp array of draws of probs of mixture components

mudraw

R/keep x nvar x ncomp array of draws of mean parameter of beta coefficients

rootdraw

R/keep x nvar x nvar x ncomp array of error variances of beta coefficients


For bayesm format: a list containing

Deltadraw

R/keep x nz*nvar matrix of draws of Delta, first row is initial value

betadraw

nlgt x nvar x R/keep array of draws of betas

nmix

list of 3 components, probdraw, NULL, compdraw

loglike

log-likelihood for each kept draw (length R/keep)


For CODA output format: A list of CODA compatible simulation chains in default format.

Note

More on probdraw component of nmix list in bayesm output format:
R/keep x ncomp matrix of draws of probs of mixture components (pvec)
More on compdraw component of return value list:

Note: Z should not include an intercept and is centered for ease of interpretation.

Be careful in assessing prior parameter, Amu. .01 is too small for many applications. See Rossi et al, chapter 5 for full discussion.

Note: as of version 2.0-2 of bayesm, the fractional weight parameter has been changed to a weight between 0 and 1. w is the fractional weight on the normalized pooled likelihood. This differs from what is in Rossi et al chapter 5, i.e.

like_i^(1-w) x like_pooled^((n_i/N)*w)

Large R values may be required (>20,000).

Author(s)

Chi Yau (based on R doc of rhierMnlRwMixture in bayesm by Peter Rossi)
chi.yau@r-tutor.com

References

Rossi, Allenby and McCulloch:
Bayesian Statistics and Marketing Ch 5
http://www.perossi.org/home/bsm-1

Examples

## Not run: 

library(rpud)
data.path <- file.path(path.package(package="rpud"), "runit/data")

# load p, Delta, Z, and simlgtdata
load(file.path(data.path, "rhierMnl-n2x6x5-rd.txt.gz")) 

## set parms for priors and Z
R <- 5000
keep <- 5 
seed <- 66

Prior <- list(ncomp=4)
Mcmc <- list(R=R, keep=keep)
Data <- list(p=p, lgtdata=simlgtdata, Z=Z)

set.seed(seed)

system.time(
out <- rpud::rhierMnlRwMixture(
        Data=Data, 
        Prior=Prior, 
        Mcmc=Mcmc, 
        output="bayesm"
))

library(bayesm)

cat("Summary of Delta draws", fill=TRUE)
summary(out$Deltadraw, tvalues=as.vector(Delta))

cat("Summary of Normal Mixture Distribution", fill=TRUE)
summary(out$nmix)

if(0) {
    ## plotting examples
    plot(out$betadraw)
    plot(out$nmix)
}


## End(Not run)

[Package rpud version 0.7.1 Index]