sir {popEpi} | R Documentation |
Calculate SIR or SMR
Description
Poisson modelled standardised incidence or mortality ratios (SIRs / SMRs) i.e. indirect method for calculating standardised rates. SIR is a ratio of observed and expected cases. Expected cases are derived by multiplying the strata-specific population rate with the corresponding person-years of the cohort.
Usage
sir(
coh.data,
coh.obs,
coh.pyrs,
ref.data = NULL,
ref.obs = NULL,
ref.pyrs = NULL,
ref.rate = NULL,
subset = NULL,
print = NULL,
adjust = NULL,
mstate = NULL,
test.type = "homogeneity",
conf.type = "profile",
conf.level = 0.95,
EAR = FALSE
)
Arguments
coh.data |
aggregated cohort data, see e.g. |
coh.obs |
variable name for observed cases; quoted or unquoted. A vector when using |
coh.pyrs |
variable name for person years in cohort data;
quoted (as a string |
ref.data |
population data. Can be left NULL if |
ref.obs |
variable name for observed cases; quoted or unquoted |
ref.pyrs |
variable name for person-years in population data; quoted or unquoted |
ref.rate |
population rate variable (cases/person-years). Overwrites
arguments |
subset |
logical condition to select data from |
print |
variable names to stratify results; quoted vector or unquoted named list with functions |
adjust |
variable names for adjusting without stratifying output; quoted vector or unquoted list |
mstate |
set column names for cause specific observations; quoted or unquoted. Relevant only
when |
test.type |
Test for equal SIRs. Test available are 'homogeneity' and 'trend'. |
conf.type |
Confidence interval type: 'profile'(=default), 'wald' or 'univariate'. |
conf.level |
Level of type-I error in confidence intervals, default 0.05 is 95% CI. |
EAR |
logical; TRUE calculates Excess Absolute Risks for univariate SIRs. (see details) |
Details
sir
is a comprehensive tool for modelling SIRs/SMRs with flexible
options to adjust and print SIRs, test homogeneity and utilize
multi-state data. The cohort data and the variable names for observation
counts and person-years are required.
The reference data is optional, since the cohort data
can be stratified (print
) and compared to total.
Adjust and print
A SIR can be adjusted or standardised using the covariates found in both coh.data
and ref.data
.
Variable to adjust are given in adjust
.
Variable names needs to match in both coh.data
and ref.data
.
Typical variables to adjust by are gender, age group and calendar period.
print
is used to stratify the SIR output. In other words, the variables
assigned to print
are the covariates of the Poisson model.
Variable levels are treated as categorical.
Variables can be assigned in both print
and adjust
.
This means the output it adjusted and printed by these variables.
print
can also be a list of expressions. This enables changing variable
names or transforming variables with functions such as cut
and round
.
For example, the existing variables agegroup
and year
could be
transformed to new levels using cut
by
print = list( age.category = cut(agegroup, breaks = c(0,50,75,100)),
year.cat = cut(year, seq(1950,2010,20)))
ref.rate or ref.obs & ref.pyrs
The population rate variable can be given to the ref.rate
parameter.
That is, when using e.g. the popmort
or a comparable data file, one may
supply ref.rate
instead of ref.obs
and ref.pyrs
, which
will be ignored if ref.rate
is supplied.
Note that if all the stratifying variables in
ref.data
are not listed in adjust
,
or when the categories are otherwise combined,
the (unweighted) mean of rates is used for computing expected cases.
This might incur a small bias in comparison to when exact numbers of observations
and person-years are available.
mstate
E.g. using lexpand
it's possible to compute counts for several outcomes
so that the population at risk is same for each
outcome such as a certain kind of cancer.
The transition counts are in wide data format,
and the relevant columns can be supplied to sir
in a vector via the coh.obs
argument.
The name of the corresponding new column in ref.data
is given in
mstate
. It's recommended to include the mstate
variable in adjust
,
so the corresponding information should also be available in ref.data
.
More examples in sir-vignette.
This approach is analogous to where SIRs are calculated separately their own function calls.
Other parameters
univariate
confidence intervals are calculated using exact
Poisson intervals (poisson.ci
). The options profile
and wald
are
is based on a Poisson regression model: profile-likelihood confidence intervals
or Wald's normal-approximation. P-value is Poisson model based conf.type
or calculated using the method described by Breslow and Day. Function automatically
switches to another conf.type
if calculation is not possible with a message.
Usually model fit fails if there is print stratum with zero expected values.
The LRT p-value tests the levels of print
. The test can be either
"homogeneity"
, a likelihood ratio test where the model variables defined in
print
(factor) is compared to the constant model.
Option "trend"
tests if the linear trend of the continuous variable in
print
is significant (using model comparison).
EAR: Excess Absolute Risk
Excess Absolute Risk is a simple way to quantify the absolute difference between cohort risk and population risk. Make sure that the person-years are calculated accordingly before using EAR. (when using mstate)
Formula for EAR:
EAR = \frac{observed - expected}{person years} \times 1000.
Data format
The data should be given in tabulated format. That is the number of observations and person-years are represented for each stratum. Note that also individual data is allowed as long as each observations, person-years, and print and adjust variables are presented in columns. The extra variables and levels are reduced automatically before estimating SIRs. Example of data format:
sex | age | period | obs | pyrs |
0 | 1 | 2010 | 0 | 390 |
0 | 2 | 2010 | 5 | 385 |
1 | 1 | 2010 | 3 | 308 |
1 | 2 | 2010 | 12 | 315 |
Value
A sir-object that is a data.table
with meta information in the attributes.
Author(s)
Matti Rantanen, Joonas Miettinen
See Also
lexpand
A SIR calculation vignette
Other sir functions:
lines.sirspline()
,
plot.sirspline()
,
sir_exp()
,
sir_ratio()
,
sirspline()
Other main functions:
Surv()
,
rate()
,
relpois()
,
relpois_ag()
,
sirspline()
,
survmean()
,
survtab()
,
survtab_ag()
Examples
data(popmort)
data(sire)
c <- lexpand( sire, status = status, birth = bi_date, exit = ex_date, entry = dg_date,
breaks = list(per = 1950:2013, age = 1:100, fot = c(0,10,20,Inf)),
aggre = list(fot, agegroup = age, year = per, sex) )
## SMR due other causes: status = 2
se <- sir( coh.data = c, coh.obs = 'from0to2', coh.pyrs = 'pyrs',
ref.data = popmort, ref.rate = 'haz',
adjust = c('agegroup', 'year', 'sex'), print = 'fot')
se
## for examples see: vignette('sir')