longteng

随笔记录, 工作日记.
正文

Correlation

(2025-02-11 16:15:47) 下一个

library("ggpubr")

ggscatter(data, x = "CE10", y = "OS", 

          add = "reg.line", conf.int = TRUE, 

          cor.coef = TRUE, cor.method = "pearson",

          xlab = "CE10", ylab = "OS")

cor.test(formula = ~ CE9 + OS,

         data =  data,

         subset = MFP == "D")

t.test(formula = CE10 ~ MFP,

                data = data)

   #                    CE1             CE2                 CE3            CE4                 

BA-5152 0.15368566 0.276724867 0.19438770 0.044953297 

BA-5153 0.09342664 0.046838160 0.02334477 0.006748026 

BA-5559 0.07732019 0.006907233 0.07898090 0.252107417 

round(cor(dat), 2)

  #CE1   CE2   CE3   CE4   CE5   CE6   CE7   CE8   CE9  CE10    OS

CE1   1.00  0.12  0.20  0.07 -0.35  0.15 -0.26 -0.60 -0.26 -0.30 -0.08

CE2   0.12  1.00  0.03 -0.10 -0.34 -0.38  0.13 -0.14 -0.34 -0.52 -0.08

CE3   0.20  0.03  1.00  0.02 -0.35 -0.03 -0.35 -0.57  0.28 -0.01 -0.20

CE4   0.07 -0.10  0.02  1.00 -0.06  0.32 -0.42 -0.21 -0.27 -0.25 -0.07

CE5  -0.35 -0.34 -0.35 -0.06  1.00  0.10 -0.05  0.57 -0.19 -0.09 -0.14

CE6   0.15 -0.38 -0.03  0.32  0.10  1.00 -0.23 -0.16 -0.31  0.00  0.00

CE7  -0.26  0.13 -0.35 -0.42 -0.05 -0.23  1.00  0.48 -0.15 -0.17  0.10

CE8  -0.60 -0.14 -0.57 -0.21  0.57 -0.16  0.48  1.00 -0.19 -0.10  0.12

CE9  -0.26 -0.34  0.28 -0.27 -0.19 -0.31 -0.15 -0.19  1.00  0.54  0.07

CE10 -0.30 -0.52 -0.01 -0.25 -0.09  0.00 -0.17 -0.10  0.54  1.00  0.21

OS   -0.08 -0.08 -0.20 -0.07 -0.14  0.00  0.10  0.12  0.07  0.21  1.00

ggplot(data) +

  aes(x = CE1, y = CE2) +

  geom_point(colour = "#0c4c8a") +

  theme_minimal()

pairs(dat[, c("CE9", "CE10", "OS")])

library(corrplot)

corrplot(cor(dat),

  method = "number",

  type = "upper" # show only upper side

)

correlation tests for whole dataset

library(Hmisc)

res <- rcorr(as.matrix(dat)) # rcorr() accepts matrices only

# display p-values (rounded to 3 decimals)

round(res$P, 3)

library(ggstatsplot)

ggscatterstats(

  data = dat,

  x = CE1,

  y = CE2,

  bf.message = FALSE,

  marginal = FALSE # remove histograms

)

library(correlation)

correlation::correlation(dat,

  include_factors = TRUE, method = "auto"

)

#https://statsandr.com/blog/correlation-coefficient-and-correlation-test-in-r/

[ 打印 ]
阅读 ()评论 (0)
评论
目前还没有任何评论
登录后才可评论.