Question: Correct way to calculate one and two way p-values for a test statistic

0

denalitastic •

**0**wrote:Assume a sample-wise permutation test to define a pvalue based on some test statistic. I have the test statistic of my comparison of interest. Shouldn't the sum of both one way pvalues = 1 for my statistic . I.e those more extreme on either side.

Below I have 2 snippets of code where I calculate the permutation values(current_stat) more extreme than my test statistic (my_stat) for both one way pvalues. Which snippet is done correctly? Here i am in a for loop going over random samples The two way pval is of course absolute_value(curr_stat) >=absolute_value(my_stat)

Here

**1**

```
if (current_stat >= absolute_value(my_stat)){
found_right++;
}
if (current_stat <= -absolute_value(my_stat)){
found_left++;
}
```

**2**

```
if (current_stat >= my_stat){
found_right++;
}
if (current_stat <= my_stat){
found_left++;
}
```

Thank you.