Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is there a way of determining how LocationTest chooses its "AutomaticTest"?

Sometimes it's clear from the VerifyTestAssumptions option

sample = BlockRandom[SeedRandom[7];RandomVariate[SkewNormalDistribution@2, 10]];

{LocationTest[sample, Automatic, "AutomaticTest", VerifyTestAssumptions ->{"Normality"}],
LocationTest[sample, Automatic, "AutomaticTest", VerifyTestAssumptions -> "Normality" -> True]}

{SignedRank, T}

other times less so

{LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> 0.05],
 LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> 0.0005]}

{SignedRank, T}

( i.e. how can the level of the apriori-decided "burden of proof" affect the resulting sampling distribution? )

Update 1:

Following on from the comments - Perhaps the setting for the significance level is somehow being inherited in checks for normality i.e.

{DistributionFitTest[sample, NormalDistribution[],"ShortTestConclusion", SignificanceLevel -> 0.05], 
DistributionFitTest[sample, NormalDistribution[],"ShortTestConclusion", SignificanceLevel -> 0.0005],
DistributionFitTest[sample, NormalDistribution[], "PValue"]}

{Reject,Do not reject,0.00836514}

The critical point is not around the previous p-value instead appearing just after 0.03

Plot[If[LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> x] === "T", 1, 0], {x, 0.01, 0.05}]

enter image description here

If so, perhaps some sort of Bonferroni correction is taking place?

Update 2:

From the answer from Andy Ross, the relevant test is not

 DistributionFitTest[sample, NormalDistribution[]]


but rather



indicating that indeed this significance level is being filtered down. This doesn't however, provide a systematic answer to determining how this choice is made in general. In this case, the logic used by LocationTest can be deduced because it is a standard example but applying NHST can be a bit of an art that depends heavily on circumstance for its ultimate interpretation. Hence, having a black box for this logic seems limiting in perhaps a far more consequential way than say for other "more deterministic" and clear-cut algorithms.

Also, what is the rationale behind this inheritance? - in NHST machinery, the significance level has a specific meaning in relation to Type 1/Type 2 errors, power, experimental context etc with the theory being predicated on a test's conditions being apriori satisfied without concession to their own uncertainty (e.g. despite a p-value being returned, is an error message for a failed test of normality in say TTest invocations counted as a false negative/positive in defining a Type 1/Type2 error?).

sample2 = {6.1, -8.4, 1, 2, 0.75, 2.9, 3.5, 5.1, 1.8, 3.6, 7., 3, 9.4,
    7.5, -6};

(* TTest::nortst: At least one of the p-values in {0.0903246}, resulting from a test for
normality, is below 0.05`. The tests in {T} require that the data is normally distributed. >> *)

(* 0.0498525 *)

The warning above doesn't seem to fit since 0.0903246 is not below 0.05 but explicitly set the significance level to the default 5% however, and the warning message disappears?

TTest[sample2, SignificanceLevel -> 0.05]

(* 0.0498525 *)

At any rate, in general it is quite conceivable that a different significance level for the overarching test might be needed in comparison with the significant level required for an apriori test checking the data's normality, symmetry, heterogeneity etc (n.b. also how are all these combined from the initial setting?)

share|improve this question
Wrt to your last example: This is at least partly documented in the last example of the Possible Issues section of the LocationTest doc page. The significance level has an impact on internal diagnosis tests (in this case a test on equal variance) which changes the degrees of freedom. –  Sjoerd C. de Vries Jan 4 at 9:20
Yes, and curiously LocationTest[sample, Automatic, "AutomaticTest", SignificanceLevel -> 0.05, VerifyTestAssumptions -> #] & /@ {"Normality", "EqualVariance", "EqualVariance" -> True, "EqualVariance" -> False} gives {"SignedRank", "T", "T", "T"} but in this example there is only one sample so I'm not sure what variances are being checked for equality? –  Ronald Monson Jan 4 at 11:00
In the first case you are saying "check for normality" in the remaining examples you are saying "ignore normality and just check for equal variances". Since there is only one sample the equal variances test has no impact on the test that is chosen. –  Andy Ross Jan 4 at 17:37
With that in mind, there should probably be a message saying the equal variance test is being ignored... –  Andy Ross Jan 4 at 17:41
Yes but one might have expected that there is an outcome of the variance check that results in "SignedRank" still being chosen. I.e. otherwise we are moving into Heisenberg territory in which the mere process of "checking" equal variances becomes pivotal (given NHST's dichotomous tradition of being either true or false). At any rate, I agree this is a red herring since there is only one sample. Perhaps what is going on ... see addition to question –  Ronald Monson Jan 5 at 0:21
add comment

1 Answer

With a single sample the test for normality is the deciding factor in what test to choose.

The key here is that DistributionFitTest is not testing against NormalDistribution[0,1] by default. It is testing against the family of normal distributions.



DistributionFitTest[sample, NormalDistribution[]]


The T test is chosen until the significance level is greater than the p-value for the test for normality.

share|improve this answer
Yes I similarly overlooked this point and it does seem to confirm that this significance level is being inherited from the original invocation. –  Ronald Monson Jan 22 at 15:04
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.