# Comparing the variance of paired observations

I have $N$ paired observations ($X_i$, $Y_i$) drawn from a common unknown distribution, which has finite first and second moments, and is symmetric around the mean.

Let $\sigma_X$ the standard deviation of $X$ (unconditional on $Y$), and $\sigma_Y$ the same for Y. I would like to test the hypothesis

$H_0$: $\sigma_X = \sigma_Y$

$H_1$: $\sigma_X \neq \sigma_Y$

Does anyone know of such a test? I can assume in first analysis that the distribution is normal, although the general case is more interesting. I am looking for a closed-form solution. Bootstrap is always a last resort.

• I'm not sure why the information that the observations are paired is important to the hypothesis being tested; could you explain? Jul 28 '10 at 0:11
• @drknexus it is important because the dependence makes the calibration of Fisher test difficult. Mar 24 '11 at 17:33

You could use the fact that the distribution of the sample variance is a chi square distribution centered at the true variance. Under your null hypothesis, your test statistic would be the difference of two chi squared random variates centered at the same unknown true variance. I do not know whether the difference of two chi-squared random variates is an identifiable distribution but the above may help you to some extent.

• @svadali it is is more usual to use ratio here since the distribution of ratio of chi square is tabulated (Fisher's F). However, the problematic part of the question (i.e. the dependency between $X$ and $Y$) is still there whatever you use. It is not straightforward to build up a test with two dependent chi square... I tryed to give an answer with a solution on that point (see below). Feb 21 '11 at 12:19

The most naive approach I can think of is to regress $Y_i$ vs $X_i$ as $Y_i \sim \hat{m}X_i + \hat{b}$, then perform a $t$-test on the hypothesis $m = 1$. See t-test for regression slope.

A less naive approach is the Morgan-Pitman test. Let $U_i = X_i - Y_i, V_i = X_i + Y_i,$ then perform a test of the Pearson Correlation coefficient of $U_i$ vs $V_i$. (One can do this simply using the Fisher R-Z transform, which gives the confidence intervals around the sample Pearson coefficient, or via a bootstrap.)

If you are using R, and don't want to have to code everything yourself, I would use bootdpci from Wilcox' Robust Stats package, WRS. (see Wilcox' page.)

If you want to go down the non-parametric route you could always try the squared ranks test.

For the unpaired case, the assumptions for this test (taken from here) are:

1. Both samples are random samples from their respective populations.
2. In addition to independence within each sample there is mutual independence between the two samples.
3. The measurement scale is at least interval.

These lecture notes describe the unpaired case in detail.

For the paired case you will have to change this procedure slightly. Midway down this page should give you an idea of where to start.

If you can assume bivariate normality, then you can develop a likelihood-ratio test comparing the two possible covariance matrix structures. The unconstrained (H_a) maximum likelihood estimates are well known - just the sample covariance matrix, the constrained ones (H_0) can be derived by writing out the likelihood (and will probably be some sort of "pooled" estimate).

If you don't want to derive the formulas, you can use SAS or R to fit a repeated measures model with unstructured and compound symmetry covariance structures and compare the likelihoods.

The difficulty clearly comes because $X$ and $Y$ are corellated (I assume $(X,Y)$ is jointly gaussian, as Aniko) and you can't make a difference (as in @svadali's answer) or a ratio (as in Standard Fisher-Snedecor "F-test") because those would be of dependent $\chi^2$ distribution, and because you don't know what this dependence is which make it difficult to derive the distribution under $H_0$.

My answer relies on Equation (1) below. Because the difference in variance can be factorized with a difference in eigenvalues and a difference in rotation angle the test of equality can be declined into two tests. I show that it is possible to use the Fisher-Snedecor Test together with a test on the slope such as the one suggested by @shabbychef because of a simple property of 2D gaussian vectors.

Fisher-Snedecor Test: If for $i=1,2$ $(Z^i_{1},\dots,Z^i_{n_i} )$ iid gaussian random variables with empirical unbiased variance $\hat{\lambda}^2_i$ and true variance $\lambda^2_i$, then it is possible to test if $\lambda_1=\lambda_2$ using the fact that, under the null,

It uses the fact that $$R=\frac{\hat{\lambda}_X^2}{\hat{\lambda}_Y^2}$$ follows a Fisher-Snedecor distribution $F(n_1-1,n_2-1)$

A simple property of 2D gaussian vector Let us denote by $$R(\theta) = \begin{bmatrix} \cos \theta & -\sin \theta \\ \sin \theta & \cos \theta \\ \end{bmatrix}$$ It is clear that there exists $\lambda_1,\lambda_2>0$ $\epsilon_1$, $\epsilon_2$ two independent gaussian $\mathcal{N}(0,\lambda_i^2)$ such that

$$\begin{bmatrix} X \\ Y \end{bmatrix} = R(\theta)\begin{bmatrix} \epsilon_1 \\ \epsilon_2 \end{bmatrix}$$ and that we have $$Var(X)-Var(Y)=(\lambda_1^2-\lambda_2^2)(\cos^2 \theta -\sin^2 \theta) \;\; [1]$$

Testing of $Var(X)=Var(Y)$ can be done through testing if ( $\lambda_1^2=\lambda_2^2$ or $\theta=\pi/4 \; mod \; [\pi/2]$)

Conclusion (Answer to the question) Testing for $\lambda_1^2=\lambda_2^2$ is easely done by using ACP (to decorrelate) and Fisher Scnedecor test. Testing $\theta=\pi/4 [mod \; \pi/2]$ is done by testing if $|\beta_1|=1$ in the linear regression $Y=\beta_1 X+\sigma\epsilon$ (I assume $Y$ and $X$ are centered).

Testing wether $\left ( \lambda_1^2=\lambda_2^2 \text{ or }\theta=\pi/4 [mod \; \pi/2]\right )$ at level $\alpha$ is done by testing if $\lambda_1^2=\lambda_2^2$ at level $\alpha/3$ or if $|\beta_1|=1$ at level $\alpha/3$.