Re: [R] standard errors for predict.nls?

From: Christoph Scherber <>
Date: Fri, 07 Nov 2008 11:33:32 +0100

Dear all,

I would like to get standard errors (or confidence intervals) for *predicted* values from an nls fit.

I have tried to implement code from p.225 in MASS (bootstrapping a nls fit), but this gives only the confidence intervals of the parameter estimates, but not an overall confidence interval for the predicted value(s):

puro1<-nls(rate~a*conc/(b+conc), data=Puromycin[1:12,], start=list(a=200, b=1)) #set up nls model

# assume only one predicted value is obtained using predict(puro1,list(conc=0.02)):


	coef(nls(rate~a*conc/(b+conc), st, start=coef(puro1)))



How do I have to change the code to get the c.i. for the predicted value?

Many thanks and best wishes,

Prof Brian Ripley schrieb:

> On Mon, 3 Nov 2008, Ben Bolker wrote:

>> Prof Brian Ripley wrote:
>>>> Christoph Scherber <Christoph.Scherber <at>>
>>>> writes:
>>>>> Dear all,
>>>>> Is there a way to retrieve standard errors from nls models?
>>>>> The help page tells me that arguments
>>>>> such as are ignored...
>>>>> Many thanks and best wishes
>>>>> Christoph
>>> In general using the delta method (which is I guess what you mean, local
>>> linearization via derivatives) is nowhere near accurate enough to be
>>> useful.  That's why it has not been done on several occasions in the 
>>> past.
>>> If you think it might be, see ?delta.method in package alr3.
>>> I would suggest using simulation/bootsrapping to explore the 
>>> uncertainty.
>>> There is an example in MASS of doing so (and that illustrates some of
>>> the pitfalls).

>> Hmmm. By an example, do you mean an example of using bootstrapping to
>> explore uncertainty in general, or of using bootstrapping to get
>> standard errors of predictions from nonlinear regressions? I looked
>> through my copy of MASS (4th ed.) and found only section 5.7
>> (bootstrapping in general) and chapter 8 (nonlinear and smooth
>> regression, esp. p. 225 "bootstrapping" for getting bootstrap c.i.'s on
>> parameter estimates). I didn't find anything *specifically* covering
>> s.e./c.i. for nls predictions, but maybe that's not what you meant.
> I meant the example on p.225 on bootstrapping a nls fit (and that you 
> needed to bootstrap residuals in some cases).  You can use almost 
> identical code to set s.e./c.i. for nls predictions.

>> And yes, I meant "delta method" rather than "delta function" in my
>> original post. Oops.

>> I might add something quick/dirty/naive to the wiki giving
>> some examples of delta method/bootstrap approaches ...

>> If there is no intention to add confidence interval calculation
>> to in the foreseeable future might I suggest that the details
>> under "Value" as to what "" will do when it is implemented be
>> removed? (And perhaps even a statement to the effect [as you say
>> above] that delta method is considered unreliable?) As written it's a
>> bit of a tease ...
> I didn't write that ... and its author might have other opinions.

>> cheers
>> Ben Bolker

Dr. rer.nat. Christoph Scherber
University of Goettingen
DNPW, Agroecology
Waldweg 26
D-37073 Goettingen

phone +49 (0)551 39 8807
fax   +49 (0)551 39 8806


______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Fri 07 Nov 2008 - 10:36:35 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 11 Nov 2008 - 20:30:24 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive