Quantcast

plotting confidence bands from predict.nls

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

plotting confidence bands from predict.nls

Penny B
I am trying to find a confidence band for a fitted non-linear curve. I
see that the predict.nls function has an interval argument, but a
previous post indicates that this argument has not been implemented.  Is
this still true? I have tried various ways to extract the interval
information from the model object without success. My code is:

Model.predict <-  predict(My.nls.model,  se.fit=TRUE,  interval =
"confidence",  level = 0.95)   ,

where My.nls.model is an nls object, I was able to extract the
predictions okay.


Thank you for your help.
Penny.

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plotting confidence bands from predict.nls

Uwe Ligges-3
Much quicker than asking for help on the list is to read the help file
(which you have been asked to do in the posting guide you hopefully read).

?predict.nls tells us:

"interval A character string indicating if prediction intervals or a
confidence interval on the mean responses are to be calculated. At
present this argument is ignored."

Best,
Uwe Ligges




On 07.05.2011 06:17, Penny Bilton wrote:

> I am trying to find a confidence band for a fitted non-linear curve. I
> see that the predict.nls function has an interval argument, but a
> previous post indicates that this argument has not been implemented. Is
> this still true? I have tried various ways to extract the interval
> information from the model object without success. My code is:
>
> Model.predict <- predict(My.nls.model, se.fit=TRUE, interval =
> "confidence", level = 0.95) ,
>
> where My.nls.model is an nls object, I was able to extract the
> predictions okay.
>
>
> Thank you for your help.
> Penny.
>
> ______________________________________________
> [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.

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plotting confidence bands from predict.nls

Gabor Grothendieck
In reply to this post by Penny B
On Sat, May 7, 2011 at 12:17 AM, Penny Bilton <[hidden email]> wrote:

> I am trying to find a confidence band for a fitted non-linear curve. I see
> that the predict.nls function has an interval argument, but a previous post
> indicates that this argument has not been implemented.  Is this still true?
> I have tried various ways to extract the interval information from the model
> object without success. My code is:
>
> Model.predict <-  predict(My.nls.model,  se.fit=TRUE,  interval =
> "confidence",  level = 0.95)   ,
>
> where My.nls.model is an nls object, I was able to extract the predictions
> okay.
>

You can get these intervals using nls2.   The as.lm function has an
nls method which returns the lm model tangent to an nls model and use
can use predict.lm on that.

> library(nls2)
> fm <- nls(demand ~ SSasympOrig(Time, A, lrc), data = BOD)
> predict(as.lm(fm), interval = "confidence")
        fit       lwr      upr
1  7.887451  3.701701 12.07320
2 12.524979  8.219483 16.83047
3 15.251674 11.813306 18.69004
4 16.854870 13.668094 20.04164
5 17.797489 14.026668 21.56831
6 18.677578 13.393630 23.96153
> predict(as.lm(fm), interval = "prediction")
        fit        lwr      upr
1  7.887451 -0.3349547 16.10986
2 12.524979  4.2409738 20.80898
3 15.251674  7.3833942 23.11995
4 16.854870  9.0932340 24.61651
5 17.797489  9.7783530 25.81663
6 18.677578  9.8453897 27.50977
Warning message:
In predict.lm(as.lm(fm), interval = "prediction") :
  Predictions on current data refer to _future_ responses


--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plotting confidence bands from predict.nls

Laurent Rhelp
In reply to this post by Penny B
Le 07/05/2011 06:17, Penny Bilton a écrit :

> I am trying to find a confidence band for a fitted non-linear curve. I
> see that the predict.nls function has an interval argument, but a
> previous post indicates that this argument has not been implemented.  
> Is this still true? I have tried various ways to extract the interval
> information from the model object without success. My code is:
>
> Model.predict <-  predict(My.nls.model,  se.fit=TRUE,  interval =
> "confidence",  level = 0.95)   ,
>
> where My.nls.model is an nls object, I was able to extract the
> predictions okay.
>
>
> Thank you for your help.
> Penny.
>
> ______________________________________________
> [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.
>
You can use the bootstrap methodology using the predicted values
assessed through the N replications.

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plotting confidence bands from predict.nls

ioanna
How do you use bootstrap to estimate the confidence as well as the prediction intervals in nonlinear regression ?
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: plotting confidence bands from predict.nls

Prof Brian Ripley
On 05/02/2012 08:10, ioanna wrote:
> How do you use bootstrap to estimate the confidence as well as the prediction
> intervals in nonlinear regression ?

With difficulty!

There is far too little here to go on, and this seems an odd question
unless it is homework (why dictate a problem-strewn method of solution
if this is a real problem?)

The real issue is how to bootstrap nonlinear regression, and you will
find that discussed in all good books on the subject, such as Venables &
Ripley and Davison & Hinkley.  It is not trivial and the solutions are
not altogether satisfactory ....

> --
> View this message in context: http://r.789695.n4.nabble.com/plotting-confidence-bands-from-predict-nls-tp3505012p4358572.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.


--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: plotting confidence bands from predict.nls

ioanna

It is not homework. My problem is this: I used nonlinear regression to fit a lognormal cumulative distribution to the probability of a buildings' collapse against a measure of seismic intensity. I am able to obtain the asymptotic confidence intervals. I am not , however, certain that they are accurate and I wonder whether a bootstrap or even a Monte carlo could improve their accuracy. You see I want a realistic represntation of the confidence intervals as I need to propagate it further in the risk assessment. Perhaps I m wrong. Could you please enlighten me?

Yanna

Date: Sun, 5 Feb 2012 03:42:05 -0800
From: [hidden email]
To: [hidden email]
Subject: Re: plotting confidence bands from predict.nls

On 05/02/2012 08:10, ioanna wrote:
> How do you use bootstrap to estimate the confidence as well as the prediction
> intervals in nonlinear regression ?

With difficulty!

There is far too little here to go on, and this seems an odd question
unless it is homework (why dictate a problem-strewn method of solution
if this is a real problem?)

The real issue is how to bootstrap nonlinear regression, and you will
find that discussed in all good books on the subject, such as Venables &
Ripley and Davison & Hinkley.  It is not trivial and the solutions are
not altogether satisfactory ....

> --
> View this message in context: http://r.789695.n4.nabble.com/plotting-confidence-bands-from-predict-nls-tp3505012p4358572.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> [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.


--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[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.



If you reply to this email, your message will be added to the discussion below:
http://r.789695.n4.nabble.com/plotting-confidence-bands-from-predict-nls-tp3505012p4358800.html
To unsubscribe from plotting confidence bands from predict.nls, click here.
NAML
Loading...