# [R] using residuals of binomial GLM

Yuval Sapir sapiryuval at gmail.com
Tue Mar 24 15:02:41 CET 2009

```Hi all,
This is more a question in statistics, but I hope to get also the R
practice for my question:
I have an ancova model where the response variable is flowering (plant
has a flower = 1, no flower = 0). The explanatory variables are leaf
length, leaf thick (both continuous variables), and soil type (factorial
with three levels):
> model<-glm(flower~(thick+length)*soil,family="binomial")
>summary(aov(model))
In the aov summary I find a significant effect of all variables, and a
significant interaction between thick and soil, so I want to explore
this interaction after "cleaning" the effect of length. I thought of two
possible ways to extract the residuals:
> res.thick<-resid(update(model,~.-thick-soil-thick:soil))
or:
> res.thick<-resid(glm(flower~length+length:soil,family="binomial"))
I validated that the two methods give the same results. Anyhow, now I
want to compare the effect of thick on flowering probability,separately
for each soil. But the residuals extracted are not 0 or 1 anymore.
Linear glm, such as
> model1<-glm(res.thick1~thick*soil)
doesn't seem to be right, and, moreover, I am interested in the
estimated coefficients and their interpretation (say - plotting a
meaningful graph). How can I get a logistic regression from residuals?
Do I NEED logistic regression? How should I understand the coefficients
I get in summary of the residuals model? How can I use the results of
the residuals model for plotting the separate lines for the probability
(logistic) curve?
Yuval

--
Yuval Sapir, PhD
Porter School of Environmental Studies
Dept. of Plant Sciences
Tel Aviv University, Tel Aviv, 69978 Israel
Mobile:054-7203140; Lab: 03-6405877

http://www.yeruka.org.il/

```