# NOT RUN {
## Data
data("TravelMode", package = "AER")
library(mlogit)
TM <- mlogit.data(TravelMode, choice = "choice", shape = "long",
alt.levels = c("air", "train", "bus", "car"), chid.var = "individual")
## MIXL model with observed heterogeneity
mixl.hier <- gmnl(choice ~ vcost + gcost + travel + wait | 1 | 0 | income + size - 1,
data = TM,
model = "mixl",
ranp = c(travel = "t", wait = "n"),
mvar = list(travel = c("income","size"), wait = c("income")),
R = 30,
haltons = list("primes"= c(2, 17), "drop" = rep(19, 2)))
## Get the individuals' conditional mean and their standard errors for lwage
bi.travel <- effect.gmnl(mixl.hier, par = "travel", effect = "ce")
summary(bi.travel$mean)
summary(bi.travel$sd.est)
## Get the individuals' conditional WTP of travel with respect to gcost
wtp.travel <- effect.gmnl(mixl.hier, par = "travel", effect = "wtp", wrt = "gcost")
summary(wtp.travel$mean)
summary(wtp.travel$sd.est)
# }
Run the code above in your browser using DataLab