I'm lacking the proper precise language to easily look up what I've been asked to do, so please forgive me if this is a trivial task (but please do tell me what this is called).

I have some data set which I'm fitting a curve to, and perform standard least-squares regression. I now want to fit curves with the same functional form with parameters such that:

  1. 95% of the data falls above the curve
  2. 95% of the data falls below the curve

to "envelope" the data at some percentile as a way of visually representing the relationship between my original fit and the data.

For clarity, I'm not trying to calculate confidence intervals in my fit parameters, but rather to estimate "best case" and "worst case" scenarios of my functional relationship.

I'm largely using matlab's curve fitting toolbox right now, but it looks like I'll have to do this manually so I'm not married to my tools.

EDIT: Whuber has explained to me that I'm trying to do a Quantile Regression at the 5th and 95th percentiles for the models I'm trying to fit.

  • 1
    $\begingroup$ Could you please elaborate on the distinction you make between "best case ... worst case" and confidence intervals for the parameters? They would seem to be based on the same underlying objectives, so how exactly are they supposed to differ? $\endgroup$ – whuber Jun 15 '17 at 13:44
  • $\begingroup$ @whuber Great question- a little context on what I'm doing might help here. I'm fitting dose-response curves to various outbreaks, and I've been asked to a) fit my probit/beta-poisson/exponential models to the data directly, b) create a version of each model that fits the data at the high and low percentile marks (5th/95th), which have a physical meaning close to "this is a conservative/aggressive model for this pathogen that over/underestimates illnesses." This is quite different from confidence intervals in the parameters, which tell me more about how good my fit is. $\endgroup$ – dhruvfire Jun 16 '17 at 19:56
  • $\begingroup$ Thank you. This is quite different from what you have asked, too. Your comment is asking about how to do a quantile regression version of your models. If you would like adequate answers, then please modify your question accordingly. $\endgroup$ – whuber Jun 16 '17 at 20:45
  • $\begingroup$ Is a quantile regression not what I'm trying to do? I've been reading up bits and pieces on that since you added the tag to my question and it seems to do exactly what I've described? EDIT: Sorry, misunderstood, will edit original question. $\endgroup$ – dhruvfire Jun 16 '17 at 21:20

If your data set is quite large, you could consider fitting a 5%- and a 95%-quantile regression, e.g. representing the functional relationship by splines.


One possibile procedure to consider:

A) First fit the data normally, perhaps to a spline.

B) Add an offset to the fitted equation, perhaps iteratively, until 95% of the points are below the now-offset equation. This would be the upper bound.

C) Subtract an offset from the fitted equation, perhaps iteratively, until 95% of the points are above the now-offset equation. This would be the lower bound.

  • $\begingroup$ This solution can work for ordinary least squares, but in this setting involving "functional forms" (which would seem to imply least squares to fit nonlinear curves) it can produce nonsense, since it assumes that the offset curves are in the same family--which often they are not. $\endgroup$ – whuber Jun 15 '17 at 13:43
  • $\begingroup$ My meaning is that a single curve is fitted to all data in step A. Steps B and C either add or subtract an offset to that same equation. $\endgroup$ – James Phillips Jun 15 '17 at 23:01
  • $\begingroup$ Suppose, to be concrete about this, that the intended functional form of the curve is $x\to y=ae^{bx}$. Then no curve of the form $ae^{bx}+c$ for $c\ne 0$ will be in that form--and so your solution cannot even get started. $\endgroup$ – whuber Jun 16 '17 at 18:11
  • $\begingroup$ @JamesPhillips whuber is correct here- I'm looking to refit my model parameters, not shift a curve of the same shape. I've included a bit more information on the goal in a response to whuber's comment on the question above. $\endgroup$ – dhruvfire Jun 16 '17 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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