# NOT RUN {
data("ModeCanada", package = "mlogit")
bususers <- with(ModeCanada, case[choice == 1 & alt == "bus"])
ModeCanada <- subset(ModeCanada, ! case %in% bususers)
ModeCanada <- subset(ModeCanada, noalt == 4)
ModeCanada <- subset(ModeCanada, alt != "bus")
ModeCanada$alt <- ModeCanada$alt[drop = TRUE]
KoppWen00 <- mlogit.data(ModeCanada, shape='long', chid.var = 'case',
alt.var = 'alt', choice='choice',
drop.index=TRUE)
pcl <- mlogit(choice~freq+cost+ivt+ovt, KoppWen00, reflevel='car',
nests='pcl', constPar=c('iv.train.air'))
# }
# NOT RUN {
<!-- % use the subset of users who have the four alternatives available and who -->
# }
# NOT RUN {
<!-- % don't take the bus -->
# }
# NOT RUN {
# }
# NOT RUN {
<!-- % bususers <- with(ModeCanada, case[choice == 1 & alt == "bus"]) -->
# }
# NOT RUN {
<!-- % ModeCanada <- subset(ModeCanada, !case %in% bususers) -->
# }
# NOT RUN {
<!-- % ModeCanada <- subset(ModeCanada, nchoice == 4) -->
# }
# NOT RUN {
<!-- % ModeCanada <- subset(ModeCanada, alt != "bus") -->
# }
# NOT RUN {
<!-- % ModeCanada$alt <- ModeCanada$alt[drop = TRUE] -->
# }
# NOT RUN {
<!-- % KoppWen00 <- mlogit.data(ModeCanada, shape='long', chid.var = 'case', -->
# }
# NOT RUN {
<!-- % alt.var = 'alt', choice='choice', -->
# }
# NOT RUN {
<!-- % drop.index=TRUE) -->
# }
# NOT RUN {
<!-- % mlogit(choice~freq+cost+ivt+ovt, KoppWen00, reflevel='car') -->
# }
# NOT RUN {
<!-- % z <- mlogit(choice~freq+cost+ivt+ovt, KoppWen00, reflevel='car', nests="pcl") -->
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab