On the Equality of Variances
using F-distribution
A good friend is a wall street day trader who has been trading BTC. Lately, he has observed higher volatility in the daily gains/losses, which he associates with celebrities and big banks’ newfound interest. Perhaps they are late to the party, or they quietly got in and are pumping it up.
We wanted to conduct a fun exercise to verify whether the recent period’s variability is more significant than a preceding period. We downloaded BTC price data for the past month and computed daily gains or losses as the difference between closing and opening prices. Here is how the gains/losses look like over the past month.
We highlight two samples, the gains/losses for the most recent week in red and the gains/losses for the week preceding it in blue.
The data from the first sample, i.e., BTC gains/losses for the most recent week, is:
$256, $7991, -$900, -$1357, $2496, $541, -$1094
The variability measured using standard-deviation of the seven values is $3299.
The data from the second sample, i.e., BTC gains/losses for the week preceding the current week, is:
-$429, $323, $2774, $1024, -$393, $986, -$943
Its variability is $1374.
At first glance, it seems evident that the variability in sample 1 is greater than sample2.
But, we know that glances and feelings are not enough.
We need to establish evidence beyond a reasonable doubt.
So my friend and I set up a hypothesis testing framework on the equality of variances.
The null hypothesis is that the population variances are equal.
To counter this, we write an alternate hypothesis that
Then, suppose we know the test-statistic and the null distribution, i.e., the limiting distribution that the test-statistic converges to. In that case, we can compute the p-value and reject if it is less than our chosen rate of rejection, i.e., if . You and I know the whole process.
Do you know what the test-statistic is?
.
.
.
Refer to Lesson 73. Can we say that is a Chi-square distribution with (n-1) degrees of fredom?
So we can write,
For the two samples which have and values, we can write the following two equations.
If we take their ratio, we get
Let’s move the degrees of freedom terms to the right-hand side.
The ratio that we see on the right-hand side is the ratio of two Chi-square distributions divided by their respective degrees of freedom.
This ratio, happens to be a special distribution called the F-distribution as presented by George W. Snedecor.
Snedecor named after Sir R.A. Fisher (F-distribution), who first introduced the ratio of sample variances for evaluating whether they are significantly different. He introduced it as the general z-distribution.
The probability distribution function of an F-distribution is:
In a later lesson, we will derive this from the first principles. We need to know some concepts on joint distributions to be able to do that. So acknowledge it for now, but look out for its derivation in one of the future lessons.
You can say that the F-distribution is a non-negative distribution since it is the ratio of the two non-negative Chi-square distributions. It is denoted as , i.e., an F-distribution with df1 degrees of freedom in the numerator (corresponding to ) and df2 degrees of freedom in the denominator (corresponding to ).
Visually, it looks similar to the Chi-square distribution. See two examples here.
At any rate, we can now see that
Now, if the null hypothesis is true, we have ; which means,
So the test-statistic is the ratio of the sample variances.
We evaluate the hypothesis based on where this test-statistic lies in the null distribution or how likely it is to find a value as large as this test-statistic in the null distribution.
For our BTC exercise, the alternate hypothesis is . So, we check how far away from unity is our test-statistic , the ratio of the sample variances.
Suppose it lies in the critical rejection region based on our choice of (the rate of rejection); in that case, the p-value will be small, allowing us to reject the null hypothesis that the population variances are equal.
Let’s try it.
The sample variance, , for the first sample, i..e, BTC gains/losses in the most recent week, is
The sample variance for the second sample (BTC gains/losses for the week preceding the current week) is
Their ratio, i.e., the test-statistic is 5.77.
Since each sample has seven values, one value per day, the null distribution assuming that is true is an F-distribution with six numerator and denominator degrees of freedom ().
It looks like this.
As we can see, the test-statistic () is in the rejection region if we opt for a rejection rate of . The critical value at the 5% level is . Any value beyond this critical value indicates a deviation far enough from unity to reject the null hypothesis that the variances are equal.
Most statistics textbooks provide a tabulated version of for various values. Here is an example of how such a table looks for . It is a snapshot from Snedecor’s book entitled “Statistical Methods,” published in 1937-1938. Rows correspond to numerator degrees of freedom, and columns correspond to denominator degrees of freedom.
We can also compute the p-value, which, in this case, is the probability of finding a value greater than the test-statistic (), from standard computer-based statistics programs.
In our case, the p-value is 0.025, lower than the chosen rate of rejection of 5%. There is a less than 5 in 100 chance of drawing a sample having a larger F value from the null distribution at hand.
So we reject the null hypothesis that . The population variances are unequal. The variability of the recent period is greater than the variability of the preceding period.
Perhaps the small, most recent sample is not enough to deduce the conclusion on the changes? Go ahead and test for yourself using more data. CoinDesk has data that goes back as far as October 2013, when the price of BTC was $123.
Will the music stop? Does the party come to an end? How much bitcoin do you have?
If you find this useful, please like, share and subscribe.
You can also follow me on Twitter @realDevineni for updates on new lessons.