Skip to content

P-value computation #1

Description

@quirinmanz

Dear STITCHIT-Team,

In the Test for p-values
using the vectors

v1 = {1,2,3,4,5};

and
v6 = {1,2,4,3,5};

the p-value is assumed to be 0.01866973
TEST_F(CORCOMPTest, pValueTest1){
CorComp cc (v6,v1);
double cor = cc.computePearsonCorrelation();
ASSERT_NEAR(cc.getPvalue(cor),0.01866973,0.01);
}
.
The corresponding R code:

> cor.test(c(1,2,3,4,5), c(1,2,4,3,5), alternative = "greater", method = "pearson")

	Pearson's product-moment correlation

data:  c(1, 2, 3, 4, 5) and c(1, 2, 4, 3, 5)
t = 3.5762, df = 3, p-value = 0.01869
alternative hypothesis: true correlation is greater than 0
95 percent confidence interval:
 0.2996475 1.0000000
sample estimates:
cor 
0.9 

> cor.test(c(1,2,3,4,5), c(1,2,4,3,5), alternative = "two.sided", method = "pearson")

	Pearson's product-moment correlation

data:  c(1, 2, 3, 4, 5) and c(1, 2, 4, 3, 5)
t = 3.5762, df = 3, p-value = 0.03739
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.08610194 0.99343752
sample estimates:
cor 
0.9

As one can see, the alternative hypothesis used in the computation in STITCHIT is one-sided ("greater").

return 1.0-cdf(fisher.first/fisher.second);

To also account for significant negative correlations, STITCHIT uses the absolute correlation for the Fisher's transformation:

STITCHIT/core/CorComp.cpp

Lines 141 to 149 in 641dc07

double cor2 = std::abs(cor);
if (observationCount_ < 5)
error=1.0;
else
error=1.0/sqrt(observationCount_-3.0);
if (std::abs(cor)==1.0)
return std::make_pair(std::numeric_limits<double>::max(),error);
else
return std::make_pair((0.5)*log((1.0+cor2)/(1.0-cor2)),error);

Does this violate the alternative hypothesis, which should be two-sided (corr != 0)?

Best,
Quirin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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