列线图/诺莫图 含概率轴

r 复制代码
## =========================
## regplot 文字替换版
## =========================

pkgs <- c("readxl", "survival", "regplot")
for (p in pkgs) {
  if (!requireNamespace(p, quietly = TRUE)) install.packages(p)
  library(p, character.only = TRUE)
}

## 读入数据
file_path <- "C:/Users/P16v/Desktop/2025-12/MATLAB2026112.xlsx"
stopifnot(file.exists(file_path))
dat0 <- readxl::read_excel(file_path)

## 数据整理
train3 <- data.frame(
  RecurT        = as.numeric(dat0$RecurT),
  Recurrence    = as.integer(dat0$Recurrence),
  CombinedScore = as.numeric(dat0$CombinedScore),
  Size          = as.integer(dat0$Size)
)
train3 <- train3[complete.cases(train3), ]

## -------------------------------------------------------
## 把变量名改成你想显示的名字
## 注意:为了公式兼容,保留合法列名,绘图后再覆盖显示文字
## -------------------------------------------------------
train3_plot <- train3
names(train3_plot)[names(train3_plot) == "CombinedScore"] <- "Combined.Score"
names(train3_plot)[names(train3_plot) == "Size"]          <- "Lesion.Size"

cat("修改后列名:", names(train3_plot), "\n")

## 建模
fit_plot <- coxph(
  Surv(RecurT, Recurrence) ~ Combined.Score + Lesion.Size,
  data = train3_plot,
  x    = TRUE,
  ties = "efron"
)

print(summary(fit_plot))

## 绘图
graphics.off()
dev.new(width = 12, height = 8)

regplot::regplot(
  reg         = fit_plot,
  observation = train3_plot[1, ],
  interval    = "confidence",
  failtime    = c(6, 12, 24),
  title       = "",
  points      = TRUE,
  center      = FALSE,
  rank        = "sd",
  clickable   = FALSE,
  showP       = TRUE,
  odds        = FALSE
)

## -------------------------------------------------------
## 覆盖左侧标签文字
## 思路:用白色矩形盖住原标签,再写入新标签
## -------------------------------------------------------

## 获取当前绘图区坐标
usr <- par("usr")

## 左侧覆盖区域(根据图形效果可微调)
x_left  <- usr[1]
x_right <- usr[1] + 0.22 * (usr[2] - usr[1])

## 先盖住左侧原标签
rect(
  xleft   = x_left,
  ybottom = usr[3],
  xright  = x_right,
  ytop    = usr[4],
  col     = "white",
  border  = NA,
  xpd     = NA
)

## 重新写左侧标签
## 这些 y 位置是按当前 regplot 常见布局手工设置的
## 如有轻微上下偏差,可把数字微调
text(x = usr[1] + 0.02 * (usr[2] - usr[1]), y = usr[4] - 0.06 * (usr[4] - usr[3]),
     labels = "Points", adj = 0, cex = 1.2, font = 3, xpd = NA)

text(x = usr[1] + 0.02 * (usr[2] - usr[1]), y = usr[4] - 0.18 * (usr[4] - usr[3]),
     labels = "Combined Score", adj = 0, cex = 1.2, xpd = NA)

text(x = usr[1] + 0.02 * (usr[2] - usr[1]), y = usr[4] - 0.33 * (usr[4] - usr[3]),
     labels = "Lesion Size", adj = 0, cex = 1.2, xpd = NA)

text(x = usr[1] + 0.02 * (usr[2] - usr[1]), y = usr[4] - 0.47 * (usr[4] - usr[3]),
     labels = "Total points", adj = 0, cex = 1.2, font = 3, xpd = NA)

text(x = usr[1] + 0.14 * (usr[2] - usr[1]), y = usr[4] - 0.73 * (usr[4] - usr[3]),
     labels = "24-month Recurrence Risk", adj = 0, cex = 1.1, xpd = NA)

text(x = usr[1] + 0.14 * (usr[2] - usr[1]), y = usr[4] - 0.86 * (usr[4] - usr[3]),
     labels = "12-month Recurrence Risk", adj = 0, cex = 1.1, xpd = NA)

text(x = usr[1] + 0.14 * (usr[2] - usr[1]), y = usr[4] - 0.99 * (usr[4] - usr[3]),
     labels = "6-month Recurrence Risk", adj = 0, cex = 1.1, xpd = NA)

cat("\n========== 完成,请查看 Plots 窗口 ==========\n")

包含修改成分,输出Plots需要修改

一个典型的列线图通常包含以下几个关键部分:

(1)变量轴:每个预测变量(如年龄、性别、睡眠质量等)都有一个独立的轴,清晰地展示各自的影响。

(2)点数轴:用于将变量值转换为相应的点数,便于后续计算。

(3)总分轴:汇总所有变量的点数,提供一个整体评分,帮助快速评估风险。

(4)概率轴:根据总分预测事件发生的概率,使得临床决策更加科学、直观。

相关推荐
mit6.824几秒前
NitroGen: AI 自动玩游戏
人工智能
小王毕业啦2 分钟前
2007-2024年 省级-农林牧渔总产值、农业总产值数据(xlsx)
大数据·人工智能·数据挖掘·数据分析·社科数据·实证分析·经管数据
数据皮皮侠5 分钟前
上市公司创新韧性数据(2000-2024)|顶刊同款 EIR 指数
大数据·人工智能·算法·智慧城市·制造
科研前沿16 分钟前
纯视觉无感解算 + 动态数字孪生:室内外无感定位技术全新升级
大数据·人工智能·算法·重构·空间计算
暗夜猎手-大魔王17 分钟前
转载--AI Agent 架构设计:错误处理与容错设计(OpenClaw、Claude Code、Hermes Agent 对比)
人工智能
码农的神经元22 分钟前
Claude Code 如何接入 DeepSeek V4 模型:从安装配置到实战验证
人工智能
波动几何31 分钟前
通用行业业务技能体系技能universal-business-skill-system
人工智能
Robot_Nav33 分钟前
AI 编程助手 Skill 完全指南:VS Code · Trae CN · Claude Code
人工智能·vscode·skill·trae·claude code
直奔標竿35 分钟前
Java开发者AI转型第二十五课!Spring AI 个人知识库实战(四)——RAG来源追溯落地,拒绝AI幻觉
java·开发语言·人工智能·spring boot·后端·spring
段一凡-华北理工大学35 分钟前
【高炉炼铁领域炉温监测、预警、调控智能体设计与应用】~系列文章06:智能决策:从经验驱动到数据驱动
网络·人工智能·数据挖掘·高炉炼铁·工业智能体·高炉炉温