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. red= nls fit, orange= "CI"

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.

  • $\begingroup$ 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. $\endgroup$
    – StasK
    Commented Apr 22, 2015 at 13:48
  • $\begingroup$ possible duplicate of Two ways of using bootstrap to estimate the confidence interval of coefficients in regression $\endgroup$
    – StasK
    Commented Apr 22, 2015 at 13:50
  • $\begingroup$ @StasK I believe they want confidence intervals for the predictions. $\endgroup$
    – Roland
    Commented Apr 22, 2015 at 14:14
  • $\begingroup$ 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. $\endgroup$
    – StasK
    Commented Apr 22, 2015 at 14:19
  • $\begingroup$ @Roland that's correct. I've made some changes to the original post. Could you help me out? $\endgroup$
    – linda
    Commented Apr 27, 2015 at 18:16


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.