# Heating data, from the Ecdat package
data("Heating",package="Ecdat")
# Heating is a "horizontal" data.frame with three choice-specific
# variables (ic: investment cost, oc: operating cost) and some
# individual-specific variables (income, region, rooms)
Heatingh <- mlogit.data(Heating,cvar=c(ic=3,oc=8,pb=17),
shape="hor.var",choice="depvar")
# a model with two choice-specific variables
summary(mlogit(depvar~ic+oc,data=Heatingh))
# same wihtout intercept
summary(mlogit(depvar~ic+oc-1,data=Heatingh))
# a model with choice-specific and individual-specific variables
summary(mlogit(depvar~ic+oc|income+rooms,data=Heatingh))
# a model with choice-specific coefficients for a choice-specific variable
summary(mlogit(depvar~ic+oc+oc:alt,data=Heatingh))
# a model with only individual-specific variables
summary(mlogit(depvar~1|income+rooms,data=Heatingh))
# the same model estimated with multinom from the nnet package
library(nnet)
summary(multinom(depvar~income+rooms,data=Heating))
Run the code above in your browser using DataLab