[R] Need help in calculating studentized residuals/leverage values of non-linear model [nls()]

Giam Xingli giam at nus.edu.sg
Thu Apr 9 02:19:01 CEST 2009


Hi Dieter,

Yes, I understand the definition of studentized residuals and I also know that studentizing the residuals is an easy exercise. However, I need the hat ('leverage')-values to studentize the residuals. I tried to use hatvalues() to obtain the leverage values but while it works on glm and lm objects, it doesn't work on nls() objects.

I also tried to do this:

X <- model.matrix(model) # where model is an nls() object
H <- X %*% solve( t(X) %*% X ) %*% t(X)
hatvalues <- diag(H)

But model.matrix didn't work either. 

That is why I posted the question of getting the studentized residuals or the leverage values of nls() objects. I hope you don't misunderstand me, I'm sorry the original post came across as a 'homework' question.

Many thanks,
Xingli
(P.S. I saw your reply on CRAN. However I didn't get the daily digest, so I am replying to your previous post. Sorry about that!)  

------------------------------

Message: 72
Date: Mon, 6 Apr 2009 12:39:07 -0700
From: <rkevinburton at charter.net>
Subject: Re: [R] Need help in calculating studentized
	residuals/leverage values	of non-linear model [nls()]
To: Dieter Menne <dieter.menne at menne-biomed.de>,
	r-help at stat.math.ethz.ch
Message-ID: <20090406153907.97VPO.402395.root at mp16>
Content-Type: text/plain; charset=utf-8

Is the output of residuals() the studentized residuals or just the residuals?

---- Dieter Menne <dieter.menne at menne-biomed.de> wrote: 
> Giam Xingli <giam <at> nus.edu.sg> writes:
> 
> >    I hope I can get advice regarding the calculation of leverage values or
> >    studentized residual values of a non-linear regression model. It seems like
> >    rstudent() does not work on a nls object.
> 
> residuals() should work for nls.
> 
> Dieter
> 
> ______________________________________________
> 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.



More information about the R-help mailing list