strate {mStats} | R Documentation |
Calculate Incidence Rates from time-to-event data
Description
strate()
calculates incidence rates and Corresponding 95\
Usage
strate(data, time, var, ..., fail = NULL, per = 1, digits = 5)
Arguments
data |
Dataset |
time |
person-time variable |
var |
outcome variable: preferably 1 for event, 0 for censored |
... |
variables for stratified analysis |
fail |
a value or values to specify failure event |
per |
units to be used in reported rates |
digits |
Rounding of numbers |
Details
Rates of event occurrences, known as incidence rates are outcome measures in longitudinal studies. In most longitudinal studies, follow-up times vary due to logistic reasons, different periods of recruitment, delay enrollment into the study, lost-to-follow-up, immigration or emigration and death.
Follow-up time in longitudinal studies
Period of observation (called as follow-up time) starts when individuals join
the study and ends when they either have an outcome of interest, are lost-to-
follow-up or the follow-up period ends, whichever happens first. This period is
called person-year-at-risk. This is denoted by PY in strate
function's output and number of event by D.
Rate
is calculated using the following formula:
\lambda = D / PY
Confidence interval of rate
is derived using the following formula:
95\% CI (rate) = rate x Error Factor
Error Factor (rate) = exp(1.96 / \sqrt{D})
plot
, if TRUE
, produces a graph of the rates against
the numerical code used for categories of by
.
Author(s)
Email: dr.myominnoo@gmail.com
Website: https://myominnoo.github.io/
References
Betty R. Kirkwood, Jonathan A.C. Sterne (2006, ISBN:978–0–86542–871–3)
Examples
## Not run:
## Using the diet data (Clayton and Hills 1993) described in STATA manual
import diet data: require haven package to read dta format.
magrittr package for piping operation
diet <- haven::read_dta("https://www.stata-press.com/data/r16/diet.dta")
diet <- generate(diet, time, (dox - doe) / 365.25)
diet <- replace(diet, time, as.numeric(time))
diet <- generate(diet, age, as.numeric(doe - dob) / 365.25)
diet <- egen(diet, age, c(41, 51, 61, 71), new_var = ageband)
diet <- egen(diet, month, c(3, 6, 8), new_var = monthgrp)
## calculate overall rates and 95% Confidence intervals
strate(diet, time, fail, fail = c(1, 3, 13))
## per 100 unit
strate(diet, time, fail, fail = c(1, 3, 13), per = 100)
## calculate Stratified rates and 95% Confidence Intervals
strate(diet, time, fail, job, fail = c(1, 3, 13))
strate(diet, time, fail, job, ageband, monthgrp, fail = c(1, 3, 13))
## per 100 unit
strate(diet, time, fail, job, ageband, monthgrp, fail = c(1, 3, 13), per = 100)
## End(Not run)