FSharp.Stats icon indicating copy to clipboard operation
FSharp.Stats copied to clipboard

[BUG] Incorrect F-test denominator assignments in TwoWayAnovaModel

Open LibraChris opened this issue 5 months ago • 1 comments

Describe the bug

In the current implementation of TwoWayAnovaModel, the logic for assigning denominator mean squares in F-test creation is incorrect for all three model types. This leads to incorrect results when performing two-way ANOVA.

Steps to reproduce the behavior:

Compare two way anova results to implementations of R or python

Expected Behavior

Each TwoWayAnovaModel type should use the correct denominator mean square for its F-tests:

  • Fixed: denominator = error mean squares
  • Random: denominator = factor mean squares (depending on nesting)
  • Mixed: denominator = error mean squares for fixed factor, factor mean squares for random factor

Actual Behavior

The denominator assignments are mismatched:

  • Fixed case is using Random logic
  • Random case is using Mixed logic
  • Mixed case is using Fixed logic

This causes incorrect F-test values and potentially invalid conclusions.

LibraChris avatar Aug 09 '25 00:08 LibraChris