[R] binary

Peter Ehlers ehlers at ucalgary.ca
Mon Jan 25 19:05:37 CET 2010


Val wrote:
> Hi all
> 
> Assume I have a data set xx;
> 
> Group: 1=group1  , 2=group2
> 
> IQ:  1= High, 0 =low
> 
> fit <- glm(IQ ~group, data = xx, family = binomial())
> 
> summary(fit)
> 
> Results
> 
>                    Estimate Std. Error z value Pr(>|z|)
> 
> (Intercept) -2.55456    0.210 -12.273  < 5e-16 ***
> 
>  group          0.36180      0.076   3.952     5.24e-05 ***
> 
> the odd ratio = exp(0.36180 )= 1.435912
> 
> My question is that the log-odd  estimate 0.3618  is it for group1 or group2?
> 
> What does the odd ratio 1.43359 is interpreted?

Val,
   Before using R's model fitting functions, it helps
   to understand your model. See any introductory text
   on logistic regression.

   Despite what you claim, it appears that your data 'set'
   may be a data.frame with variables 'IQ' and 'group',
   something like this:

set.seed(34)
xx <- data.frame(IQ = sample(0:1, 10, TRUE), group = gl(2, 5))
xx

   The summary you show was not produced by R, at least
   not as you show it. Here's the result for the above
   data:

fit <- glm(IQ ~ group, data=xx, family=binomial())
summary(fit)

## snipped R output
Coefficients:
             Estimate Std. Error z value Pr(>|z|)
(Intercept)  -0.4055     0.9129  -0.444    0.657
group2        0.8109     1.2910   0.628    0.530

## end R output

   Note the '2' in 'group2'. R is smart. It let's you
   know which level of factor 'group' should get the
   added 0.8109 in its log-odds estimate. From your
   reported output it would be impossible to tell that.
   You might have set 'group' to have level '2' as the
   reference level, in which case R would show a
   'group1' row.

   For more on logistic regression, you could consult
   Wikipedia, but here's a brief explanation of your
   simple case:
   Consider two models, one for each group:

   log(Pr(IQ=1)/Pr(IQ=0)) = const_1  (group 1)
   log(Pr(IQ=1)/Pr(IQ=0)) = const_2  (group 2)

   Combine these into a single model, using an
   indicator variable to signal the group:

   log(Pr(IQ=1)/Pr(IQ=0)) = beta_0 + beta_1 * Indic(group 2)

   where Indic(group 2) = 1 for group 2 and 0 otherwise and
   beta_0 = const_1,
   beta_0 + beta_1 = const_2.

This should help you answer your questions yourself.

  - Peter Ehlers


> 
> Thanks in advance
> 
> ______________________________________________
> 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.
> 
> 

-- 
Peter Ehlers
University of Calgary



More information about the R-help mailing list