[R] standardized/studentized residuals with loess

Bert Gunter gunter.berton at gene.com
Thu Nov 11 18:26:36 CET 2010


This is a simple and sensible question that does not have a simple
answer. It's a research issue, and you should go to the literature to
see what approaches seem appropriate.

HOWEVER, one simple descriptive approach -- which, however, may have
important statistical flaws -- is to run loess on the absolute values
(or,perhaps, their sqare roots)of the raw residuals. I think this
might be asymptotically reasonable with a fixed smoothing window, but
small sample behavior could well be awful. Carefully done simulations
might help determine this.

As I said, no simple answer. Perhaps others with real expertise might
comment/correct -- maybe offlist, as this seems to be wandering from
R.

-- Bert



On Thu, Nov 11, 2010 at 5:08 AM, Oliver Frings
<oliverfrings at googlemail.com> wrote:
> Hi Josh,
>
> many thank's for your reply. I tried to read up on this more and to be frank
> I got a bit confused about the exact definition of residual standardization.
> It occurs to me that different people have different definitions and that it
> can be done with and without the leverage of each point. Anyhow, the way you
> did it seems correct to me! My only problem is now that it assumes the same
> standard error for each point. My data have definitely different standard
> deviations at different points. So I was wondering if there is a way to do
> it that accounts for the different standard deviations at different points?
>
> Many thanks!
>
> /Oliver
>
> On Wed, Nov 10, 2010 at 8:21 PM, Joshua Wiley <jwiley.psych at gmail.com>wrote:
>
>> Hi Oliver,
>>
>> As a warning, I may be missing something too.  I did not see something
>> explicit in base R or MASS.  In a quick scan of the fourth edition of
>> the MASS book, I did not read anything that it is
>> illogical/unreasonable to try to find standardized residuals (but my
>> knowledge of local regression approaches nil).  With that background,
>> I proceeded to blithely scavenge from other functions until I came up
>> with this:
>>
>> loess.stdres <- function(model) {
>>  res <- model$residuals
>>  s <- sqrt(sum(res^2)/(length(res) - model$enp))
>>  stdres <- res/(sqrt(1 - hat(res)) * s)
>>  return(stdres)
>> }
>>
>> ## now for a half-baked check
>>
>> ## fit linear model and local regression
>> cars.lm <- lm(dist ~ speed, cars)
>> cars.lo <- loess(dist ~ speed, cars)
>>
>> ## these seem somewhat similar
>> rstandard(cars.lm)
>> c(scale(residuals(cars.lm)))
>>
>> ## these seem somewhat similar too
>> loess.stdres(cars.lo)
>> c(scale(cars.lo$residuals))
>>
>>
>> Cheers,
>>
>> Josh
>>
>>
>>
>> On Wed, Nov 10, 2010 at 9:24 AM, Oliver Frings
>> <oliverfrings at googlemail.com> wrote:
>> > Hi all,
>> >
>> > I'm trying to apply loess regression to my data and then use the fitted
>> > model to get the *standardized/studentized residuals. I understood that
>> for
>> > linear regression (lm) there are functions to do that:*
>> > *
>> > *
>> > fit1 = lm(y~x)
>> > stdres.fit1 = rstandard(fit1)
>> > studres.fit1 = rstudent(fit1)
>> >
>> > I was wondering if there is an equally simple way to get
>> > the standardized/studentized residuals for a loess model? BTW
>> > my apologies if there is something here that I'm missing.
>> >
>> > All the best,
>> > *
>> > *
>> > *Oliver *
>> >
>> >        [[alternative HTML version deleted]]
>> >
>> > ______________________________________________
>> > 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.
>> >
>>
>>
>>
>> --
>> Joshua Wiley
>> Ph.D. Student, Health Psychology
>> University of California, Los Angeles
>> http://www.joshuawiley.com/
>>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>



-- 
Bert Gunter
Genentech Nonclinical Biostatistics



More information about the R-help mailing list