[R] logistic regression by group?

Noah Silverman noah at smartmediacorp.com
Thu Mar 4 20:22:12 CET 2010


Thanks for the quick reply.

I cant give any sample code as I don't know how to code this in R. 
That's why I tried to pass along some pseudo code.

I'm looking for the best "beta" that maximize likelihood over all the
groups.  So, while your suggestion is close, it isn't quite what I need.

I've seen the formula written as:

L = product( exp(xb) / sum(exp(xb)) )

Where sum(exp(xb))  represents the sum of all the items in the group.

Does that make sense?


On 3/4/10 4:04 AM, Corey Sparks wrote:
> Hi, first, you should always provide some repeatable code for us to have a
> look at, that shows what you have tried so far.  
> That being said,  you can use the subset= option  in glm to subdivide your
> data and run separate models like that, e.g.
> fit.1<-glm(y~x1+x2, data=yourdat, family=binomial, subset=group==1)
> fit.2<-glm(y~x1+x2, data=yourdat, family=binomial, subset=group==2)
> where group is your grouping variable.
> Which should give you that kind of stratified model.
> Hope this helps,
> Corey
> -----
> Corey Sparks, PhD
> Assistant Professor
> Department of Demography and Organization Studies
> University of Texas at San Antonio
> 501 West Durango Blvd
> Monterey Building 2.270C
> San Antonio, TX 78207
> 210-458-3166
> corey.sparks 'at' utsa.edu
> https://rowdyspace.utsa.edu/users/ozd504/www/index.htm

More information about the R-help mailing list