相關性的顯著性檢驗

  • cor.test()

使用cor.test()函數對單個Pearson、Spearman、Kendall相關係數進行檢驗,格式爲less

cor.test(x,y,laternative = ,method =)

x、y:要檢驗相關性的變量ide

alternative:指定雙側檢驗或單側檢驗,取值爲 two.side,less,或者greater函數

                    當研究的假設爲整體的相關係數小於 0 時,請使用alternative = 「less」spa

                    當研究的假設爲整體的相關係數大於 0 時,使用alternative=「greater」code

method:指定要計算的相關類型(pearson、kendall、speraman)ip

it

> cor.test(states[,3], states[,5])

	Pearson's product-moment correlation

data:  states[, 3] and states[, 5]
t = 6.8479, df = 48, p-value = 1.258e-08
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.5279280 0.8207295
sample estimates:
      cor 
0.7029752
  • corr.test()

psych包中提供的corr.test()函數能夠一次作更多的事情,該函數能夠爲Pearson、Pearmen或Kendall相關計算相關矩陣和顯著水平io

test

> library(psych)

> corr.test(states, use="complete")
Call:corr.test(x = states, use = "complete")
Correlation matrix 
           Population Income Illiteracy Life Exp Murder HS Grad
Population       1.00   0.21       0.11    -0.07   0.34   -0.10
Income           0.21   1.00      -0.44     0.34  -0.23    0.62
Illiteracy       0.11  -0.44       1.00    -0.59   0.70   -0.66
Life Exp        -0.07   0.34      -0.59     1.00  -0.78    0.58
Murder           0.34  -0.23       0.70    -0.78   1.00   -0.49
HS Grad         -0.10   0.62      -0.66     0.58  -0.49    1.00
Sample Size 
[1] 50
Probability values (Entries above the diagonal are adjusted for multiple tests.) 
           Population Income Illiteracy Life Exp Murder HS Grad
Population       0.00   0.59       1.00      1.0   0.10       1
Income           0.15   0.00       0.01      0.1   0.54       0
Illiteracy       0.46   0.00       0.00      0.0   0.00       0
Life Exp         0.64   0.02       0.00      0.0   0.00       0
Murder           0.01   0.11       0.00      0.0   0.00       0
HS Grad          0.50   0.00       0.00      0.0   0.00       0

 To see confidence intervals of the correlations, print with the short=FALSE option
 
 #參數 use =  的取值爲「pairwise」或「complete」分別表示對缺失值執行成對刪除或行刪除
 #參數 method = 的取值爲「pearson」(默認值)、「spearman」或「kendall」,能夠看到人口數量和高中率的相關關係(-0.10)並不顯著地不爲0
  • 其餘顯著性檢驗

偏相關係數的檢驗,在多元正態性的假設下,ggm包中的pcor.test()能夠用來控制一個或者多個額外變量時兩個變量之間的條件獨立性,使用格式爲變量

pcor.test(r,q,n)

r:是由pocr()函數計算的偏相關係數

q:爲要控制的變量數(以數值表示位置)

n:爲樣本大小

 

psych包中的r.test()函數提供了多種實用的顯著性檢驗方法,此函數可用來檢驗

a、某種相關係數的顯著性

b、兩個獨立相關係數的差別是否顯著

c、兩個基於一個共享變量獲得的非獨立相關係數的差別是否顯著

d、兩個基於徹底不一樣的變量獲得的非獨立相關係數的差別是否顯著

更多參閱help(r.test)

相關文章
相關標籤/搜索