1\name{rhierBinLogit}
2\alias{rhierBinLogit}
3\concept{bayes}
4\concept{MCMC}
5\concept{hierarchical models}
6\concept{binary logit}
7
8\title{MCMC Algorithm for Hierarchical Binary Logit}
9
10\description{
11\bold{This function has been deprecated. Please use \code{rhierMnlRwMixture} instead.}
12
13\code{rhierBinLogit} implements an MCMC algorithm for hierarchical binary logits with a normal heterogeneity distribution. This is a hybrid sampler with a RW Metropolis step for unit-level logit parameters.
14
15\code{rhierBinLogit} is designed for use on choice-based conjoint data with partial profiles. The Design matrix is based on differences of characteristics between two alternatives. See Appendix A of \emph{Bayesian Statistics and Marketing} for details.
16}
17
18\usage{rhierBinLogit(Data, Prior, Mcmc)}
19
20\arguments{
21  \item{Data }{list(lgtdata, Z)}
22  \item{Prior}{list(Deltabar, ADelta, nu, V)}
23  \item{Mcmc }{list(R, keep, sbeta)}
24}
25
26\details{
27\subsection{Model and Priors}{
28  \eqn{y_{hi} = 1} with \eqn{Pr = exp(x_{hi}'\beta_h) / (1+exp(x_{hi}'\beta_h)} and \eqn{\beta_h} is \eqn{nvar x 1} \cr
29  \eqn{h = 1, \ldots, length(lgtdata)} units (or "respondents" for survey data)
30
31  \eqn{\beta_h} = ZDelta[h,] + \eqn{u_h} \cr
32  Note: here ZDelta refers to \code{Z\%*\%Delta} with ZDelta[h,] the \eqn{h}th row of this product\cr
33  Delta is an \eqn{nz x nvar} array
34
35  \eqn{u_h} \eqn{\sim}{~} \eqn{N(0, V_{beta})}.  \cr
36
37  \eqn{delta = vec(Delta)} \eqn{\sim}{~} \eqn{N(vec(Deltabar), V_{beta}(x) ADelta^{-1})}\cr
38  \eqn{V_{beta}} \eqn{\sim}{~} \eqn{IW(nu, V)}
39}
40\subsection{Argument Details}{
41  \emph{\code{Data  = list(lgtdata, Z)} [\code{Z} optional]}
42  \tabular{ll}{
43    \code{lgtdata:       } \tab list of lists with each cross-section unit MNL data \cr
44    \code{lgtdata[[h]]$y:} \tab \eqn{n_h x 1} vector of binary outcomes (0,1) \cr
45    \code{lgtdata[[h]]$X:} \tab \eqn{n_h x nvar} design matrix for h'th unit \cr
46    \code{Z:             } \tab \eqn{nreg x nz} mat of unit chars (def: vector of ones)
47  }
48  \emph{\code{Prior = list(Deltabar, ADelta, nu, V)} [optional]}
49  \tabular{ll}{
50    \code{Deltabar:} \tab \eqn{nz x nvar} matrix of prior means (def: 0) \cr
51    \code{ADelta:  } \tab prior precision matrix (def: 0.01I) \cr
52    \code{nu:      } \tab d.f. parameter for IW prior on normal component Sigma (def: nvar+3) \cr
53    \code{V:       } \tab pds location parm for IW prior on normal component Sigma (def: nuI)
54  }
55  \emph{\code{Mcmc  = list(R, keep, sbeta)} [only \code{R} required]}
56  \tabular{ll}{
57    \code{R:       } \tab number of MCMC draws \cr
58    \code{keep:    } \tab MCMC thinning parm -- keep every \code{keep}th draw (def: 1) \cr
59    \code{sbeta:   } \tab scaling parm for RW Metropolis (def: 0.2)
60  }
61}
62}
63
64\value{
65  A list containing:
66  \item{Deltadraw }{ \eqn{R/keep x nz*nvar} matrix of draws of Delta}
67  \item{betadraw  }{ \eqn{nlgt x nvar x R/keep} array of draws of betas}
68  \item{Vbetadraw }{ \eqn{R/keep x nvar*nvar} matrix of draws of Vbeta}
69  \item{llike     }{ \eqn{R/keep x 1} vector of log-like values}
70  \item{reject    }{ \eqn{R/keep x 1} vector of reject rates over nlgt units}
71}
72
73\note{Some experimentation with the Metropolis scaling paramter (\code{sbeta}) may be required.}
74
75\author{Peter Rossi, Anderson School, UCLA, \email{perossichi@gmail.com}.}
76
77\references{For further discussion, see Chapter 5, \emph{Bayesian Statistics and Marketing} by Rossi, Allenby, and McCulloch. \cr \url{http://www.perossi.org/home/bsm-1}}
78
79\examples{
80if(nchar(Sys.getenv("LONG_TEST")) != 0) {R=10000} else {R=10}
81set.seed(66)
82
83nvar = 5              ## number of coefficients
84nlgt = 1000           ## number of cross-sectional units
85nobs = 10             ## number of observations per unit
86nz = 2                ## number of regressors in mixing distribution
87
88Z = matrix(c(rep(1,nlgt),runif(nlgt,min=-1,max=1)), nrow=nlgt, ncol=nz)
89Delta = matrix(c(-2, -1, 0, 1, 2, -1, 1, -0.5, 0.5, 0), nrow=nz, ncol=nvar)
90iota = matrix(1, nrow=nvar, ncol=1)
91Vbeta = diag(nvar) + 0.5*iota\%*\%t(iota)
92
93lgtdata=NULL
94for (i in 1:nlgt) {
95  beta = t(Delta)\%*\%Z[i,] + as.vector(t(chol(Vbeta))\%*\%rnorm(nvar))
96  X = matrix(runif(nobs*nvar), nrow=nobs, ncol=nvar)
97  prob = exp(X\%*\%beta) / (1+exp(X\%*\%beta))
98  unif = runif(nobs, 0, 1)
99  y = ifelse(unif<prob, 1, 0)
100  lgtdata[[i]] = list(y=y, X=X, beta=beta)
101}
102
103Data1 = list(lgtdata=lgtdata, Z=Z)
104Mcmc1 = list(R=R)
105
106out = rhierBinLogit(Data=Data1, Mcmc=Mcmc1)
107
108cat("Summary of Delta draws", fill=TRUE)
109summary(out$Deltadraw, tvalues=as.vector(Delta))
110
111cat("Summary of Vbeta draws", fill=TRUE)
112summary(out$Vbetadraw, tvalues=as.vector(Vbeta[upper.tri(Vbeta,diag=TRUE)]))
113
114if(0){
115## plotting examples
116plot(out$Deltadraw,tvalues=as.vector(Delta))
117plot(out$betadraw)
118plot(out$Vbetadraw,tvalues=as.vector(Vbeta[upper.tri(Vbeta,diag=TRUE)]))
119}
120
121}
122\seealso{ \code{\link{rhierMnlRwMixture}} }
123\keyword{ models}
124
125