-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcpmt01.qmd
49 lines (38 loc) · 1.69 KB
/
cpmt01.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
---
title: CPMT1
subtitle: Cox Proportional Hazards Model Tables with a Single Covariate
categories: [CPM]
---
------------------------------------------------------------------------
::: panel-tabset
## Setup
We will use the `cadtte` data set from the `random.cdisc.data` package to illustrate the tables.
We start by selecting the biomarker evaluable population (BEP) and the time-to-event endpoint of interest, here overall survival.
We then convert time of overall survival to months and create a new variable for the event information.
```{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 `summarize_coxreg()` function in `tern` 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`.
Rather than fitting the model and then tidying the output via the `broom::tidy()` function, we can directly input these three arguments into the `summarize_coxreg()` function to summarize the model fit in a table layout, building the table with our pre-processed `adtte` data set.
```{r}
lyt <- basic_table() %>%
summarize_coxreg(variables = list(
time = "AVAL",
event = "event",
covariates = "COUNTRY"
))
build_table(lyt, adtte)
```
{{< include ../misc/session_info.qmd >}}
:::