incidence_rate | R Documentation |
The analyze function estimate_incidence_rate()
creates a layout element to estimate an event rate adjusted for
person-years at risk, otherwise known as incidence rate. The primary analysis variable specified via vars
is
the person-years at risk. In addition to this variable, the n_events
variable for number of events observed (where
a value of 1 means an event was observed and 0 means that no event was observed) must also be specified.
estimate_incidence_rate(
lyt,
vars,
n_events,
id_var = "USUBJID",
control = control_incidence_rate(),
na_str = default_na_str(),
nested = TRUE,
summarize = FALSE,
label_fmt = "%s - %.labels",
...,
show_labels = "hidden",
table_names = vars,
.stats = c("person_years", "n_events", "rate", "rate_ci"),
.formats = NULL,
.labels = NULL,
.indent_mods = NULL
)
s_incidence_rate(
df,
.var,
n_events,
is_event = lifecycle::deprecated(),
id_var = "USUBJID",
control = control_incidence_rate()
)
a_incidence_rate(
df,
labelstr = "",
.var,
.df_row,
n_events,
id_var = "USUBJID",
control = control_incidence_rate(),
.stats = NULL,
.formats = c(person_years = "xx.x", n_events = "xx", rate = "xx.xx", rate_ci =
"(xx.xx, xx.xx)", n_unique = "xx", n_rate = "xx (xx.x)"),
.labels = NULL,
.indent_mods = NULL,
na_str = default_na_str(),
label_fmt = "%s - %.labels"
)
lyt |
( |
vars |
( |
n_events |
( |
id_var |
( |
control |
(
|
na_str |
( |
nested |
( |
summarize |
( |
label_fmt |
( |
... |
additional arguments for the lower level functions. |
show_labels |
( |
table_names |
( |
.stats |
( |
.formats |
(named |
.labels |
(named |
.indent_mods |
(named |
df |
( |
.var |
( |
is_event |
( |
labelstr |
( |
.df_row |
( |
estimate_incidence_rate()
returns a layout object suitable for passing to further layouting functions,
or to rtables::build_table()
. Adding this function to an rtable
layout will add formatted rows containing
the statistics from s_incidence_rate()
to the table layout.
s_incidence_rate()
returns the following statistics:
person_years
: Total person-years at risk.
n_events
: Total number of events observed.
rate
: Estimated incidence rate.
rate_ci
: Confidence interval for the incidence rate.
n_unique
: Total number of patients with at least one event observed.
n_rate
: Total number of events observed & estimated incidence rate.
a_incidence_rate()
returns the corresponding list with formatted rtables::CellValue()
.
estimate_incidence_rate()
: Layout-creating function which can take statistics function arguments
and additional format arguments. This function is a wrapper for rtables::analyze()
.
s_incidence_rate()
: Statistics function which estimates the incidence rate and the
associated confidence interval.
a_incidence_rate()
: Formatted analysis function which is used as afun
in estimate_incidence_rate()
.
control_incidence_rate()
and helper functions h_incidence_rate.
df <- data.frame(
USUBJID = as.character(seq(6)),
CNSR = c(0, 1, 1, 0, 0, 0),
AVAL = c(10.1, 20.4, 15.3, 20.8, 18.7, 23.4),
ARM = factor(c("A", "A", "A", "B", "B", "B")),
STRATA1 = factor(c("X", "Y", "Y", "X", "X", "Y"))
)
df$n_events <- 1 - df$CNSR
basic_table(show_colcounts = TRUE) %>%
split_cols_by("ARM") %>%
estimate_incidence_rate(
vars = "AVAL",
n_events = "n_events",
control = control_incidence_rate(
input_time_unit = "month",
num_pt_year = 100
)
) %>%
build_table(df)
# summarize = TRUE
basic_table(show_colcounts = TRUE) %>%
split_cols_by("ARM") %>%
split_rows_by("STRATA1", child_labels = "visible") %>%
estimate_incidence_rate(
vars = "AVAL",
n_events = "n_events",
.stats = c("n_unique", "n_rate"),
summarize = TRUE,
label_fmt = "%.labels"
) %>%
build_table(df)
a_incidence_rate(
df,
.var = "AVAL",
.df_row = df,
n_events = "n_events"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.