Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 2110 - Calculation for Skewness and Kurtosis using TSeriesStatsTool
Summary: Calculation for Skewness and Kurtosis using TSeriesStatsTool
Status: IN_PROGRESS
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Tools (show other bugs)
Version: 19.161025
Hardware: PC Windows
: --- enhancement
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-06 23:30 EDT by Nina Kajiji
Modified: 2023-03-16 15:22 EDT (History)
2 users (show)

See Also:
Chart Series: FastLine
Delphi / C++ Builder RAD IDE Version: RAD XE8


Attachments
Contains the data and a snapshot of the output and TeeChart code (44.95 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2018-10-06 23:30 EDT, Nina Kajiji
Details
test xls and report pdf (489.57 KB, application/x-zip-compressed)
2018-10-22 03:42 EDT, yeray alonso
Details
Small test project (2.56 KB, application/x-zip-compressed)
2023-03-16 15:22 EDT, david berneda
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nina Kajiji 2018-10-06 23:30:01 EDT
Created attachment 863 [details]
Contains the data and a snapshot of the output and TeeChart code

The calculation of Skewness and Kurtosis using the TSeriesStatsTool is giving different answers compared to that of SAS (with vardef=df option), SPSS and Excel. All three provide comparable numbers. The mean and standard deviation calculations from TeeChart are comparable to that of the statistical programs.

I am including an .XLS file with the data I am using. The Teechart code is also attached.

Teecharts answers are: 
Skewness = 0.916
Kurtosis = 3.658 

Excels answers are:
Skewness = 0.965
Kurtosis = 1.032

I also show the traditional calculation for Kurtosis which appears in  textbooks such as Snedecor and Cochran (1967). By that method the calculation should be 3.7544.

So I am not sure what formulas are being used in Teechart. I would really appreciate if you could clarify the computational differences I observe.

Thanks,
Nina
Comment 1 yeray alonso 2018-10-22 03:42:36 EDT
Created attachment 865 [details]
test xls and report pdf

I attack here the test xls and the report from Nina Kajiji.
Thanks for the analysis!
Comment 2 david berneda 2023-03-16 15:17:14 EDT
In progress. 

Adding support for "Complete" calculation. This code was created without considering the different alternatives, so originally the Std Deviation was only used at the end of the calculation, not while accumulating the sum of differences.

Still not totally correct, pending to check.

    with Series,MandatoryValueList do
    if Count>0 then
       tmpMean:=Total/Count
    else
       tmpMean:=0;

    for t:=0 to Series.Count-1 do
    begin
      tmp:=(Series.MandatoryValueList.Value[t]-tmpMean);

      // https://www.steema.com/bugs/show_bug.cgi?id=2110

      if Complete then
         tmp:=tmp/tmpStdDeviation;

      result:=result+Power(tmp,Exponent);
    end;
  end;
Comment 3 david berneda 2023-03-16 15:22:11 EDT
Created attachment 1038 [details]
Small test project

Test project with the same data of the Excel sheet.