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

Jan van der Laan rhelp at eoos.dds.nl
Thu Apr 14 10:01:33 CEST 2011


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

North
    Province A
       Municipality 1
       Municipality 2
       Municipality 3
       ...
    Province B
       Municipality 1
       ...
    ...
West
    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,

Jan



More information about the R-help mailing list