Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect statistics and p-values for MANOVA #323

Open
snarles opened this issue Jun 6, 2022 · 2 comments
Open

Incorrect statistics and p-values for MANOVA #323

snarles opened this issue Jun 6, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@snarles
Copy link

snarles commented Jun 6, 2022

My issue is about the output of hyppo.ksample.MANOVA. It is known that in the 2-sample case, MANOVA is equivalent to Hotelling's T2 test. This can be verified by comparing hyppo.ksample.Hotelling and statsmodels.multivariate.manova. However, hyppo.ksample.MANOVA differs from both hyppo.ksample.Hotelling and statsmodels.multivariate.manova.

Reproducing code example:

import numpy as np
from numpy.random import randn
from statsmodels.multivariate import manova
from hyppo.ksample import MANOVA, Hotelling
rng = np.random.default_rng(2022)
n = 1000
p = 20
x1 = rng.standard_normal((n, p))
y1 = np.zeros((n, 1))
x2 = rng.standard_normal((n, p))
y2 = np.ones((n, 1))
x = np.vstack([x1, x2])
y = np.vstack([y1, y2])
y = y - np.mean(y)
stat, pvalue = MANOVA().test(x1, x2)
print(stat, pvalue)
# (0.0009554388955993614, 0.9999999301031335)
stat, pvalue = Hotelling().test(x1, x2)
print(stat, pvalue)
# (1.794917015985669, 0.016507943732996515)
print(manova.MANOVA(x, y).mv_test())
#                   Multivariate linear model
#===============================================================
#                                                               
#---------------------------------------------------------------
#           x0           Value   Num DF   Den DF  F Value Pr > F
#---------------------------------------------------------------
#          Wilks' lambda 0.9822 20.0000 1980.0000  1.7952 0.0165
#         Pillai's trace 0.0178 20.0000 1980.0000  1.7952 0.0165
# Hotelling-Lawley trace 0.0181 20.0000 1980.0000  1.7952 0.0165
#    Roy's greatest root 0.0181 20.0000 1980.0000  1.7952 0.0165
#===============================================================

Version information

  • OS: macOS 10.15.7
  • Python Version 3.8.5
  • Package Version 0.3.2
@snarles snarles added the bug Something isn't working label Jun 6, 2022
@sampan501
Copy link
Member

Thank you for your issue, will investigate and see if I can find the bug in the code.

@sampan501
Copy link
Member

I found the bug, seems to be an array broadcasting issue. Should work now. I'll patch it and send in an updated version soon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants