Skip to content

Two tailed p-values from pvalue are often larger than 1 #8

@demcbs

Description

@demcbs

Two tailed p-values from pvalue are often larger than 1. This is easily tested by using the function with y_pred1=y_pred2, or by setting the scale of y_pred1 to a larger value than that of y_pred2 in the example notebook.

The issue arises here:

    p = percentileofscore(z, 0.0, kind="weak") / 100.0
    if two_tailed:
        p *= 2.0

I think the fix is in the replacement:

    p = percentileofscore(z, 0.0, kind="weak") / 100.0
    if two_tailed:
        p = 2*min(p, 1-p)

This will provide also restore that p-values for two-tailed tests are the same regardless of the order of y_pred1 and y_pred2.
However, this will still give undesired p values of 0.0 if y_pred1=y_pred2, because the percentileofscore argument kind = "weak". To remedy this, one could do

    p = percentileofscore(z, 0.0, kind="mean") / 100.0
    if two_tailed:
        p = 2*min(p, 1-p)

Which will result in p values of 1.0 again, but slightly changes the p values compared to the old calculation, even when p<1-p.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions