-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpmt03.qmd
50 lines (39 loc) · 1.51 KB
/
cpmt03.qmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
title: CPMT3
subtitle: Cox Proportional Hazards Model Tables with Separate Models for Each Covariate
categories: [CPM]
---
------------------------------------------------------------------------
::: panel-tabset
## Setup
We prepare the data in the same way as in [CPMT1](../tables/cpmt01.qmd).
```{r, message = FALSE}
library(tern)
library(dplyr)
adtte <- random.cdisc.data::cadtte %>%
df_explicit_na() %>%
filter(PARAMCD == "OS", BEP01FL == "Y") %>%
mutate(
AVAL = day2month(AVAL),
AVALU = "Months",
event = 1 - CNSR
)
```
## Table
The separate Cox Proportional Hazards models for each covariate can be fitted and summarized in a table using the `summarize_coxreg()` function in `tern`.
This function takes the same `variables`, `at`, and `control` arguments that are used to fit a model using the `fit_coxreg_univar()` function - specifying the time, event and covariate in a `variables` list, and `control` and `at` with any further customizations to the model.
Note that the default confidence level is 95% but this can be customized via the `conf_level` element in `control`.
We input these three arguments into the `summarize_coxreg()` function to summarize the model fit in a table layout, and then build the table with our pre-processed `adtte` data set.
```{r}
lyt <- basic_table() %>%
summarize_coxreg(
variables = list(
time = "AVAL",
event = "event",
covariates = c("COUNTRY", "AGE")
)
)
build_table(lyt = lyt, df = adtte)
```
{{< include ../misc/session_info.qmd >}}
:::