# How to plot the confidence interval from boot.ci output of nonlinear regression in R?

I have a data.frame with two columns (x and y) for which I have obtained a nonlinear least squares fit: -a/(b+exp(-x)).

Now I'm trying to plot the 95% confidence interval for y. My best attempt so far is based on another nonlinear fit of the standard error of y for several intervals of x: a*x^-b. This first fit +/- 1.96 the second fit are plotted below.

This seems a bit arbitrary though, so I am wondering if there is a more robust way of calculating this confidence interval? I've been exploring the bootstrap, but so far I've only been able to obtain values and I'm unsure about how to transform them into an interval which is clearly dependent on the x-value. What should I do with the values resulting from boot.ci? Or should I, if possible, bootstrap both x and y at the same time?

Let me know if I should provide more details.

• I don't think you've got your terms right. Standard deviation is a descriptive measure, square root of the variance; you probably are interested in standard errors. Correlations, or at least Pearson moment correlation, looks at the linear fit, while your fit is clearly nonlinear (although fancier rank correlations can check whether the two variables in question have a monotone, curvilinear relation). Please rethink/rephrase your question -- DO NOT REPLY BELOW, edit your original text please. Commented Apr 22, 2015 at 13:48
• Commented Apr 22, 2015 at 13:50
• @StasK I believe they want confidence intervals for the predictions. Commented Apr 22, 2015 at 14:14
• Probably; but I don't want the community waste their time answering wrong questions. As far as the bootstrap for regression goes, there's a fair number of resources and answers on this site already. Commented Apr 22, 2015 at 14:19
• @Roland that's correct. I've made some changes to the original post. Could you help me out? Commented Apr 27, 2015 at 18:16