**[R] epitab** -- Tables for epidemiologists (ir and iri)

__Syntax__

**ir** *var_case* *var_exposed* *var_time* [*if*] [*in*] [*weight*] [**,** *ir_options*]

**iri** *#a #b #N1 #N2* [**,** __l__**evel(***#***)**]

*ir_options* Description
-------------------------------------------------------------------------
Options
**by(***varname* [**,** __mis__**sing**]**)** stratify on *varname*
__es__**tandard** combine external weights with within-stratum
statistics
__is__**tandard** combine internal weights with within-stratum
statistics
__s__**tandard(***varname***)** combine user-specified weights with
within-stratum statistics
__p__**ool** display pooled estimate
__noc__**rude** do not display crude estimate
__noh__**om** do not display homogeneity test
**ird** calculate standard incidence-rate difference
__l__**evel(***#***)** set confidence level; default is **level(95)**
-------------------------------------------------------------------------
**fweight**s are allowed; see weight.

__Menu__

__ir__
**Statistics > Epidemiology and related > Tables for epidemiologists >**
**Incidence-rate ratio**

__iri__

**Statistics > Epidemiology and related > Tables for epidemiologists >**
**Incidence-rate ratio calculator**

__Description__

**ir** is used with incidence-rate (incidence-density or person-time) data.
It calculates point estimates and confidence intervals for the
incidence-rate ratio and difference, along with attributable or prevented
fractions for the exposed and total population. **iri** is the immediate
form of **ir**; see immed. Also see **[R] poisson** and **[ST] stcox** for related
commands.

__Options__

+---------+
----+ Options +----------------------------------------------------------

**by(***varname* [**,** **missing**]**)** specifies that the tables be stratified on
*varname*. Missing categories in *varname* are omitted from the
stratified analysis, unless option **missing** is specified within **by()**.
Within-stratum statistics are shown and then combined with
Mantel-Haenszel weights. If **estandard**, **istandard**, or **standard()** is
also specified (see below), the weights specified are used in place
of Mantel-Haenszel weights.

**estandard**, **istandard**, and **standard(***varname***)** request that within-stratum
statistics be combined with external, internal, or user-specified
weights to produce a standardized estimate. These options are
mutually exclusive and can be used only when **by()** is also specified.
(When **by()** is specified without one of these options, Mantel-Haenszel
weights are used.)

**estandard** external weights are the person-time for the unexposed
controls.

**istandard** internal weights are the person-time for the exposed
controls. **istandard** can be used to produce, among other things,
standardized mortality ratios (SMRs).

**standard(***varname***)** allows user-specified weights. *varname* must
contain a constant within stratum and be nonnegative. The scale of
*varname* is irrelevant.

**pool** specifies that, in a stratified analysis, the directly pooled
estimate also be displayed. The pooled estimate is a weighted
average of the stratum-specific estimates using inverse-variance
weights, which are the inverse of the variance of the
stratum-specific estimate. **pool** is relevant only if **by()** is also
specified.

**nocrude** specifies that in a stratified analysis the crude estimate -- an
estimate obtained without regard to strata -- not be displayed.
**nocrude** is relevant only if **by()** is also specified.

**nohom** specifies that a chi-squared test of homogeneity not be included in
the output of a stratified analysis. This tests whether the exposure
effect is the same across strata and can be performed for any pooled
estimate -- directly pooled or Mantel-Haenszel. **nohom** is relevant
only if **by()** is also specified.

**ird** may be used only with **estandard**, **istandard**, or **standard()**. It
requests that **ir** calculate the standardized incidence-rate difference
rather than the default incidence-rate ratio.

**level(***#***)** specifies the confidence level, as a percentage, for confidence
intervals. The default is **level(95)** or as set by **set level**.

__Examples__

---------------------------------------------------------------------------
Setup
**. webuse irxmpl**

List the data
**. list**

Calculate incidence-rate ratios, differences, etc.
**. ir cases exposed time**

Immediate form of above command
**. iri 15 41 19017 28010**

---------------------------------------------------------------------------
Setup
**. webuse rm**

List the data
**. list**

Perform stratified analysis of the incidence-rate ratio
**. ir deaths male pyears, by(age)**

Same as above, but report 90% confidence intervals
**. ir deaths male pyears, by(age) level(90)**

---------------------------------------------------------------------------
Setup
**. webuse dollhill2**

List the data
**. list**

Perform stratified analysis of the incidence-rate ratio, reporting 90%
confidence intervals
**. ir deaths smokes pyears, by(age) level(90)**

Perform stratified analysis of the standardized incidence-rate ratio,
reporting 90% confidence intervals
**. ir deaths smokes pyears, by(age) level(90) istandard**

Same as above, but also display the directly pooled estimate
**. ir deaths smokes pyears, by(age) level(90) istandard pool**

Same as above, but compute the standardized incidence-rate difference,
rather than the incidence-rate ratio
**. ir deaths smokes pyears, by(age) level(90) istandard pool ird**

Perform stratified analysis of the standardized incidence-rate ratio,
making weights proportional to person-time of the unexposed group
**. ir deaths smokes pyears, by(age) estandard**

Create a variable that is always equal to 1
**. generate conswgt = 1**

Perform stratified analysis of the standardized incidence-rate ratio,
weighting each age category equally
**. ir deaths smokes pyears, by(age) standard(conswgt)**
---------------------------------------------------------------------------

__Video example__

Incidence-rate ratios calculator

__Stored results__

**ir** and **iri** store the following in **r()**:

Scalars
**r(p)** one-sided p-value
**r(ird)** incidence-rate difference
**r(lb_ird)** lower bound of CI for **ird**
**r(ub_ird)** upper bound of CI for **ird**
**r(irr)** incidence-rate ratio
**r(lb_irr)** lower bound of CI for **irr**
**r(ub_irr)** upper bound of CI for **irr**
**r(afe)** attributable (prev.) fraction among exposed
**r(lb_afe)** lower bound of CI for **afe**
**r(ub_afe)** upper bound of CI for **afe**
**r(afp)** attributable fraction for the population
**r(crude)** crude estimate (**ir** only)
**r(lb_crude)** lower bound of CI for **crude**
**r(ub_crude)** upper bound of CI for **crude**
**r(pooled)** pooled estimate (**ir** only)
**r(lb_pooled)** lower bound of CI for **pooled**
**r(ub_pooled)** upper bound of CI for **pooled**
**r(chi2_mh)** Mantel-Haenszel homogeneity chi-squared (**ir** only)
**r(chi2_p)** pooled homogeneity chi-squared
**r(df)** degrees of freedom (**ir** only)