Repository: statsmodels/statsmodels

Issue:
tiny documentation issue: statsmodels.stats.multitest.multipletests() parameter pvals is one-dimensional
Could you please mod the doc for statsmodels.stats.multitest.multipletests()
to say that the parameter pvals is one-dimensional?

I'm hung up at this instant or I'd give you a pull request, sorry.


Discussion:
Thanks for reporting.

It's raising an exception at **some** place now if pvals is 2-D. Or, did you see a case without exception where some numbers are returned?

I think we should raise explicitly an exception if `pvals.ndim !=1`, then it still leaves the option open to add an axis argument with default axis=0. I don't see a current issue or discussion on adding support for ndim >1.
AFAIR, it shouldn't be difficult to have a vectorized axis solution, except it will making the nan case more difficult to implement #2899
Yes, it raises an ValueError that is not easy for mere mortals to unravel.
Yes, raising an exception requiring ndim +AD0APQ- 1 is better than simply
documenting, duh.
That's why you're the good engineer and I'm the script kiddy.

Thanks.

On 12/6/16, 10:20 AM, +ACI-Josef Perktold+ACI- +ADw-notifications+AEA-github.com+AD4- wrote:

+AD4-Thanks for reporting.
+AD4-It's raising an exception at some place now if pvals is 2-D. Or, did you
+AD4-see a case without exception where some numbers are returned?
+AD4-I think we should raise explicitly an exception if pvals.ndim +ACEAPQ-1, then
+AD4-it still leaves the option open to add an axis argument with default
+AD4-axis+AD0-0. I don't see a current issue or discussion on adding support for
+AD4-ndim +AD4-1.
+AD4-AFAIR, it shouldn't be difficult to have a vectorized axis solution,
+AD4-except it will making the nan case more difficult to implement
+AD4-
+AD4AIw-2899 +ADw-https://github.com/statsmodels/statsmodels/issues/2899+AD4-
+AD4gFA-
+AD4-You are receiving this because you authored the thread.
+AD4-Reply to this email directly,
+AD4-view it on GitHub 
+AD4APA-https://github.com/statsmodels/statsmodels/issues/3307+ACM-issuecomment-26519
+AD4-4528+AD4-, or 
+AD4-mute the thread 
+AD4APA-https://github.com/notifications/unsubscribe-auth/ABpd4EWdWGy1gFV3yJRWTrw
+AD4-x6WQyWN7tks5rFYtIgaJpZM4LFfSx+AD4-.
+AD4-
+AD4-
+AD4AewAi-api+AF8-version+ACI-:+ACI-1.0+ACI-,+ACI-publisher+ACI-:+AHsAIg-api+AF8-key+ACI-:+ACI-05dde50f1d1a384dd78767c55493e
+AD4-4bb+ACI-,+ACI-name+ACI-:+ACI-GitHub+ACIAfQ-,+ACI-entity+ACI-:+AHsAIg-external+AF8-key+ACI-:+ACI-github/statsmodels/statsmo
+AD4-dels+ACI-,+ACI-title+ACI-:+ACI-statsmodels/statsmodels+ACI-,+ACI-subtitle+ACI-:+ACI-GitHub
+AD4-repository+ACI-,+ACI-main+AF8-image+AF8-url+ACI-:+ACI-https://cloud.githubusercontent.com/assets/1
+AD4-43418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png+ACI-,+ACI-avatar+AF8-image+AF8-url
+AD4AIg-:+ACI-https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0
+AD4-b-11e6-9aed-b52498112777.png+ACI-,+ACI-action+ACI-:+AHsAIg-name+ACI-:+ACI-Open in
+AD4-GitHub+ACI-,+ACI-url+ACI-:+ACI-https://github.com/statsmodels/statsmodels+ACIAfQB9-,+ACI-updates+ACI-:+AHsAIg-s
+AD4-nippets+ACI-:+AFsAewAi-icon+ACI-:+ACI-PERSON+ACI-,+ACI-message+ACI-:+ACIAQA-josef-pkt in +ACM-3307: Thanks for
+AD4-reporting.+AFw-r+AFw-n+AFw-r+AFw-nIt's raising an exception at +ACoAKg-some+ACoAKg- place now if
+AD4-pvals is 2-D. Or, did you see a case without exception where some numbers
+AD4-are returned?+AFw-r+AFw-n+AFw-r+AFw-nI think we should raise explicitly an exception if
+AD4AYA-pvals.ndim +ACEAPQ-1+AGA-, then it still leaves the option open to add an axis
+AD4-argument with default axis+AD0-0. I don't see a current issue or discussion
+AD4-on adding support for ndim +AFw-u003e1.+AFw-r+AFw-nAFAIR, it shouldn't be difficult
+AD4-to have a vectorized axis solution, except it will making the nan case
+AD4-more difficult to implement +ACM-2899+ACIAfQBd-,+ACI-action+ACI-:+AHsAIg-name+ACI-:+ACI-View
+AD4-Issue+ACI-,+ACI-url+ACI-:+ACI-https://github.com/statsmodels/statsmodels/issues/3307+ACM-issue
+AD4-comment-265194528+ACIAfQB9AH0-


