I need a hand with something. I'm using curve_fit from SciPy to fit a curve with three parameters. Now, when I use it, I get this thing called pcov, which I know is the covariance matrix. But here's the thing: can I use pcov to figure out how much my predictions might be off?
I know I can calculate the error between the real data and the fitted curve, but can I somehow use pcov to get that error variance directly for a new data point I'm predicting?
Thanks in advance
Provided your model is continuous and smooth and the the covariance matrix is a good approximation (see
@Nick ODellcomments), you can use first order error propagation method to estimate first order error on your regression wrt parameters covariance.Lets say you have the following dataset and model:
We define the error function as follow:
We can then estimate the curve:
And assess the confidence interval:
It graphically leads to:
And gives an envelope where the curve would be found (if smooth and continuous) using parameters first order variation wrt their uncertainty.