基於T-test的permutation test
1:R 中進行置換檢驗的方式有多種,比較典型的就是coin包中的oneway_test函數,但是一個問題是實際問題考慮的可能只是單側的置換檢驗的結果,
但是oneway_test計算的默認是雙側的P值,這時的計算最好是用Deducer包中的perm.t.test函數

2:簡單的perm.t.test函數的說明
perm.t.test(x,y,statistic=c("t","mean"),alternative=c("two.sided", "less", "greater"), midp=TRUE, B=10000)
x a numeric vector containing the first sample y a numeric vector containing the second sample statistic The statistic to be permuted. See details alternative The alternative hypothesis,可以設置是單側的還是雙側的假設檢驗 midp should the mid p-value be used B The number of monte-carlo samples to be generated
Details This function performs a two sample permutation test. If the mean is permuted, then the test assumes exchangability between the two samples.
if the t-statistic is used, the test assumes either exchangability or a sufficiently large sample size. Because there is little lost in the way of power,
and the assumptions are weaker, the t-statistic is used by default.
Value A list with class "htest" containing the following components: statistic The observed value of the statistic. p.value the p-value for the test. method a character string indicating the type of test performed. data.name a character string giving the name(s) of the data. B The number of samples generated alternative the direction of the test
4:例子默認的是以Ttest的方式進行置換檢驗 perm.t.test(rnorm(100),runif(100,-.5,.5)) rm(list=ls()) x<-c(1,2,3,4,5) y<-c(100,101,102,103,104) perm.t.test(y,x,alternative="greater",midp=TRUE, B=1000)
5:使用注意:
a:不同類樣本的先后順序
b:函數perm.t.test處於Deducer包中,在安裝Deducer的過程中需要涉及java的環境配置等等,
需要R的版本與Java的版本一致,目前找到的比較好的處理方式參照如下:http://www.cnblogs.com/ohshit/p/6159644.html
處理之后便可以成功library rJava