2つのデータセットがあり、それらが大幅に異なるかどうかを知りたい(これは、「2つのグループは大幅に異なる?使用するテスト」から得られます)。
私は置換テストを使用して、Rで次のことを行うことにしました。
permutation.test <- function(coding, lncrna) {
    coding <- coding[,1] # dataset1
    lncrna <- lncrna[,1] # dataset2
    ### Under null hyphotesis, both datasets would be the same. So:
    d <- c(coding, lncrna)
    # Observed difference
    diff.observed = mean(coding) - mean(lncrna)
    number_of_permutations = 5000
    diff.random = NULL
    for (i in 1:number_of_permutations) {
        # Sample from the combined dataset
        a.random = sample (d, length(coding), TRUE)
        b.random = sample (d, length(lncrna), TRUE)
        # Null (permuated) difference
        diff.random[i] = mean(b.random) - mean(a.random)
    }
    # P-value is the fraction of how many times the permuted difference is equal or more extreme than the observed difference
    pvalue = sum(abs(diff.random) >= abs(diff.observed)) / number_of_permutations
    pvalue
}
それにもかかわらず、このペーパーによると、p値は0であってはなりません:http : //www.statsci.org/smyth/pubs/permp.pdf
何をすすめますか?p値を計算するのはこの方法ですか?
pvalue = sum(abs(diff.random) >= abs(diff.observed)) / number_of_permutations
良い方法?または、次のことを行う方が良いですか?
pvalue = sum(abs(diff.random) >= abs(diff.observed)) + 1 / number_of_permutations + 1
          
a.randomb.randomb.randoma.randomcodinglncrna