Here is the short of it:
You have the correct instinct. The original paper from the eponymous creators of the test make the assumption the population difference in medians is known, therefore not of concern because you can just center your data. So basically, the test ignores that issue.
In summary, the test is this. Assume you have a simple random sample from a population $X$ with probability distribution $F(X)$. And assume you have a sample from population $Y$ with probability distribution $G(Y)$. The hypotheses are:
- $H_0$: $F$ and $G$ are identical distributions.
- $H_1$: The only difference between $F$ and $G$ is the scale parameter differs.
You could estimate the difference in location parameters and center your data before you run the test in software. Some software may even do this (even though it's not a good idea). I would not call this data-snooping. You are trying to use your data to answer the question "Are the scales different? I don't care about locations." It's just that the tool you have isn't quite right for the job without the strong assumption that the true difference in population medians is known.
Here's the problem. Say you were to center the data based on an estimated median difference or location difference. The Ansari-Bradley test was formulated and all probabilistic results were derived based on knowing the true location difference. You do not know what the true difference is, you can only estimate it. This means that results of the test would not be reliable when you used the estimate to center the data. This would be especially problematic at small sample sizes.. At larger sample sizes it might not matter. But that would require investigation, simulations, etc. to verify.
This is similar to the one-sample z-test for the mean that gets taught in many introductory statistics courses. You assume you know the true standard deviation $\sigma$. This allows you to use the Z-distribution for inference. However, you almost always never know $\sigma$ so you estimate it with $s$. But, the Z-distribution would no longer be valid for the situation and any inference would be unreliable. However, we can fall back on the t-distribution and carry on like nothing's wrong. You do not have that option with the Ansari-Bradley test.
Here is the long of it
The test was a great idea from a theoretical non-parametric statistics perspective since the results of the Ansari-Bradley test were distribution free, i.e., which probability distribution the data came from didn't matter. We love distribution free tests in non-parametric statistics. This also brings up another somewhat problematic assumption, they assumed that not only was the location difference known, but that the centered distributions were identical except for scale (which is a similar assumption of the Mann-Whitney-Wilcoxon test for location but also assumes equal scale). Without these kinds of assumptions, we lose the distribution free properties of non-parametric tests.
I've done some investigating and tried to find an alternative method which doesn't require those problematic assumptions and... My initial findings aren't so great. At least I can't find a well suited alternative test implemented commonly, or at least not obscurely, in software. Maybe someone else knows of something...
The most straight forward brute force method is to make a permutation test. Create an appropriate test statistic that accounts for the difference in location, calculate it for the original data, then permute the data thousands of times under the assumption the scale is the same, and finally compare the permutation test statistics to the original and see what happens. The problem is that whole centering the data thing. It makes things a bit unreliable overall.
I did find a paper where the assumption is that the distributions have some quantile in common, not necessarily the median. Link here. However it looks like they just wrote some SAS code for it and there isn't a generic function.