**[ST] ltable** -- Life tables for survival data

__Syntax__

**ltable** *timevar* [*deadvar*] [*if*] [*in*] [*weight*] [**,** *options*]

*timevar* specifies the time of failure or censoring. If *deadvar* is not
specified, all values of *timevar* are interpreted as failure times.
Observations with *timevar* equal to missing are ignored.

*deadvar* specifies how the time recorded in *timevar* is to be interpreted.
Observations with *deadvar* equal to 0 are treated as censored and all
other nonmissing values indicate that *timevar* should be interpreted
as a failure time. Observations with *deadvar* equal to missing are
ignored.

*deadvar* does not specify the number of failures. Specify frequency
weights for aggregated data recording the number of failures.

*options* Description
-------------------------------------------------------------------------
Main
__nota__**ble** display graph only; suppress display of
table
__g__**raph** present the table graphically, as well as
in tabular form
**by(***groupvar***)** produce separate tables (or graphs) for
each value of *groupvar*
__t__**est** report chi-squared measure of differences
between groups (2 tests)
**overlay** overlay plots on the same graph
__su__**rvival** display survival table; the default
__f__**ailure** display cumulative failure table
__h__**azard** display hazard table
**ci** graph confidence interval
__l__**evel(***#***)** set confidence level; default is **level(95)**
__noa__**djust** suppress actuarial adjustment to the
number at risk
__tv__**id(***varname***)** subject ID variable to use with
time-varying parameters
__i__**ntervals(w**|*numlist***)** time intervals in which data are to be
aggregated for tables
__sav__**ing(***filename*[**,** **replace**]**)** save the life-table data to *filename*; use
**replace** to overwrite existing *filename*

Plot
__ploto__**pts(***plot_options***)** affect rendition of the plotted line and
plotted points
__plot____#__**opts(***plot_options***)** affect rendition of the *#*th plotted line
and plotted points; available only with
**overlay**

CI plot
__ciop__**ts(***rspike_options***)** affect rendition of the confidence
intervals
__ci____#__**opts(***rspike_options***)** affect rendition of the *#*th confidence
interval; available only with **overlay**

Add plots
**addplot(***plot***)** add other plots to the generated graph

Y axis, X axis, Titles, Legend, Overall
*twoway_options* any options other than **by()** documented in
**[G-3]** *twoway_options*
__byop__**ts(***byopts***)** how subgraphs are combined, labeled, etc.
-------------------------------------------------------------------------

*plot_options* Description
-------------------------------------------------------------------------
*connect_options* change look of lines or connecting method
*marker_options* change look of markers (color, size, etc.)
-------------------------------------------------------------------------

**fweight**s are allowed; see weight.

__Menu__

**Statistics > Survival analysis > Summary statistics, tests, and tables >**
**Life tables for survival data**

__Description__

**ltable** displays and graphs life tables for individual-level or aggregate
data and optionally presents the likelihood-ratio and log-rank tests for
equivalence of groups. **ltable** also allows you to examine the empirical
hazard function through aggregation.

__Options__

+------+
----+ Main +-------------------------------------------------------------

**notable** suppresses displaying the table. This option is often used with
**graph**.

**graph** requests that the table be presented graphically, as well as in
tabular form; when **notable** is also specified, only the graph is
presented. When you specify **graph**, only one table can be calculated
and graphed at a time; see **survival**, **failure**, and **hazard** below.

**graph** may not be specified with **hazard**. Use **sts graph** to graph
estimates of the hazard function.

**by(***groupvar***)** creates separate tables (or graphs within the same image)
for each value of *groupvar*. *groupvar* may be string or numeric.

**test** presents two chi-squared measures of the differences between groups,
the likelihood-ratio test of homogeneity and the log-rank test for
equality of survivor functions. The two groups are identified by the
**by()** option, so **by()** must also be specified.

**overlay** causes the plot from each group identified in the **by()** option to
be overlaid on the same graph. The default is to generate a separate
graph (within the same image) for each group. This option requires
the **by()** option.

**survival**, **failure**, and **hazard** indicate the table to be displayed. If
none is specified, the default is the survival table. Specifying
**failure** displays the cumulative failure table. Specifying **survival**
**failure** would display both the survival and the cumulative failure
table. If **graph** is specified, multiple tables may not be requested.

**ci** graphs the confidence intervals around **survival**, **failure**, or **hazard**.

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

**noadjust** suppresses the actuarial adjustment to the number at risk. The
default is to consider the adjusted number at risk for each interval
as the total at the start minus (the number of censored)/2. If
**noadjust** is specified, the number at risk is simply the total at the
start, corresponding to the standard Kaplan-Meier assumption.
**noadjust** should be specified when using **ltable** to list results
corresponding to those produced by **sts list**.

**tvid(***varname***)** is for use with longitudinal data with time-varying
parameters. Each subject appears in the data more than once, and
equal values of *varname* identify observations referring to the same
subject. When **tvid()** is specified, only the last observation on each
subject is used in making the table. The order of the data does not
matter, and *last* here means the last observation chronologically.

**intervals(w**|*numlist***)** specifies the intervals into which the data are to
be aggregated for tabular presentation. A numeric argument is
interpreted as the width of the interval. For instance, **interval(2)**
aggregates data into the intervals 0<=t<2, 2<=t<4, and so on. Not
specifying **interval()** is equivalent to specifying **interval(1)**.
Because in most data, failure times are recorded as integers, this
amounts to no aggregation except that implied by the recording of the
time variable, and so it produces Kaplan-Meier product-limit
estimates of the survival curve (with an actuarial adjustment; see
the **noadjust** option above). Also see **[ST] sts list**. Although it is
possible to examine survival and failure without aggregation, some
form of aggregation is almost always required for examining the
hazard.

When more than one argument is specified, intervals are aggregated as
specified. For instance, **interval(0,2,8,16)** aggregates data into the
intervals [0,2), [2,8), [8,16), and (if necessary) [16, infinity).

**interval(w)** is equivalent to
**interval(0,7,15,30,60,90,180,360,540,720)**, corresponding to 1 week,
(roughly) 2 weeks, 1 month, 2 months, 3 months, 6 months, 1 year, 1.5
years, and 2 years when failure times are recorded in days. The **w**
suggests widening intervals.

**saving(***filename*[**,** **replace**]**)** creates a Stata data file (**.dta** file)
containing the life table. This option will not save the graph to
disk; see **[G-2] graph save** to save the resulting graph to disk.

**replace** specifies that *filename* be overwritten if it exists. This
option is not shown in the dialog box.

+------+
----+ Plot +-------------------------------------------------------------

**plotopts(***plot_options***)** affects the rendition of the plotted line and
plotted points; see **[G-3]** *connect_options* and **[G-3]** *marker_options*.

**plot***#***opts(***plot_options***)** affects the rendition of the *#*th plotted line and
plotted points; see **[G-3]** *connect_options* and **[G-3]** *marker_options*.
This option is valid only if **overlay** is specified.

+---------+
----+ CI plot +----------------------------------------------------------

**ciopts(***rspike_options***)** affects the rendition of the confidence intervals
for the graphed survival, failure, or hazard; see **[G-3]**
*rspike_options*.

**ci***#***opts(***rspike_options***)** affects the rendition of the *#*th confidence
interval for the graphed survival, failure, or hazard; see **[G-3]**
*rspike_options*. This option is valid only if **overlay** is specified.

+-----------+
----+ Add plots +--------------------------------------------------------

**addplot(***plot***)** provides a way to add other plots to the generated graph;
see **[G-3]** *addplot_option*.

+-----------------------------------------+
----+ Y axis, X axis, Titles, Legend, Overall +--------------------------

*twoway_options* are any of the options documented in **[G-3]** *twoway_options*,
excluding **by()**. These include options for titling the graph (see
**[G-3]** *title_options*) and for saving the graph to disk (see **[G-3]**
*saving_option*).

**byopts(***byopts***)** affects the appearance of the combined graph when **by()** is
specified, including the overall graph title and the organization of
subgraphs. See **[G-3]** *by_option*.

__Examples__

---------------------------------------------------------------------------
Setup
**. webuse rat**

List some of the data
**. list in 1/5**
**. list if died == 0**

Display the life table for group 1
**. ltable t died if group == 1**

Display the life table for group 1 aggregated into 30-day intervals
**. ltable t died if group == 1, interval(30)**

Display the life table for group 1 using the specified intervals
**. ltable t died if group == 1, interval(120,180,210,240,330)**

Display separate life tables for each group and aggregate into 30-day
intervals
**. ltable t died, by(group) interval(30)**

Display a failure table for group 1 aggregated into 30-day intervals
**. ltable t died if group == 1, interval(30) failure**

---------------------------------------------------------------------------
Setup
**. webuse selvin**

List some of the data
**. list in 1/5**

Obtain survival rates, and show both table and graph
**. ltable t died [freq=pop], graph**

---------------------------------------------------------------------------
Setup
**. webuse tumor**

List some of the data
**. list in 1/6, sep(0)**

Display the hazard table
**. ltable t d [freq=pop], hazard interval(0(1)9)**
---------------------------------------------------------------------------

__Video example__

How to construct life tables