[R] What is the most useful way to detect nonlinearity in lo

(Ted Harding) Ted.Harding at nessie.mcc.ac.uk
Sun Dec 5 20:38:00 CET 2004

On 05-Dec-04 Peter Dalgaard wrote:
> 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...

Hi Peter,

Yes, the above is certainly misleading (try it with 2000 instead
of 500)! But what would you suggest instead?


E-Mail: (Ted Harding) <Ted.Harding at nessie.mcc.ac.uk>
Fax-to-email: +44 (0)870 094 0861  [NB: New number!]
Date: 05-Dec-04                                       Time: 19:38:00
------------------------------ XFMail ------------------------------

More information about the R-help mailing list