The information contained in this e-mail message may be privileged, confidential, and/or protected from disclosure. This e-mail message may contain protected health information (PHI); dissemination of PHI should comply with applicable federal and state laws. If you are not the intended recipient, or an authorized representative of the intended recipient, any further review, disclosure, use, dissemination, distribution, or copying of this message or any attachment (or the information contained therein) is strictly prohibited. If you think that you have received this e-mail message in error, please notify the sender by return e-mail and delete all references to it and its contents from your systems.
The alternative to raising an exception would be to ravel, which is common in numpy and scipy, but it would make a default axis=0 as an extension backwards incompatible.

Resolving patch:
diff --git a/statsmodels/stats/multitest.py b/statsmodels/stats/multitest.py
--- a/statsmodels/stats/multitest.py
+++ b/statsmodels/stats/multitest.py
@@ -59,29 +59,29 @@ def _ecdf(x):
 
 def multipletests(pvals, alpha=0.05, method='hs', is_sorted=False,
                   returnsorted=False):
-    '''test results and p-value correction for multiple tests
-
+    """
+    Test results and p-value correction for multiple tests
 
     Parameters
     ----------
-    pvals : array_like
-        uncorrected p-values
+    pvals : array_like, 1-d
+        uncorrected p-values.   Must be 1-dimensional.
     alpha : float
         FWER, family-wise error rate, e.g. 0.1
     method : string
         Method used for testing and adjustment of pvalues. Can be either the
-        full name or initial letters. Available methods are ::
-
-        `bonferroni` : one-step correction
-        `sidak` : one-step correction
-        `holm-sidak` : step down method using Sidak adjustments
-        `holm` : step-down method using Bonferroni adjustments
-        `simes-hochberg` : step-up method  (independent)
-        `hommel` : closed method based on Simes tests (non-negative)
-        `fdr_bh` : Benjamini/Hochberg  (non-negative)
-        `fdr_by` : Benjamini/Yekutieli (negative)
-        `fdr_tsbh` : two stage fdr correction (non-negative)
-        `fdr_tsbky` : two stage fdr correction (non-negative)
+        full name or initial letters. Available methods are:
+
+        - `bonferroni` : one-step correction
+        - `sidak` : one-step correction
+        - `holm-sidak` : step down method using Sidak adjustments
+        - `holm` : step-down method using Bonferroni adjustments
+        - `simes-hochberg` : step-up method  (independent)
+        - `hommel` : closed method based on Simes tests (non-negative)
+        - `fdr_bh` : Benjamini/Hochberg  (non-negative)
+        - `fdr_by` : Benjamini/Yekutieli (negative)
+        - `fdr_tsbh` : two stage fdr correction (non-negative)
+        - `fdr_tsbky` : two stage fdr correction (non-negative)
 
     is_sorted : bool
         If False (default), the p_values will be sorted, but the corrected
@@ -131,7 +131,7 @@ def multipletests(pvals, alpha=0.05, method='hs', is_sorted=False,
 
     Method='hommel' is very slow for large arrays, since it requires the
     evaluation of n partitions, where n is the number of p-values.
-    '''
+    """
     import gc
     pvals = np.asarray(pvals)
     alphaf = alpha  # Notation ?


Test patch: