[R] breakpoints and nonlinear regression

Achim Zeileis Achim.Zeileis at uibk.ac.at
Tue Jan 17 19:20:20 CET 2012


On Tue, 17 Jan 2012, crimsonengineer87 wrote:

> Dear Forum,
>
> I have been wracking my head over this problem for the past few days. I have
> a dataset of (x,y). I have been able to obtain a nonlinear regression line
> using nls. However, we would like to do some statistical analysis. I would
> like to obtain a confidence interval for the curve. We thought we could
> divide up the curve into piecewise linear regressions and compute CIs from
> those portions. There is a package called strucchange that seems helpful,
> but I am thoroughly confused.
>
> 'breakpoints' is used to calculate the number of breaks in the data for
> linear regressions.  I have the following in my script:
>
> bp.pavlu <- breakpoints(Na ~ f(yield, a, b), h=0.15, breaks=3,
> data=pavludata)
> plot(bp.pavlu)
> breakpoints(bp.pavlu)
>
> But I am confused as to how to graph the piecewise functions that make up
> the curve. I am not even sure if I am using breakpoints correctly. Do I just
> give it a linear relationhip (Na ~ yield), instead of what I have?

breakpoints() currently can just handle linear (in parameters) 
regressions. So unless f(., a, b) is either known or can be written as a 
linear predictor, breakpoints() cannot estimate breaks in the model of 
interest.

If you want approximate f(., a, b) by a piecewise linear function, then 
you would use breakpoints(Na ~ yield). The result however will typically 
not be continuous. To see the result fitted() can be used. See the 
references in ?breakpoints for some examples.

However, I doubt that this is a route worth pursuing given your problem 
description...

> Is there an easier way to calculate the confidence interval for a non-linear
> regression?

If you want to use nls(), you could use simulation techniques to obtain 
confidence intervals.

Another possible alternative would be to use a GAM formulation. See e.g. 
gam() in package "mgcv".

hth,
Z

> I am new to R (as I've read in many questions), but I have most certainly
> tried many things and am just getting frustrated with the lack of examples
> for what I'd like to do with my data... I'd appreciate any insight. I can
> also provide more information if I am not clear. Thanks in advance.
>
> Julian
>
> --
> View this message in context: http://r.789695.n4.nabble.com/breakpoints-and-nonlinear-regression-tp4303629p4303629.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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