I have an equation to predict the weight of manatees from their age, in days (dias, in portuguese):

R <- function(a, b, c, dias) c + a*(1 - exp(-b*dias))

I have modelled it in R, using nls(), and got this graphic:

enter image description here

Now I want to calculate the 95% confidence interval and plot it in the graphic. I've used the lower and higher limits for each variable a, b and c, like this:

lower a = a - 1.96*(standard error of a)
higher a = a + 1.96*(standard error of a)
(the same for b and c)

then I plot a lower line using lower a,b,c and a higher line using higher a,b,c. But I'm not sure if that's the right way to do it. It is giving me this graphic:

enter image description here

Is this the way to do it, or am I doing it wrong?


1 Answer 1

  1. This QA on this site explains the math to create confidence bands around curves generated by nonlinear regression: Shape of confidence and prediction intervals for nonlinear regression

  2. If you read further, it will help to distinguish confidence intervals for the parameters from confidence bands for the curve.

  3. Looking at your graph, it sure looks like you have data from four animals, measuring each on many days. If so, fitting all the data at once violates one of the assumptions of regression -- that each data point be independent (or that each residual has independent "error"). You might consider fitting each animal's tracing individually, or use a mixed model to fit them all at once.

  • 5
    $\begingroup$ +1 The third point is crucial: any effort to compute CIs or confidence bands assuming these data are independent will produce woefully inadequate (that is, short) intervals. It might help the O.P. to emphasize that the method proposed in the question is definitely wrong: it neglects the (strong) correlation among parameter estimates and aggregates the confidence limits incorrectly. The net result actually looks sort of reasonable (purely by accident and luck) but to my eye it still is not sufficiently conservative. $\endgroup$
    – whuber
    Commented Apr 1, 2014 at 16:38

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.