Lesson 97 – The Two-Sample Hypothesis Test – Part VI

On the Equality of Variances

using F-distribution

H_{0}:\sigma_{1}^{2}=\sigma_{2}^{2}

H_{A}:\sigma_{1}^{2}>\sigma_{2}^{2}

H_{A}:\sigma_{1}^{2}<\sigma_{2}^{2}

H_{A}:\sigma_{1}^{2} \neq \sigma_{2}^{2}

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.

H_{0}: \sigma_{1}^{2}=\sigma_{2}^{2}

To counter this, we write an alternate hypothesis that

H_{A}:\sigma_{1}^{2}>\sigma_{2}^{2}

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 H_{0} if it is less than our chosen rate of rejection, i.e., if p-value < \alpha. You and I know the whole process. 

Do you know what the test-statistic is?

.

.

.

Refer to Lesson 73. Can we say that \frac{(n-1)s^{2}}{\sigma^{2}} is a Chi-square distribution with (n-1) degrees of fredom?

So we can write,

\frac{(n-1)s^{2}}{\sigma^{2}}=\chi^{2}

For the two samples which have n_{1} and n_{2} values, we can write the following two equations.

\frac{(n_{1}-1)s_{1}^{2}}{\sigma_{1}^{2}}=\chi_{1}^{2}

\frac{(n_{2}-1)s_{2}^{2}}{\sigma_{2}^{2}}=\chi_{2}^{2}

If we take their ratio, we get

\frac{\frac{(n_{1}-1)s_{1}^{2}}{\sigma_{1}^{2}}}{\frac{(n_{2}-1)s_{2}^{2}}{\sigma_{2}^{2}}} = \frac{\chi_{1}^{2}}{\chi_{2}^{2}}

Let’s move the degrees of freedom terms to the right-hand side.

\frac{s_{1}^{2}/\sigma_{1}^{2}}{s_{2}^{2}/\sigma_{2}^{2}} = \frac{\chi_{1}^{2}/(n_{1}-1)}{\chi_{2}^{2}/(n_{2}-1)}

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, \frac{\chi_{1}^{2}/(n_{1}-1)}{\chi_{2}^{2}/(n_{2}-1)} 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:

f_{F}(f) = \frac{(\frac{n_{1}+n_{2}}{2}-1)!(\frac{n_{1}}{n_{2}})^{(\frac{n_{1}}{2})}f^{(\frac{n_{1}}{2}-1)}}{(\frac{n_{1}}{2}-1)!(\frac{n_{2}}{2}-1)!(1+\frac{n_{1}}{n_{2}}f)^{\frac{n_{1}+n_{2}}{2}}}; \hspace{5} 0 < f < \infty

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 F_{df1,df2}, i.e., an F-distribution with df1 degrees of freedom in the numerator (corresponding to \chi_{1}^{2}) and df2 degrees of freedom in the denominator (corresponding to \chi_{2}^{2}).

Visually, it looks similar to the Chi-square distribution. See two examples here.

The distribution shown in black has six degrees of freedom, each in the numerator and the denominator. The distribution shown in red has six degrees of freedom in the numerator and 12 degrees of freedom in the denominator. The one with lower degrees of freedom has a fatter tail and more variance — to factor in more uncertainty due to smaller sample sizes.

At any rate, we can now see that

\frac{s_{1}^{2}/\sigma_{1}^{2}}{s_{2}^{2}/\sigma_{2}^{2}} = F_{n_{1}-1,n_{2}-1}

Now, if the null hypothesis is true, we have \sigma_{1}^{2}=\sigma_{2}^{2}; which means, \frac{s_{1}^{2}}{s_{2}^{2}} = F_{n_{1}-1,n_{2}-1}

So the test-statistic is the ratio of the sample variances.

f_{0}=\frac{s_{1}^{2}}{s_{2}^{2}}

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 f_{0} in the null distribution.

For our BTC exercise, the alternate hypothesis H_{A} is \sigma_{1}^{2} > \sigma_{2}^{2}. So, we check how far away from unity is our test-statistic f_{0}, the ratio of the sample variances.

Suppose it lies in the critical rejection region based on our choice of \alpha (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, s_{1}^{2}, for the first sample, i..e, BTC gains/losses in the most recent week, is

s_{1}^{2} = \frac{1}{n_{1}-1}\sum_{i=1}^{i=n_{1}}(x_{i}-\bar{x})^{2}=10,884,592

The sample variance for the second sample (BTC gains/losses for the week preceding the current week) is

s_{2}^{2} = \frac{1}{n_{2}-1}\sum_{i=1}^{i=n_{2}}(x_{i}-\bar{x})^{2}=1,887,768

Their ratio, i.e., the test-statistic f_{0} is 5.77.

Since each sample has seven values, one value per day, the null distribution assuming that H_{0} is true is an F-distribution with six numerator and denominator degrees of freedom (F_{6,6}).

It looks like this.

As we can see, the test-statistic (f_{0}=5.77) is in the rejection region if we opt for a rejection rate of \alpha=5\%. The critical value at the 5% level is f_{critical}=4.28. 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 f_{critical} for various \alpha values. Here is an example of how such a table looks for \alpha=5\%. 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 (P(F > f_{0})), 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  \sigma_{1}^{2}=\sigma_{1}^{2}. 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.

error

Enjoy this blog? Please spread the word :)