Recent

Author Topic: How to get goodness of fit in TAChart Fit Series?  (Read 3302 times)

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
How to get goodness of fit in TAChart Fit Series?
« on: July 27, 2015, 12:38:22 pm »
Is there a field or property that delivers an estimate for the goodness of fit in TAChart's Fit Series? I well understand that R2 doesn't make sense for nonlinear regression; However, information like a p value or even Akaike's information criterion (AIC) would be useful.

Alternatively, is this information provided by the ipfpol procedure from numlib? Unfortunately, FPC's numlib is nearly undocumented.

(Note: This is a re-post of the question http://stackoverflow.com/questions/31616676/goodness-of-fit-in-tachart-fit-series at stackoverflow. I didn't get an answer there.)
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11453
  • FPC developer.
Re: How to get goodness of fit in TAChart Fit Series?
« Reply #1 on: July 27, 2015, 01:13:13 pm »
There is numlib documentation, and some examples. Problem is that both examples and documentation are older than the library files, and the documentation is Dutch.

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: How to get goodness of fit in TAChart Fit Series?
« Reply #2 on: July 27, 2015, 02:11:13 pm »
No, TAChart does not calculate any goodness-of-fit parameters. But you can do this by yourself since the results of the fitting parameters are returned by the FitSeries (properties "ParamCount" and "Param[AIndex]").

You mention non-linear fits: They are not supported by TFitSeries at all. Therefore, if you have dedicated fitting tasks you should employ an external numerical library such as the excellent dmath (https://sourceforge.net/projects/dmath/).

Sorry for not giving you an answer in your stackoverflow post. But I do not check this site regularly. Post all Lazarus-related questions here.
« Last Edit: July 27, 2015, 02:17:46 pm by wp »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: How to get goodness of fit in TAChart Fit Series?
« Reply #3 on: July 27, 2015, 06:15:56 pm »
In r49571 I added calculation of R-squared as a simple goodness-of-fit parameter (--> new read-only property "GoodnessOfFit" of TFitSeries). See also the updated FitDemo in the demos folder.

More advanced calculations would require knowledge of the standard errors of the data points. In case they are known the goodness-of-fit calculation can be performed by the event handler "OnCalcGoodnessOfFit" replacing the built-in R-squared calculation method.

jwdietrich

  • Hero Member
  • *****
  • Posts: 1232
    • formatio reticularis
Re: How to get goodness of fit in TAChart Fit Series?
« Reply #4 on: August 09, 2015, 07:47:30 pm »
Thanks for all your suggestions. I will check them and will report my experiences here.
function GetRandomNumber: integer; // xkcd.com
begin
  GetRandomNumber := 4; // chosen by fair dice roll. Guaranteed to be random.
end;

http://www.formatio-reticularis.de

Lazarus 2.2.6 | FPC 3.2.2 | PPC, Intel, ARM | macOS, Windows, Linux

 

TinyPortal © 2005-2018