[R] mlogit and model-based recursive partitioning

Achim Zeileis Achim.Zeileis at uibk.ac.at
Tue Oct 2 08:24:06 CEST 2012


Tudor:

> Has anyone tried to model-based recursive partition (using mob from 
> package party; thanks Achim and colleagues) a data set based on a 
> multinomial logit model (using mlogit from package mlogit; thanks Yves)?

Interesting question: in principle, this is possible but I wouldn't know 
of anyone who has tried this.

> I attempted to do so, but there are at least two reasons why I could 
> not. First, in mob I am not quite sure that a model of class StatModel 
> exists for mlogit models.  Second, as mlogit uses the pipe character | 
> to specify the model, I wonder how this would interact with mob which 
> uses pipe to differentiate between explanatory and segmentation 
> variables.

This is one but not the only complication when trying to actually combine 
mlogit and mob. I think the building blocks would have to be:

- Set up the data plus formula handling. As you point out, that would need 
a three-part formula separating alternative-specific and subject-specific 
regressors and partitioning variables. Furthermore you would probably need 
to translate between the long format used by mlogit (subjects x 
alternatives) to the wide format because mob would want to partition the 
subjects.

- A StatModel object would be required. Personally, if I wanted to do it, 
would try to set up the StatModel object on the fly (rather than predefine 
it in a package) so that the StatModel creator can depend on the 
formula/data. The formula/data processing described above can be done 
inside the StatModel object.

- Finally, the required methods for the fitted model object would have to 
be defined. In particular, the subject-specific gradients would be 
required. I think currently, mlogit just provides the overall gradient.

So, in summary: It can be done but it would likely need more than just an 
hour of coding...

hth,
Z

> An example (not working) of what I would like to accomplish follows below.
>
> Thanks a lot.
>
> Tudor
>
> library(party)
> library(mlogit)
> data("Fishing", package = "mlogit")
> Fish <- mlogit.data(Fishing, varying = c(2:9), shape = "wide", choice =
> "mode")
> # FIT AN mlogit MODEL
> m1 <- mlogit(mode ~ price + catch, data=Fish)
> # THE DESIRED END RESULT:  SEGMENT m1 BASED ON INCOME AND/OR OTHER POSSIBLE
> COVARIATES
>
>
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/mlogit-and-model-based-recursive-partitioning-tp4644743.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>




More information about the R-help mailing list