crude.rates | R Documentation |
Calculates the rate of specified events relative to the amount of follow-up time, based on panel data. It allows for the segmentation of data into different time periods (eras) and computes the event rates for these periods.
crude.rates(
dat,
outcome.names,
cut.points = NULL,
time.multiplier = 1,
id.name = "id",
t1.name = "t1",
t2.name = "t2",
grouping.variables = NULL,
type = "overall",
na.rm = TRUE,
era.name = "period"
)
dat |
A data frame structured as panel data. |
outcome.names |
A character vector of variable names from dat, expected to be binary, representing the events of interest. The function calculates the rates of these events within the specified time intervals. Variables not in dat or non-binary will be ignored. |
cut.points |
A numeric vector specifying the end points of time intervals for rate calculation. The data is split into eras based on these points, and rates are computed for each interval. |
time.multiplier |
A numeric value that scales the computed rates, useful for converting rates to a standard time unit (e.g., per 1000 person-years). |
id.name |
The character name of the identifying variable within dat, used for tracking individuals across multiple data rows. |
t1.name |
The character name of the time variable within dat representing the start (left endpoint) of observation intervals. |
t2.name |
The character name of the time variable within dat representing the end (right endpoint) of observation intervals. |
grouping.variables |
A character vector of variables in dat to group the results by. |
type |
Specifies the counting method: "distinct" for counting only new occurrences separated by zeros, or "overall" (default) for counting all records with the event. |
na.rm |
A logical indicating whether to exclude missing values from the calculations. |
era.name |
The character string used to name the time period column in the resulting table. |
Returns a data table containing the calculated rates of the specified events for each group and time period (era). The rates are presented alongside the grouping variables and the specified era. Each row corresponds to a unique combination of the grouping variables and time period, with the event rates adjusted according to the specified time.multiplier. The output facilitates the comparison of event rates across different segments of follow-up time and subgroups within the data.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.