相关和回归分析

时间:2014-02-20 11:20:03

标签: statistics regression correlation linear-regression nonlinear-functions

我应该如何分析四个序数(0,1,2,3)和各种连续值范围之间的相关性?散点图看起来像一个4个平行的水平点。

1 个答案:

答案 0 :(得分:0)

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

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

非显着相关

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