R中整数之间的相关性

问题描述 投票:0回答:1

我有兴趣评估入学考试成绩与第一学期考试成绩的关系 - 两个变量都是整数。我已经计算了Pearson相关性。

但是,由于我的变量是整数,因此散点不是真正分散的。

有没有更好的方法来计算和可视化相关性?或者他们关系的任何其他衡量标准?

如果我的两个整数没有正常分布怎么办?

这是一个问题,他们不是在同一规模? final表示为百分比,entrance_exam表示0-15的测试核心。

test_data <- data.frame("entrance_exam" = sample(0:15,200,replace=T), "final" = sample(0:100,200,replace=T))
str(test_data)
cor.test(entrance_exam,percentage)

ggplot(test_data, aes(x=entrance_exam, y=final)) + 
  geom_point()+
  geom_smooth(method=lm, color="black")+
  # labs(title="Correlation between Diagnostic testscore and Percentage",
       # x= "Total testscore", y = "Percentage" )+
  theme(plot.title = element_text(size=15, face="bold", hjust = 0.5))

enter image description here

r ggplot2 associations regression correlation
1个回答
0
投票

如果违反正态分布假设,您可以使用秩相关性检验(Spearman):cor.test(test_data$entrance_exam,test_data$final, m = 's') 它返回一个斯皮尔曼的rho,你可以解释它好像是一个皮尔逊的r

您可以使用百分比值进行转换,但由于Spearman相关性测试对数据进行排名,因此它没有任何区别。

当你的一个轴被表示为离散变量时,它会成为一个问题,你必须使用肯德尔的tau

wikipedia page

© www.soinside.com 2019 - 2024. All rights reserved.