Advanced Octave A29 — Hypothesis testing and multiple comparisons

by Giux GX-TXT, octave-en, scripts-en 2 min read

Advanced GNU Octave with GX-TXT · Module 05

When comparing multiple groups, it is not enough to read different p-values as if each was the only test planned. This lesson performs two comparisons of Welch and shows a simple correction of Bonferroni.

Objectives and prerequisites

We repeat the hypothetical tests and statistics of the introductory course. The three small groups are synthetic and without physical units assigned; we treat them as independent samples to illustrate the procedure, without drawing conclusions on a real population. The test uses GX-TXT dev112-P011-bis and GNU Octave 9.4.0.

For each comparison, nothing is the equality of the averages of the two groups; the alternative is bilateral. The Welch test does not require equal variances, but the other assumptions and independence remain relevant, especially with such small samples.

Two comparisons and a family

Import test_multipli.m, register it and run it in the Runner. The program compares A with B and A with C through NUMERIC_API_v1/hypothesis_test:

r = gxtxt_api_call('NUMERIC_API_v1','hypothesis_test', ...
                   {'welch_t',a,targets{k},struct('alternative','two_sided')});
fprintf('Comparison A-%d: difference=%.6f, p=%.6f\n',k,r.estimate,r.p_value);
fprintf('Bonferroni threshold alpha/2=%.3f; below threshold=%d\n',0.05/2,r.p_value<0.05/2);

If the two tests constitute the comparison family established in advance and the overall level required is 0,05, the illustrated rule compares each p-value with 0,025. Bonferroni can be conservative; the choice of the family and method must be motivated before observing the results.

In the test the average difference A−B is about −0,28 and the p-value about 0,005213, under 0,025. For A−C the printed difference is zero and the 1 p-value, above the threshold. The numbers describe only these synthetic data and the model of the test.

Interpreting correctly

A p-value measures how much results at least equally extreme are compatible with the hypothesis nothing and the assumptions of the test; it is not the probability that the hypothesis nothing is true. A result under a threshold does not measure on its own the practical importance of the effect, while a result above threshold does not show that the averages are identical.

It shows an estimate of the effect, unity when present, uncertainty, method, hypothesis and number of comparisons. With reduced samples, the adequacy of the hypotheses and the accuracy of the estimate deserve special attention.

Exercise

  1. What is the Bonferroni threshold for two tests with a total level of 0,05?
  2. The second result shows that populations have identical averages?
  3. Is p-value the probability that nothing is true?

Worked solution

  1. 0,025 for test in the family considered.
  2. No. The test does not provide sufficient evidence according to the chosen criterion; it does not prove exact equality.
  3. No. It is defined in reference to the distribution of data under hypotheses nothing and assumptions of the test.

Download the Module 05 scripts (ZIP)

#GNU Octave #GX-TXT #GX-TXT public APIs

Other steps of this project

Leave a Reply

Your email address will not be published. Required fields are marked *