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

Is the two-tailed pvalue correct in permutationTest? #469

Open
jodorning opened this issue Jun 29, 2020 · 0 comments
Open

Is the two-tailed pvalue correct in permutationTest? #469

jodorning opened this issue Jun 29, 2020 · 0 comments

Comments

@jodorning
Copy link

When I compare the output to the same test in Python permutation_test library, it seems that your PermutationTest outputs the most frequent mean rather than the two-tailed pvalue. The one-tailed p-values are similar to those from Python permutation_test.

SQL (BIGQUERY)

CREATE TEMPORARY FUNCTION permutation_test(sampleX ARRAY<FLOAT64>, sampleY ARRAY<FLOAT64>)
 RETURNS FLOAT64
 LANGUAGE js AS
"""
  return permutationTest(sampleX, sampleY, "two_side", 5000); //simple-statistics.alternative.permutationTest(sampleX: Array<number>, sampleY: Array<number>, alternative: string, k: number): number of permutations)
"""
OPTIONS (
 library="xxxx"
);

 SELECT permutation_test([2., 5, 3, 6, 7, 2, 5], [20., 5, 13, 12, 7, 2, 2])  

Two-sided P = 0.133

PYTHON

import permutation_test as p

var_control = [2, 5, 3, 6, 7, 2, 5]
var_treatment = [20, 5, 13, 12, 7, 2, 2]

p_value = p.permutationtest(
    data = var_control, 
    ref_data=var_treatment,
    n_combinations_max=5000)

Two-sided P = 0.0999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant