Solved – How to fit a curve at a 95% “envelope” over data points

curve fittingMATLABquantile regressionquantiles

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.

Best Answer

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.