For the Jarque-Bera measure, we start by creating the table variable, __Table, and setting this as equal to our base data table, R08_Table. This is done for ease of reference. Next, we calculate the mean (__Mean), standard deviation (__StdDev), and count (n) of the data points in our Values column. This is done by using AVERAGEX, STDEVX.S, and COUNTROWS respectively.
Next, we need to calculate the skewness of our data. The formula for skewness is as follows:
This formula requires n, the number of data points, the average or mean of those data points (the X with the bar over it) and the standard deviation of the data points, S. Since we must calculate the sum of the cube of the differences between each row's Value column and the mean of the Value column, we create the table variable, __TableSkew, and use our base data table, __Table, as a starting point. We use ADDCOLUMNS to add the __Skew column to our table and simply implement the summation portion of the formula for skewness. We can now implement the rest of the formula for skewness in our __Skewness variable by dividing the sum of our __Skew column by the __StdDev to the third power (cubed). We then divide this quotient by 4.
The calculation for the __TableKurtosis and __Kurtosis variables are identical to the calculation for the __TableSkew and __Skewness variable except that powers of 4 are used instead of powers of 3.
Now that we have calculated all of the required parts of the Jarque-Bera test formula, we can calculate our final value for the Jarque-Bera measure. The __FirstPart variable simply calculates the quotient of __n divided by 6. The __SecondPart variable calculates the rest of the formula for the Jarque-Bera test. We then simply need to return the multiplication of the __FirstPart variable and the __SecondPart variable.
For the JB Type measure, we simply need to check if the value of our Jarque-Bera measure is greater than zero. If our Jarque-Bera measure is greater than zero then the data is not normally distributed. Otherwise, the data is normally distributed.