In respect of fitting piecewise linear regressions, have you looked at the "segmented" package?
cheers, Rolf Turner On 18/01/12 04:30, 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? Is there an easier way to calculate the confidence interval for a non-linear regression? 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.
______________________________________________ R-help@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.