This commit is contained in:
Louis Chih-Ming Lee 2026-05-20 18:03:39 +02:00
parent cadad4a4ba
commit 838281ac01
2 changed files with 126 additions and 64 deletions

View file

@ -590,7 +590,7 @@ test.new.var(old.vars, "year", 5)
`year` has the smallest $p$-value
## `tx.type` + `age.rec` + `hla.match` + `age.donor` + `year`
## `tx.type` + `age.rec` + `hla.match` + `age.donor` + `year` + ?
```{r, echo=TRUE}
old.vars <- c("tx.type", "age.rec", "hla.match", "age.donor", "year")
@ -613,7 +613,7 @@ cox.full <- coxph(surv.full, data = dat, method = "breslow")
cox.full
```
```{r, fig.width=7, fig.height=5}
```{r, fig.width=6, fig.height=6}
tidy(cox.full, exponentiate = TRUE, conf.int = TRUE) |>
mutate(
term = recode(
@ -635,7 +635,7 @@ tidy(cox.full, exponentiate = TRUE, conf.int = TRUE) |>
geom_point(size = 2) +
labs(
title = "Hazard Ratios from Full Cox Model",
x = "Hazard Ratio",
x = "Log Hazard Ratio",
y = NULL
) +
my.theme
@ -696,6 +696,59 @@ tidy(cox.full.1, exponentiate = TRUE, conf.int = TRUE) |>
```
```{r, fig.width=6, fig.height=6}
hr.full <- tidy(cox.full, exponentiate = TRUE, conf.int = TRUE)
hr.full.1 <- tidy(cox.full.1, exponentiate = TRUE, conf.int = TRUE)
hr.compare <- bind_rows(
hr.full |>
mutate(model = "Full model with year"),
hr.full.1 |>
mutate(model = "Model without year")
) |>
mutate(
term = recode(
term,
"tx.typeLiving" = "Living donor",
"age.rec" = "Recipient age",
"hla.match" = "HLA match",
"age.donor" = "Donor age",
"year" = "Transplant year"
),
term = factor(
term,
levels = c(
"Transplant year",
"Living donor",
"Recipient age",
"Donor age",
"HLA match"
)
)
)
ggplot(hr.compare, aes(x = estimate, y = term, color = model)) +
geom_vline(xintercept = 1, linetype = "dashed") +
geom_errorbarh(
aes(xmin = conf.low, xmax = conf.high),
height = 0.2,
position = position_dodge(width = 0.6)
) +
geom_point(
size = 2.5,
position = position_dodge(width = 0.6)
) +
scale_x_log10() +
labs(
title = "Hazard Ratios from Cox Models",
x = "Log Hazard Ratio",
y = NULL,
color = NULL
) +
my.theme
```