三个相关性函数:

cor():R自带的,输入数据可以是vector,matrix,data.frame,输出两两的相关系数R值

cor.test():R自带的,输入数据只能是两个vector,输出两个变量的相关系数R值,显著性水平a值

corr.test():psych包的,输入数据可以是data.frame,输出两两变量的相关系数R值,显著性水平a值

> cor(state.x77)
Population Income Illiteracy Life Exp Murder HS Grad Frost Area
Population 1.00000000 0.2082276 0.10762237 -0.06805195 0.3436428 -0.09848975 -0.3321525 0.02254384
Income 0.20822756 1.0000000 -0.43707519 0.34025534 -0.2300776 0.61993232 0.2262822 0.36331544
Illiteracy 0.10762237 -0.4370752 1.00000000 -0.58847793 0.7029752 -0.65718861 -0.6719470 0.07726113
Life Exp -0.06805195 0.3402553 -0.58847793 1.00000000 -0.7808458 0.58221620 0.2620680 -0.10733194
Murder 0.34364275 -0.2300776 0.70297520 -0.78084575 1.0000000 -0.48797102 -0.5388834 0.22839021
HS Grad -0.09848975 0.6199323 -0.65718861 0.58221620 -0.4879710 1.00000000 0.3667797 0.33354187
Frost -0.33215245 0.2262822 -0.67194697 0.26206801 -0.5388834 0.36677970 1.0000000 0.05922910
Area 0.02254384 0.3633154 0.07726113 -0.10733194 0.2283902 0.33354187 0.0592291 1.00000000
> cor.test(state.x77[,1],state.x77[,2]) Pearson's product-moment correlation data: state.x77[, 1] and state.x77[, 2]
t = 1.475, df = 48, p-value = 0.1467
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
-0.07443435 0.45991855
sample estimates:
cor
0.2082276 > corr.test(state.x77)
Call:corr.test(x = state.x77)
Correlation matrix
Population Income Illiteracy Life Exp Murder HS Grad Frost Area
Population 1.00 0.21 0.11 -0.07 0.34 -0.10 -0.33 0.02
Income 0.21 1.00 -0.44 0.34 -0.23 0.62 0.23 0.36
Illiteracy 0.11 -0.44 1.00 -0.59 0.70 -0.66 -0.67 0.08
Life Exp -0.07 0.34 -0.59 1.00 -0.78 0.58 0.26 -0.11
Murder 0.34 -0.23 0.70 -0.78 1.00 -0.49 -0.54 0.23
HS Grad -0.10 0.62 -0.66 0.58 -0.49 1.00 0.37 0.33
Frost -0.33 0.23 -0.67 0.26 -0.54 0.37 1.00 0.06
Area 0.02 0.36 0.08 -0.11 0.23 0.33 0.06 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 Frost Area
Population 0.00 1.00 1.00 1.00 0.23 1.00 0.25 1.00
Income 0.15 0.00 0.03 0.23 1.00 0.00 1.00 0.16
Illiteracy 0.46 0.00 0.00 0.00 0.00 0.00 0.00 1.00
Life Exp 0.64 0.02 0.00 0.00 0.00 0.00 0.79 1.00
Murder 0.01 0.11 0.00 0.00 0.00 0.01 0.00 1.00
HS Grad 0.50 0.00 0.00 0.00 0.00 0.00 0.16 0.25
Frost 0.02 0.11 0.00 0.07 0.00 0.01 0.00 1.00
Area 0.88 0.01 0.59 0.46 0.11 0.02 0.68 0.00 To see confidence intervals of the correlations, print with the short=FALSE option

  

最新文章

  1. 『.NET Core CLI工具文档』(七)dotnet-new
  2. java JSP(原创新手可进)
  3. js通过日期计算属于星期几
  4. centos6安装svn1.9
  5. Forward和Redirect的区别
  6. ubuntu之使用sublime text3搭建Python IDE
  7. HDU 2870 Largest Submatrix
  8. markdown转dokuwiki
  9. 使用 ServKit(PHPnow) 搭建 PHP 环境[图]
  10. JMeter 监控和记录&常用功能
  11. svg 五花 元辅音 助读器
  12. Codeforces Round #452 E. New Year and Old Subsequence
  13. Win2003及2008R2重启自动登录设置方法
  14. libgdx学习记录2——文字显示BitmapFont
  15. 在Winform开发框架中下拉列表绑定字典以及使用缓存提高界面显示速度
  16. 014_IP专项研究监控
  17. 适合使用并行的一种bfs
  18. java内嵌jetty服务器
  19. 实现html页面自动刷新的几种方式
  20. Uncaught TypeError: (intermediate value)(...) is not a function 上一个方法结束没有加分号; 代码解析报错

热门文章

  1. Photoshop脚本之创建文件夹
  2. 第一百九十五节,jQuery EasyUI,Resizable(调整大小)组件
  3. linux grep sed awk
  4. Yii GridView::widget
  5. 页面加载,使用ajax查询某个类别,并且给它们添加(拼接)连接
  6. PHPCMS 前台移用地区联动数据
  7. POJ1751 Highways
  8. “线程安全的” Dictionary(TKey,TValue)
  9. c#数据格式转换汇总
  10. Linux下带宽流量工具iftop实践