1
$\begingroup$

I have a correlation coefficient of two hierarchical clustering trees with 20 labels.

I want to check the hypothesis that the labels of the trees are uncorrelated with a permutation test.

I calculated a p-value using 500 permutations

obsereved.coeff = 0.292

sample.permut <- c()
n <- 500

for(i in 1:n){
  t = tree2 %>% dist(method = "euclidean") %>% hclust("complete") %>% as.dendrogram %>% set("labels",permute(row.names(tree2)))
  sample.permut[i] = cor_bakers_gamma(tree1, t)
}
p-val = sum(abs(sample.permut)>=obsereved.coeff)/500
# p-value:  0.002
  • are 500 permutations enough?
  • is my p-value calculation correct?
  • can I conclude that the labels of the two trees are related, with a 5% probability that the null is correct?

enter image description here

$\endgroup$
2
  • $\begingroup$ Unrelated or uncorrelated? There's a difference. $\endgroup$
    – Dave
    Commented May 11, 2021 at 13:28
  • $\begingroup$ uncorrelated. both trees have the same 20 labels $\endgroup$
    – ari6739
    Commented May 11, 2021 at 13:33

1 Answer 1

1
$\begingroup$

are 500 permutations enough?

Never write simulation code with 500 in it. Always write n <- 500 and use n for the rest. Then as your last step try increasing n to higher values. Only if that does not change the result in relevant ways assume that n was large enough. Or run it with n <-500 many times and see if the results are stable enough.

is my p-value calculation correct?

boils down as to whether everything is correct with p-val = sum(abs(sample.permut)>=obsereved.coeff)/500 As we do not know what sample.permut is and have not seen the rest of the code, we could not honestly say "yes, that is correct". Btw, have you considered one-tailed vs two-tailed testing?

with a 5% probability that the null is correct?

No. That is not what a $p$-value is.

$\endgroup$
3
  • $\begingroup$ sample.permut is a vector of correlations between tree1 and tree2 with permuted labels $\endgroup$
    – ari6739
    Commented May 11, 2021 at 14:07
  • 2
    $\begingroup$ "Never write simulation code with 500 in it. Always write n <- 500 and use n for the rest." I second this advice. $\endgroup$
    – Dave
    Commented May 11, 2021 at 14:14
  • $\begingroup$ In bootstrapping it's often enough to re-sample 2000 times. With permutation tests where I know the answer from other methods, I have often found there is improvement up to about 100,000 iterations (and the extra running time is seldom an issue). $\endgroup$
    – BruceET
    Commented May 11, 2021 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.