用R进行相关分析

来自OBHRM百科
Lichaoping讨论 | 贡献2017年3月5日 (日) 09:07的版本 结果

跳转至: 导航搜索

脚本与注释

datafilename <- "http://personality-project.org/r/datasets/maps.mixx.epi.bfi.data" # 指定文件名与路径
mydata <-  read.table(datafilename,header=TRUE)                                      # 读取数据到mydata
attach(mydata)                                                                       # 激活mydata
epi <- data.frame(epiE ,epiS ,epiImp ,epilie ,epiNeur)                               # 从mydata中提取数据子集,只包括要分析的变量
corr.test(epi)                                                                       # 相关分析

结果

> corr.test(epi)
Call:corr.test(x = epi)
Correlation matrix    # 相关分析的结果,可以复制到WORD,然后文字转换成表格
         epiE  epiS epiImp epilie epiNeur
epiE     1.00  0.85   0.80  -0.22   -0.18
epiS     0.85  1.00   0.43  -0.05   -0.22
epiImp   0.80  0.43   1.00  -0.24   -0.07
epilie  -0.22 -0.05  -0.24   1.00   -0.25
epiNeur -0.18 -0.22  -0.07  -0.25    1.00
Sample Size 
[1] 231
Probability values (Entries above the diagonal are adjusted for multiple tests.) 
        epiE epiS epiImp epilie epiNeur
epiE    0.00 0.00   0.00   0.00    0.02
epiS    0.00 0.00   0.00   0.53    0.00
epiImp  0.00 0.00   0.00   0.00    0.53
epilie  0.00 0.43   0.00   0.00    0.00
epiNeur 0.01 0.00   0.26   0.00    0.00

 To see confidence intervals of the correlations, print with the short=FALSE option