# NOT RUN {
#######################################
# example one: train ticket selection
#######################################
require(mlogit)
data("Train", package="mlogit")
Train$choiceid <- 1:nrow(Train)
Tr <- dfidx(Train, shape = "wide", varying = 4:11, sep = "_",
choice = "choice", idx = list(c("choiceid", "id")),
idnames = c(NA, "alt"))
Tr$price <- Tr$price/100 * 2.20371
Tr$time <- Tr$time/60
ml.Train <- mlogit(choice ~ price + time + change + comfort | -1, Tr)
# compute pairs cluster bootstrapped p-values
# note: few reps to speed up example
cluster.bs.tr <- cluster.bs.mlogit(ml.Train, Tr, ~ id, boot.reps=100)
##################################################################
# example two: predict type of heating system installed in house
##################################################################
require(mlogit)
data("Heating", package = "mlogit")
H <- Heating
H$region <- as.numeric(H$region)
H.ml <- dfidx(H, shape="wide", choice="depvar", varying=c(3:12),
idx = list(c("idcase", "region")))
m <- mlogit(depvar~ic+oc, H.ml)
# compute pairs cluster bootstrapped p-values
cluster.bs.h <- cluster.bs.mlogit(m, H.ml, ~ region, boot.reps=1000)
# }
Run the code above in your browser using DataLab