[R] Need help interpreting the logit regression function

Rohit Pandey rohitpandey576 at gmail.com
Mon Jan 16 00:51:22 CET 2012


Hello R community,

I have a question about the logistic regression function.
Specifically, when the predictor variable has not just 0's and 1's,
but also fractional values (between zero and one). I get a warning
when I use the "glm(formula = ... , family = binomial(link =
"logit"))" which says:

"In eval(expr, envir, enclos) : non-integer #successes in a binomial glm!"

I looked this up on a few forums and got the impression that I could
go ahead and ignore this warning. If that is not so, please suggest
another function that can be used (and no need to read further).

But if this is usable, then the numbers are not making sense for me.

What I am seeing is best explained through an example:

#Setting up the data:
>c(1,1,0,0,1,1,0,1,1,0,0,0,0,1,1,0,0,0,0,1)->resp
>indep<-rep(2:3,10)
#Running the logistic regression:
>glm(formula = resp~as.factor(indep) , family = binomial(link = "logit"),na.action = na.pass)
#Gives me:
Coefficients:
      (Intercept)  as.factor(indep)3
       -1.692e-16         -4.055e-01
>table(indep,resp)
     resp
indep 0 1
    2   5 5
    3   6 4

Meaning that the odds for '2' to have a favorable outcome are 5/5 =1;
and the odds for 3 are 4/6 = 0.6666

And indeed, exp( -1.692e-16) = 1 and exp( -1.692e-16+-4.055e-01) = 0.66.

But when I change all the 1's of the independent variable to 0.5, the
odds should both be half of what they were before (right?).

However, when I run the logistic function after doing this,

>resp[resp==1]=0.5
>glm(formula = resp~as.factor(indep) , family = binomial(link = "logit"),na.action = na.pass)
(Intercept)  as.factor(indep)3
          -1.0986            -0.2877

Now, exp(-1.0986) = 0.3333 and exp(-1.0986-0.2877) = 0.25.

These are nothing like the previous odds halved. So, either I am using
the function wrong or interpreting it wrong. Can some one please point
me in the right direction..

-- 

Thanks in advance,

Rohit



More information about the R-help mailing list