首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >相关和回归分析

相关和回归分析
EN

Stack Overflow用户
提问于 2014-02-20 19:20:03
回答 1查看 108关注 0票数 0

如何分析四个序数(0,1,2,3)与连续值的不同范围之间的相关性?散点图看起来像4个平行的水平点。

EN

回答 1

Stack Overflow用户

发布于 2014-02-21 02:18:36

您可以运行Spearman等级相关测试。使用R,

代码语言:javascript
复制
require(pspearman)
x <- c(rep("a", 5), rep("b", 5), rep("c", 5), rep("d", 5))
x <- factor(x, levels=c("a", "b", "c", "d"), ordered=T)
y <- 1:20

spearman.test(x, y)

    Spearman's rank correlation rho

data:  x and y
S = 40.6203, p-value = 6.566e-06
alternative hypothesis: true rho is not equal to 0
sample estimates:
      rho 
0.9694584 

Warning message:
In spearman.test(x, y) : Cannot compute exact p-values with ties

不显著的相关性

代码语言:javascript
复制
set.seed(123)
y2 <- rnorm(20)
spearman.test(x, y2)

Spearman's rank correlation rho

data:  x and y2
S = 1144.329, p-value = 0.5558
alternative hypothesis: true rho is not equal to 0
sample estimates:
     rho 
0.139602 

Warning message:
In spearman.test(x, y2) : Cannot compute exact p-values with ties
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21906189

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档