File: sir.Rd

package info (click to toggle)
r-cran-popepi 0.4.13%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,656 kB
  • sloc: sh: 13; makefile: 2
file content (209 lines) | stat: -rw-r--r-- 8,297 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/sir.R
\name{sir}
\alias{sir}
\title{Calculate SIR or SMR}
\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{
\item{coh.data}{aggregated cohort data, see e.g. \verb{[lexpand]}}

\item{coh.obs}{variable name for observed cases; quoted or unquoted. A vector when using \code{mstata}.}

\item{coh.pyrs}{variable name for person years in cohort data;
quoted (as a string \code{'myvar'}) or unquoted (AKA as a name; \code{myvar})}

\item{ref.data}{population data. Can be left NULL if \code{coh.data}
is stratified in \code{print}. See \verb{[pophaz]} for details.}

\item{ref.obs}{variable name for observed cases; quoted or unquoted}

\item{ref.pyrs}{variable name for person-years in population data; quoted or unquoted}

\item{ref.rate}{population rate variable (cases/person-years). Overwrites
arguments \code{ref.pyrs} and \code{ref.obs}. Quoted or unquoted}

\item{subset}{logical condition to select data from \code{coh.data} before any computations}

\item{print}{variable names to stratify results; quoted vector or unquoted named list with functions}

\item{adjust}{variable names for adjusting without stratifying output; quoted vector or unquoted list}

\item{mstate}{set column names for cause specific observations; quoted or unquoted. Relevant only
when \code{coh.obs} length is two or more. See details.}

\item{test.type}{Test for equal SIRs. Test available are 'homogeneity' and 'trend'.}

\item{conf.type}{Confidence interval type: 'profile'(=default), 'wald' or 'univariate'.}

\item{conf.level}{Level of type-I error in confidence intervals, default 0.05 is 95\% CI.}

\item{EAR}{logical; TRUE calculates Excess Absolute Risks for univariate SIRs.
(see details)}
}
\value{
A sir-object that is a \code{data.table} with meta information in the attributes.
}
\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.
}
\details{
\code{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 (\code{print}) and compared to total.

\strong{Adjust and print}

A SIR can be adjusted or standardised using the covariates found in both \code{coh.data} and \code{ref.data}.
Variable to adjust are given in \code{adjust}.
Variable names needs to match in both \code{coh.data} and \code{ref.data}.
Typical variables to adjust by are gender, age group and calendar period.

\code{print} is used to stratify the SIR output. In other words, the variables
assigned to \code{print} are the covariates of the Poisson model.
Variable levels are treated as categorical.
Variables can be assigned in both \code{print} and \code{adjust}.
This means the output it adjusted and printed by these variables.

\code{print} can also be a list of expressions. This enables changing variable
names or transforming variables with functions such as \code{cut} and \code{round}.
For example, \code{agegroup} can be transformed on-the-go with

\code{print = list(my_ag = cut(agegroup, my_ag_breaks))}

\strong{ref.rate or ref.obs & ref.pyrs}

The population rate variable can be given to the \code{ref.rate} parameter.
That is, when using e.g. the \code{popmort} or a comparable data file, one may
supply \code{ref.rate} instead of \code{ref.obs} and \code{ref.pyrs}, which
will be ignored if \code{ref.rate} is supplied.

Note that if all the stratifying variables in
\code{ref.data} are not listed in \code{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.

\strong{mstate}

E.g. using \code{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 \code{sir}
in a vector via the \code{coh.obs} argument.
The name of the corresponding new column in \code{ref.data} is given in
\code{mstate}. It's recommended to include the \code{mstate} variable in \code{adjust},
so the corresponding information should also be available in \code{ref.data}.
More examples in sir-vignette.

This approach is analogous to where SIRs are calculated separately their
own function calls.

\strong{Other parameters}

\code{univariate} confidence intervals are calculated using exact
Poisson intervals (\code{poisson.ci}). The options \code{profile} and \code{wald} are
is based on a Poisson regression model: profile-likelihood confidence intervals
or Wald's normal-approximation. P-value is Poisson model based \code{conf.type}
or calculated using the method described by Breslow and Day. Function automatically
switches to another \code{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 \code{print}. The test can be either
\code{"homogeneity"}, a likelihood ratio test where the model variables defined in
\code{print} (factor) is compared to the constant model.
Option \code{"trend"} tests if the linear trend of the continuous variable in
\code{print} is significant (using model comparison).

\strong{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:
\deqn{EAR = \frac{observed - expected}{person years} \times 1000.}{EAR = (obs - exp)/pyrs * 1000.}

\strong{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:

\tabular{rrrrr}{
sex \tab age \tab period \tab obs \tab pyrs \cr
0 \tab 1 \tab 2010 \tab 0 \tab 390 \cr
0 \tab 2 \tab 2010 \tab 5 \tab 385 \cr
1 \tab 1 \tab 2010 \tab 3 \tab 308 \cr
1 \tab 2 \tab 2010 \tab 12 \tab 315
}
}
\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')


}
\seealso{
\verb{[lexpand]}
\href{../doc/sir.html}{A SIR calculation vignette}

Other sir functions: 
\code{\link{lines.sirspline}()},
\code{\link{plot.sirspline}()},
\code{\link{sir_exp}()},
\code{\link{sir_ratio}()},
\code{\link{sirspline}()}

Other main functions: 
\code{\link{Surv}()},
\code{\link{rate}()},
\code{\link{relpois}()},
\code{\link{relpois_ag}()},
\code{\link{sirspline}()},
\code{\link{survmean}()},
\code{\link{survtab}()},
\code{\link{survtab_ag}()}
}
\author{
Matti Rantanen, Joonas Miettinen
}
\concept{main functions}
\concept{sir functions}