library(mlogit) #wide format example data("Train",package="mlogit") Train$choiceid <- 1:nrow(Train) head(Train,3) #long format example data("ModeCanada",package = "mlogit") head(ModeCanada) library("Formula") f <- Formula(choice ~ cost | income + urban | ivt) #force data into appropriate data frame MC = dfidx(ModeCanada, subset = noalt == 4, alt.levels = c("train","air","bus","car")) head(MC) MC$time = with(MC,ivt+ovt) m1.MC1 = mlogit(choice~cost+freq+ovt|income|ivt,MC) summary(m1.MC1) #RANDOM PARAMETERS MODEL Tr = dfidx(Train,shape="wide",choice="choice",varying=4:11,sep = "_", idx = list(c("choiceid","id")),idnames=c("chid","alt"), opposite = c("price","comfort","time","change")) Tr$price = Tr$price/100 * 2.20371 Tr$time = Tr$time / 60 head(Tr,3) Train.ml = mlogit(choice~price+time+change+comfort|-1,Tr) summary(Train.ml) coef(Train.ml)[-1]/coef(Train.ml)[1] Train.mxlu = mlogit(choice~price+time+change+comfort|-1,Tr, panel=TRUE,rpar=c(time="n",change="n",comfort="n"), R=100,correlation=FALSE,halton=NA,method="bhhh") names(coef(Train.mxlu)) summary(Train.mxlu) Train.mxlc = mlogit(choice~price+time+change+comfort|-1,Tr, panel=TRUE,rpar=c(time="n",change="n",comfort="n"), R=100,correlation=TRUE,halton=NA,method="bhhh") names(coef(Train.mxlc)) summary(Train.mxlc) marg.ut.time = rpar(Train.mxlc,"time") summary(marg.ut.time) wtp.time = rpar(Train.mxlc,"time",norm="price") summary(wtp.time) vcov(Train.mxlc,what="rpar")