[R] Same regression per sub-group: apply?
Gabor Grothendieck
ggrothendieck at gmail.com
Fri Dec 7 13:41:32 CET 2007
See:
https://stat.ethz.ch/pipermail/r-help/2007-May/132866.html
On Dec 7, 2007 3:32 AM, Rense Nieuwenhuis <r.nieuwenhuis at student.ru.nl> wrote:
> Dear helpers,
>
> I've come up with what is probably a simple problem, but I cannot
> find the solution. I have a data-set containing survey-data from
> several countries. What I want to do is to perform some regression
> analyses, for each country separately. The question is, how to do
> this nicely (thus without repeating the same syntax with another
> `subset' argument).
>
> I thought of the following:
>
> model.per.country <- tapply(data, data$COUNTRY, function(x) glm
> (dependent.var ~ FEMALE + AGE + EDUCLIN + (), family=binomial,
> data=capital))
>
> But this does not work. What goes wrong, I think, is that the
> dependent variable is clustered according to `Country', but not so
> for the predictors. The error message I received:
>
> Error in tapply(dat, dat$COUNTRY, function(x) glm(participate ~
> FEMALE + :
> arguments must have same length
> >
>
>
> Could you please help me solving this little problem?
>
> Thanks in advance:
>
> Rense Nieuwenhuis
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> 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