anova reports F=inf, p=0 for identical constant groups, where F is 0/0 and scipy returns nan

Aperta Adatta ai principianti
#263 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
82/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python, rust
Ambito
data

Direzione di ricerca

Individua l’implementazione Rust dell’ANOVA a un fattore che contiene il controllo ms_within == 0.0 e verifica come calcola la somma dei quadrati media tra i gruppi. Aggiungi o aggiorna i test ANOVA in modo che gruppi costanti identici restituiscano nan, nan, mentre gruppi con varianza positiva tra i gruppi e varianza zero all’interno dei gruppi continuino a restituire inf, 0; quindi esegui la suite di test Rust pertinente e gli esempi delle binding Python.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area/statistics help wanted kind/wrong-result severity/2-critical

anova reports F = inf, p = 0 for groups that are identical and constant — maximal statistical significance from data with no difference at all.

import rssn
s = rssn.Session()

a = s.compute("anova(list(list(5,5,5),list(5,5,5)))")
a.text      # 'list(inf, 0)'
a.reduced   # True
a.error     # None
a.diagnostic_codes  # ()

Both groups have mean 5 and zero within-group spread, so SS_between = 0 and SS_within = 0, and F = 0/0 is undefined — not infinite. Reporting p = 0 says "the means differ with probability 1", the strongest possible rejection, about two samples that are bit-identical.

scipy returns (nan, nan) for the same input (with ConstantInputWarning), and rssn's own checked numeric operator rejects it:

rssn.num_stats_ext_anova_one_way([[5.,5.,5.],[5.,5.,5.]], checked=True)
# RssnError: domain error: anova_one_way

The genuinely infinite case is handled correctly, which shows the two cases are distinguishable and the library just conflates them:

s.compute("anova(list(list(1,1,1),list(2,2,2)))").text   # 'list(inf, 0)'
scipy.stats.f_oneway([1,1,1],[2,2,2])                    # statistic=inf, pvalue=0.0

There SS_between > 0 and SS_within = 0, so F = inf is right. The bug is the guard if ms_within == 0.0 { return (f64::INFINITY, 0.0) }, which fires before checking whether the between-group variance is also zero.

Same result for [[1,1],[1,1]] and for three identical constant groups.

Expected: nan, nan (or an explicit "undefined" report) when both SS_between and SS_within are zero, and inf, 0 only when SS_between > 0.

rssn 0.3.0, Python binding, Windows x86_64.

Lingua principale
Rust
Stelle
36
Fork
3
Merge medio
18h 51m
PR unite (30g)
18

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Apich-Organization/rssn

Tutte le issue di Apich-Organization/rssn

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.