JuliaStats / HypothesisTests.jl

Hypothesis tests for Julia
Other
292 stars 87 forks source link

`OneWayANOVATest`, `LeveneTest`, `FlignerKilleenTest` #272

Open r-de-r opened 2 years ago

r-de-r commented 2 years ago

in function 'anova' line 4 Z̄ = mean(Z̄ᵢ) is wrong. It must be Z̄ = sum(Z̄ᵢ .* Nᵢ) / sum(Nᵢ).

As a result, function using 'anova', ie. OneWayANOVATest, LeveneTest, FlignerKilleenTest are wrong, too.

function anova(scores::AbstractVector{<:Real}...)
    Nᵢ = [length(g) for g in scores]
    Z̄ᵢ = mean.(scores)
    # Z̄ = mean(Z̄ᵢ)
    Z̄ = sum(Z̄ᵢ .* Nᵢ) / sum(Nᵢ)
    SStᵢ = Nᵢ .* (Z̄ᵢ .- Z̄).^2
    SSeᵢ = sum.( (z .- z̄).^2 for (z, z̄) in zip(scores, Z̄ᵢ) )
    (Nᵢ, SStᵢ, SSeᵢ)
end
r-de-r commented 2 years ago

BrownForsytheTest is wrong, too.

wildart commented 2 years ago

Duplicate #242

nalimilan commented 2 years ago

The solution proposed by @wildart at #242 is more efficient. Anybody willing to make a PR, with a test?