View source: R/ard_incidence_rate.R
ard_incidence_rate | R Documentation |
Function takes a time at risk variable (time
) and event count variable (count
) and calculates the incidence
rate in person-years.
Incidence rate is calculated as: Total number of events that occurred / Total person-time at risk
ard_incidence_rate(
data,
time,
count = NULL,
id = NULL,
by = NULL,
strata = NULL,
n_person_time = 100,
unit_label = "time",
conf.level = 0.95,
conf.type = c("normal", "normal-log", "exact", "byar")
)
data |
( |
time |
( |
count |
( |
id |
( |
by , strata |
(
Arguments may be used in conjunction with one another. |
n_person_time |
( |
unit_label |
( |
conf.level |
( |
conf.type |
( One of: |
The formulas used to calculate the confidence interval for each CI type are as
follows, where x_i
and t_i
represent the number of events and follow-up
time for subject i
, respectively.
byar
: Byar's approximation of a Poisson CI. A continuity correction of 0.5 is included in the calculation.
CI = (\sum{x_i} + 0.5) (1 - 1 / (9 \times (\sum{x_i} + 0.5)) \pm Z_{1 - \alpha / 2} / (3 \sqrt{\sum{x_i} + 0.5}))^3 / \sum{t_i}
normal
: Normal CI.
CI = \sum{x_i} / \sum{t_i} \pm Z_{1 - \alpha / 2} \sqrt{\sum{x_i}} / \sum{t_i}
normal-log
: Normal-Log CI.
CI = \exp(\log(\sum{x_i} / \sum{t_i}) \pm Z_{1 - \alpha / 2} / \sqrt{\sum{x_i}})
exact
: Exact CI for a Poisson mean.
CI_{lower} = \chi^2_{\alpha / 2, 2\sum{x_i} + 2} / {2 \sum{t_i}}
CI_{upper} = \chi^2_{1 - \alpha / 2, 2\sum{x_i} + 2} / {2 \sum{t_i}}
an ARD data frame of class 'card'
set.seed(1)
data <- data.frame(
USUBJID = 1:100,
TRTA = sample(LETTERS[1:3], 100, replace = TRUE),
AETTE1 = abs(rnorm(100, mean = 0.5)),
AETOT1 = sample(0:20, 100, replace = TRUE)
)
data |>
ard_incidence_rate(time = AETTE1, count = AETOT1, id = USUBJID, by = TRTA, unit_label = "years")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.