簡體   English   中英

不同的系數 corrplot() 和 cor.test()

[英]different coefficient corrplot() and cor.test()

我計算了航班數據集所有可能組合的相關系數。 我首先使用 corrplot 進行了此操作。 結果是小時和 sched_dep_time 組合的系數為 1。 但是使用 cor.test() 它告訴我該值接近 1 但為 0.9906496。

這是我的代碼:

# the corrplot
a <- flights %>% select(year, month, day, dep_time, sched_dep_time, dep_delay, arr_time, sched_arr_time, arr_delay, flight, air_time, distance, hour, minute)
corrplot(cor(na.omit(a)), method = "number")
# using cor.test
cor.test(flights$hour, flights$sched_dep_time, method = "pearson")

這種差異的解釋是什么?

這似乎是一個四舍五入的問題。 當你做

library("corrplot")
corrplot(cor(na.omit(a)), method = "number", number.digits=4, number.cex=.5)

系數匹配得更好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM