[R] Grouped regression

Suresh Krishna madzientist at gmail.com
Sun Jul 8 10:11:14 CEST 2012


I am a very occasional user of R, and will be grateful for some help  in  
constructing a regression across groups.

Here is an example:

Sex[120:144]<-factor(TG) #Renaming some males to transgender, to create 3  
groups, male, female and transgender

out<-lm(Bwt~Sex/Hwt) #Gives me 3 separate linear regressions for groups M,  
F and TG

What I now want to do is to examine subsets of this, where groups F and TG  
have the same slope (and/or intercept). I want to do this in such a way  
that future calls to anova() for model comparison will recognize the  
subset structure: so I do not want to just reset the levels with F to TG  
and then examine the regression.

Thanks much,


More information about the R-help mailing list