# standardized/studentized residuals with loess

4 messages
Open this post in threaded view
|
Report Content as Inappropriate

## standardized/studentized residuals with loess

 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: standardized/studentized residuals with loess

 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 <[hidden email]> 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]] > > ______________________________________________ > [hidden email] 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/______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.
Open this post in threaded view
|
Report Content as Inappropriate

## Re: standardized/studentized residuals with loess

 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 <[hidden email]>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 > <[hidden email]> 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]] > > > > ______________________________________________ > > [hidden email] 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]] ______________________________________________ [hidden email] mailing list https://stat.ethz.ch/mailman/listinfo/r-helpPLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.