# "One-tailed" Levene Test

F-tests can be two-tailed (to test that $s_1^2 \ne s_2^2$) or one-tailed (to test that $s_1^2 > s_2^2$).

How can I modify Levene/Brown-Forsythe to be "one-tailed", that is, to test $s_1^2 > s_2^2$ instead of $s_1^2 \ne s_2^2$?

Here is a demo:

The image shows normally distributed training data (n=1000) and a model. An F-test is used to compare the variance of one point's residuals (n=2) to the variance of all of the residuals (n=2000), so the point is an outlier if its residual variance is "too large." The points are colored by p-value, where light points fit the model and dark points are outliers, and you can see that the two-tailed Brown-Forsythe rejects points that are too close to the model as well as too far.

Note: A different non-parametric, one-sided variance test would be fine as well.

Glen_b gave the information I needed, but I thought I would leave some implementation details (using scipy).

#basic F-test
F = var(a) / var(b)
Fp = stats.f.sf(F, df1, df2)

#Brown Forsythe
BF, BFp = stats.levene(a, b, center='median')

#two tailed t-test on transformed data
za = abs(a-median(a))
zb = abs(b-median(b))
t, tp_two_tailed = stats.ttest_ind(za, zb)

#the two tailed t test recapitulates the BF test
assert(t**2 == BF)
assert(p_BF == p_two_tailed)

#one tailed t test p value
tp = stats.t.sf(t, df)


Above shows scatter plots of the p values from the one-tailed $F$-test and two-tailed BF-test (left), and the one-tailed $t$ tests (right). Red points are "too close" ($s_1^2 < s_2^2$).

Browne-Forsythe simply performs ANOVA on $z_{ij}=|y_{ij} - \tilde{y}_j|$, where $y_{ij}$ is the $i$th observation in group $j$. Groups with larger spread in $y$ will have larger mean $z$. (Levene is similar, but the $z$'s are defined in terms of the deviations from the group mean instead of the group median.)

If you only have two groups (where a one-tailed test has meaning), you'd simply replace that ANOVA in either of those tests with a plain two-sample t-test on the $z$s ... except one tailed.

Of course, you'd have to specify the direction a priori (before seeing the data).

If you already conclude that the Browne-Forsythe or Levene $F$ is appropriate in the two-group, two-tailed case, then the corresponding $t$-test is necessarily appropriate in the two-group version (it rejects exactly the same cases as the $F$ when working two-tailed) - consequently the only remaining consideration is whether it works as well two tailed as it does one tailed. Simple considerations of symmetry in arguments should suffice for that.

So if you think Browne-Forsythe or Levene are okay, then just do a $t$-test. Nothing to it.

[Caveat Emptor: Using such a test prior to an ANOVA to decide whether on not to apply some adjustment for heteroskedasticity or more robust procedure is not advisable. Better to assume the variances are unequal at the outset.]

• Thanks. The usual test statistic for the classification technique I'm implementing is the basic $F = s_1^2 / s_2^2$, and I'm not sure yet if the ANOVA F will work. The one-tailed version is necessary for me to test ANOVA/Levene. Pointing out that it's just a t test should be enough, and I'll let you know how it goes tomorrow. Sep 8, 2013 at 15:21
• Could you be more explicit? Why is a "classification technique" testing equality of variance at all, let alone by such a method? Sep 8, 2013 at 16:52
• Sure, it's called SIMCA. Here is the original paper. This paper is easier to read. Modern software here Sep 8, 2013 at 17:27
• Both gated; I can't read them from this machine. But the point of my question was that I doubt the classification technique itself is doing anything but classifying. The testing is done separately, probably because underlying the technique is an assumption of equal variance. Formal hypothesis tests are generally a bad idea in such circumstances. Sep 8, 2013 at 17:33
• My ability to explain/defend the method isn't really related to the question. If you are really interested, I would be very happy to discuss elsewhere. You can find my email in my profile. Sep 8, 2013 at 17:52

I know this is 2 years later, but you may want to investigate the software you are using to see if it's already a one-way test. In R there are 3 packages that contain Brown-Forsythe (which is simply Levene's, but uses median instead of mean), and all of them are the one-sided test.

You can test this yourself just by looking at the F-value that you are given, and looking at an F-Distribution table. Since the F-Distribution is typically expected for ANOVA use, and ANOVA is typically one-tailed, these tables are almost always given as one-tailed. You didn't give specific values, but here’s an example. I randomly drew two samples, (x & y, sampled without replacement) from a normally distributed population. Both samples originally have similar variances (0.73 & 0.25), and both are n=50. I manipulated the data in x to dramatically change its variance (6.99). I ran the Brown-Forsythe, which gave me F(1,98)=4.06, p=0.047. I manipulated the data in x a second time to slightly decrease the variance (6.90). I re-ran Brown-Forsythe, and this time I got F(1,98)=3.75, p=0.056.

Clearly, if alpha=5%, then these latter two manipulated variances of x straddle the line. Now take a look at this F-Distribution table—it has a graph at the top to help assure you that it’s a one-tailed test. https://www.safaribooksonline.com/library/view/random-data-analysis/9780470248775/images/tabA-5a.jpg

For df1=1 and df2=100, the critical value for the one-tailed F-Distribution is 3.94. Since we had df2=98, we would expect our specific critical value to be slightly higher than 3.94, but not by much. The first manipulation had F=4.06, p=0.049, and the second was F=3.75, p=0.056. You can see that according to this one-tailed F-Distribution table, the p-values produced by this Brown-Forsythe test in R are using a one-tailed test--i.e., the critical value for p=0.05 is 3.94, which is right in-between the two calculated F-values. If you could use your own software to perform the Brown-Forsythe, and manipulate your data to get to an F-value that is close to p=0.05, then you can compare it to this F-Distribution table as I have done to see what kind of ‘tailedness’ your software uses to produce its p-values

However, let’s presume your software uses a two-tailed test, but you still really want a one-tailed test. As long as you are given an F-value from the Brown-Forsythe, you can look it up yourself using the table. If your calculated F is greater than the critical value in the table for your degrees of freedom, then you must reject the null (i.e., the variances are not equal); if your calculated F-value is less than the critical value in the table, then you should fail to reject the null, and assume the variances are equal enough to proceed to whatever parametric test you are intending to run to test the means. If you are running R, then you can use 1-pf(F,df1,df2)