
How to retriev V_r2 in FuncFit

remolorio
Hi I am using
Function straightline(w,x) :Fitfunc WAVE w ; Variable x return w[0]+w[1]*x End
in a looped FuncFit command in a procedure. I could not use the CurveFit command - there seem to be some complication in my particular code that only work with FuncFit. So Far so good. How can I retrieve the V_r2 variable here? it does not seem to be generated automatically as during the CurveFit command.
Thanks
Remo
CurveFit can work in a function:
Note that in the above, V_r2 is a local variable when CurveFit is run in a function, whereas it is global if run interactively.
DisplayHelpTopic("Special Variables for Curve Fitting")
So I simply copied it to a global variable in the above code.
Hope this helps.
EDIT:
Here is code that works with FuncFit - note that V_r2 is not calculated directly from the fit - I used StatsLinearRegression.
October 31, 2018 at 03:57 am - Permalink
The assumption is that a user-defined fit function is nonlinear, and the r-squared statistic is not valid. You can compute it pretty easily after the fact; it helps to generate the residual wave from your fit as a start.
But you should be able to use CurveFit line in your code- what went wrong?
October 31, 2018 at 09:14 am - Permalink
Thanks for the replies,
The issue with using CurveFit instead of FuncFit is that I get a syntax error for the former in the expression that defines my X range as a function of two variables:
Remo
November 1, 2018 at 03:50 am - Permalink
CurveFit requires usage of the "kwCWavef" keyword if an explicit coefficient wave is given
Curvefit line, kwCWave=W_coef y_wave[10,50] /X= x_wave[10,50]
Have a close look on the definitions of FuncFit and CurveFit in the manual
HJ
November 1, 2018 at 04:01 am - Permalink
Ah I see, thanks for that hint HJ.
Now I can use Curvefit and the issue with the V_r2 is resolved.
Thanks!
November 1, 2018 at 04:08 am - Permalink