[R] Automatic splitting/combining nested categorical variable in glm

From: Jan van der Laan <rhelp_at_eoos.dds.nl>
Date: Thu, 14 Apr 2011 10:01:33 +0200

I have a categorical variable with a nested structure. For example, region: a country is split into parts, which in turn contain provinces, which contain municipalities:

Part -> Province -> Municipality


    Province A

       Municipality 1
       Municipality 2
       Municipality 3

Province B Municipality 1


    Province A


    Province B



What I would like to do is to automatically split/combine regions in a forward (starting with parts and then splitting) or backward (starting with municipalities and collapsing) manner. Do there exists methods for this in R? Googling I couldn't find anything, but perhaps I have been using the wrong terms.

Please note that I do not want to choose between using Part as covarate OR e.g. Province. I want to allow for different levels in one covariate, e.g. West split into Provinces and the remaining parts not.

    Also: I am using logistig regression (glm).

Thank you for your help.

With regards,


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. Received on Thu 14 Apr 2011 - 08:04:11 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 14 Apr 2011 - 08:40:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive