Line fits and the use of V_rab

I realized that Line fits do not output a covariance matrix even with /M=2, and a correlation coefficient V_rab is given instead. I have a bit trouble wrapping my head around using this correlation coefficient in error propagation. Is the following correct when calculating the error from a multiplication or division of slope and intercept (e.g., a/b):

NVAR coefCorr = V_rab
Wave cw = W_coef
Wave sw = W_sigma
Variable err    = sqrt(  (sw[0]/cw[0])^2 + (sw[1]/cw[1])^2 + 2*(coefCorr*sw[0]*sw[1])/(cw[0]*cw[1]) )

Here I 'convert' the correlation coefficient into a covariance-like factor by multiplying with sigma. I am not sure if I make a mistake on the order of sqrt() or x^2.

Why I need this? To generate derived values such as the x-intercept of a line in my Super Quick Fit package, of course. ;)

I would need to think hard about your equations for error propagation, but if it helps you can force generation of the covariance matrix by using a user defined function:

Make/O/D wData = {1,3,4,4,5,6}
Display wData
ModifyGraph mode=3
CurveFit/M=2/NTHR=0 line  wData /D
//  fit_wData= W_coef[0]+W_coef[1]*x
//  W_coef={1.619,0.88571}
//  V_chisq= 1.10476;V_npnts= 6;V_numNaNs= 0;V_numINFs= 0;
//  V_startRow= 0;V_endRow= 5;V_q= 1;V_Rab= -0.825723;V_Pr= 0.96204;
//  V_r2= 0.925522;
//  W_sigma={0.38,0.126}
//  Coefficient values ± one standard deviation
//      a   =1.619 ± 0.38
//      b   =0.88571 ± 0.126
//  ** M_Covar not created **
Function myLineFun(w,x) : FitFunc
    Wave w
    Variable x
    //CurveFitDialog/ These comments were created by the Curve Fitting dialog. Altering them will
    //CurveFitDialog/ make the function less convenient to work with in the Curve Fitting dialog.
    //CurveFitDialog/ Equation:
    //CurveFitDialog/ f(x) = a + b * x
    //CurveFitDialog/ End of Equation
    //CurveFitDialog/ Independent Variables 1
    //CurveFitDialog/ x
    //CurveFitDialog/ Coefficients 2
    //CurveFitDialog/ w[0] = a
    //CurveFitDialog/ w[1] = b
    return w[0] + w[1] * x
End
Make/D/N=2/O W_coef
W_coef[0] = {1,0}
FuncFit/M=2/NTHR=0 myLineFun W_coef  wData /D
//Fit converged properly
//  fit_wData= myLineFun(W_coef,x)
//  W_coef={1.6191,0.88571}
//  V_chisq= 1.10476;V_npnts= 6;V_numNaNs= 0;V_numINFs= 0;
//  V_startRow= 0;V_endRow= 5;
//  W_sigma={0.38,0.126}
//  Coefficient values ± one standard deviation
//      a   =1.6191 ± 0.38
//      b   =0.88571 ± 0.126
print M_Covar
// M_Covar[0][0]= {0.144671,-0.0394558}
// M_Covar[0][1]= {-0.0394558,0.0157823}

 

Hi Kurt, thanks a lot for the hint. While I do not want to replicate the Line function (this would introduce some clutter in my package https://www.wavemetrics.com/node/21866 ), I was able to test that my approach is correct:

Make/O/D wData = {1,3,4,4,5,6}
Display wData
ModifyGraph mode=3
CurveFit/M=2/NTHR=0 line  wData /D
print V_rab*W_sigma[0]*W_sigma[1]
  -0.0394558

Which is (almost) equal to:

FuncFit/M=2/NTHR=0 myLineFun W_coef  wData /D
print M_Covar[0][1]
  -0.0394559

If this is not just a strange coincidence with this particular data set, then I guess my approach using coefCorr*sw[0]*sw[1] as a replacement for the coefficient matrix is OK. Great.