[R] What is the most useful way to detect nonlinearity in logistic regression?
Peter Dalgaard
p.dalgaard at biostat.ku.dk
Sun Dec 5 16:15:57 CET 2004
Peter Dalgaard <p.dalgaard at biostat.ku.dk> writes:
> Re. the smoothed residuals, you do need to be careful about the
> smoother. Some of the "robust" ones will do precisely the wrong thing
> in this context: You really are interested in the mean, not some
> trimmed mean (which can easily amount to throwing away all your
> cases...). Here's an idea:
>
> x <- runif(500)
> y <- rbinom(500,size=1,p=plogis(x))
> xx <- predict(loess(resid(glm(y~x,binomial))~x),se=T)
> matplot(x,cbind(xx$fit, 2*xx$se.fit, -2*xx$se.fit),pch=20)
>
> Not sure my money isn't still on the splines, though.
Doh. You might also want to make sure that the residuals are of a type
that can be _expected_ to have mean zero. Apparently, the default
deviance residuals do not have that property, whereas response
residuals do. I did check that loess (as opposed to lowess!) does a
plain least-squares based fitting by default, but I didn't think to
check what kind of residuals I was looking at.
Serves me right for posting way beyond my bedtime...
Anyways, you're probably better off believing Frank and not me in
these matters.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
More information about the R-help
mailing list