**[ST] stcurve** -- Plot survivor, hazard, cumulative hazard, or cumulative
incidence function

__Syntax__

**stcurve** [**,** *options*]

*options* Description
-------------------------------------------------------------------------
Main
* __sur__**vival** plot survivor function
* __haz__**ard** plot hazard function
* __cumh__**az** plot cumulative hazard function
* **cif** plot cumulative incidence function
**at(***varname***=***#* [*varname***=***# ...*]**)** value of the specified covariates and
[**at1(***varname***=***#* [*varname***=***# ...*]**)** mean of unspecified covariates
[**at2(***varname***=***#* [*varname***=***# ...*]**)**
[...]]]

Options
__alpha__**1** conditional frailty model
__fixed__**only** set all random effects to zero
__uncond__**itional** unconditional frailty model or
random-effects model
__marg__**inal** synonym for **unconditional**
__r__**ange(***# #***)** range of analysis time
__out__**file(***filename* [**,** **replace**]**)** save values used to plot the curves
**width(***#***)** override "optimal" width; use with
**hazard**
__k__**ernel(***kernel***)** kernel function; use with **hazard**
__nob__**oundary** no boundary correction; use with
**hazard**

Plot
*connect_options* affect rendition of plotted survivor,
hazard, or cumulative hazard
function

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*
-------------------------------------------------------------------------
* One of **survival**, **hazard**, **cumhaz**, or **cif** must be specified.
**survival** and **hazard** are not allowed after estimation with **stcrreg**.
**cif** is allowed only after estimation with **stcrreg**.

__Menu__

**Statistics > Survival analysis > Regression models >** **Plot survivor,**
**hazard, cumulative hazard, or cumulative incidence function**

__Description__

**stcurve** plots the survivor, hazard, or cumulative hazard function after
**stcox**, **streg**, **stintreg**, **mestreg**, **xtstreg**. **stcurve** also plots the
cumulative subhazard or cumulative incidence function after **stcrreg**.

__Options__

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

**survival** specifies that the survivor function be plotted. **survival** is
not allowed after estimation with **stcrreg**.

**hazard** specifies that the hazard function be plotted. **hazard** is not
allowed after estimation with **stcrreg**.

**cumhaz** specifies that the cumulative hazard function be plotted when used
after **stcox**, **streg**, **stintreg**, **mestreg**, or **xtstreg** and specifies that
the cumulative subhazard function be plotted when used after **stcrreg**.

**cif** specifies that the cumulative incidence function be plotted. This
option is available only after estimation with **stcrreg**.

**at(***varname***=***# ...***)** specifies that the covariates specified by *varname* be
set to *#*. By default, **stcurve** evaluates the function by setting each
covariate to its mean value. This option causes the function to be
evaluated at the value of the covariates listed in **at()** and at the
mean of all unlisted covariates.

**at1(***varname***=***# ...***)**, **at2(***varname***=***# ...***)**, ..., **at10(***varname***=***# ...***)**
specify that multiple curves (up to 10) be plotted on the same graph.
**at1()**, **at2()**, ..., **at10()** work like the **at()** option. They specify
that the function be evaluated at the value of the covariates
specified and at the mean of all unlisted covariates. **at1()**
specifies the values of the covariates for the first curve, **at2()**
specifies the values of the covariates for the second curve, and so
on.

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

**alpha1**, when used after fitting a frailty model, plots curves that are
conditional on a frailty value of one. This is the default for
shared-frailty models.

**fixedonly** specifies that all random effects be set to zero, which is
equivalent to using only the fixed portion of the model, when
plotting results for random-effects models. This option is allowed
only after **xtstreg** or **mestreg**; it is the default after **xtstreg**.

**unconditional** and **marginal**, when used after fitting a frailty model or a
random-effects model, plot curves that are unconditional on the
frailty or on the random effects. That is, the curve is "averaged"
over the frailty distribution or over the random-effects
distributions. This is the default for unshared-frailty models and
for random-effects models. This option is not allowed after **stintreg**
or **xtstreg**.

**range(***# #***)** specifies the range of the time axis to be plotted. If this
option is not specified, **stcurve** plots the desired curve on an
interval expanding from the earliest to the latest time in the data.

**outfile(***filename* [**,** **replace**]**)** saves in *filename***.dta** the values used to
plot the curve(s).

**width(***#***)** is for use with **hazard** (and applies only after **stcox**) and is
used to specify the bandwidth to be used in the kernel smooth used to
plot the estimated hazard function. If left unspecified, a default
bandwidth is used, as described in **[R] kdensity**.

**kernel(***kernel***)** is for use with **hazard** and is for use only after **stcox**
because, for Cox regression, an estimate of the hazard function is
obtained by smoothing the estimated *hazard contributions*. **kernel()**
specifies the kernel function for use in calculating the weighted
kernel-density estimate required to produce a smoothed
hazard-function estimator. The default is **kernel(epanechnikov)**, yet
*kernel* may be any of the kernels supported by **kdensity**; **[R] kdensity**.

**noboundary** is for use with **hazard** and applies only to the plotting of
smoothed hazard functions after **stcox**. It specifies that no
boundary-bias adjustments are to be made when calculating the
smoothed hazard-function estimator. By default, the smoothed hazards
are adjusted near the boundaries; see **[ST] sts graph**. If the **epan2**,
**biweight**, or **rectangular** kernel is used, the bias correction near the
boundary is performed using boundary kernels. For other kernels, the
plotted range of the smoothed hazard function is restricted to be
inside of one bandwidth from each endpoint. For these other kernels,
specifying **noboundary** merely removes this range restriction.

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

*connect_options* affect the rendition of the plotted survivor, hazard, or
cumulative hazard function; see **[G-3]** *connect_options*.

+-----------+
----+ 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*).

__Examples after stcox__

Setup
**. webuse drugtr**

Fit Cox model
**. stcox age drug**

Plot the estimated survivor function
**. stcurve, survival**

Plot the estimated survivor function for the placebo group and for the
treatment group
**. stcurve, survival at1(drug=0) at2(drug=1)**

Plot the estimated hazard function for the placebo group and for the
treatment group on a log scale
**. stcurve, hazard at1(drug=0) at2(drug=1) kernel(gauss)** **yscale(log)**

__Examples after streg__

---------------------------------------------------------------------------
Setup
**. webuse cancer**

Map values for **drug** into 0 for placebo and 1 for nonplacebo
**. replace drug = drug == 2 | drug == 3**

Fit a loglogistic survival model
**. streg age drug, d(llog)**

Plot the survivor function
**. stcurve, survival ylabels(0 .5 1)**

Plot the hazard function
**. stcurve, hazard**

Plot the survivor function for the placebo group and for the treatment
group
**. stcurve, survival at1(drug=0) at2(drug=1) ylabels(0 .5 1)**

---------------------------------------------------------------------------
Setup
**. webuse catheter, clear**

Declare data to be survival-time data
**. stset time infect**

Fit a Weibull/inverse-Gaussian shared-frailty model
**. streg age female, d(weibull) frailty(invgauss) shared(patient)**

Plot the individual hazard function for females at mean age
**. stcurve, hazard at(female=1) alpha1**

Plot the population hazard function for females at mean age
**. stcurve, hazard at(female=1) unconditional**

---------------------------------------------------------------------------

__Example after stcrreg__

Setup
**. webuse hypoxia**

Declare data to be survival-time data
**. stset dftime, failure(failtype==1)**

Fit competing-risks model
**. stcrreg ifp tumsize pelnode, compete(failtype==2)**

Compare cumulative incidence functions for two groups with remaining
covariates held at their mean values
**. stcurve, cif at1(pelnode=0) at2(pelnode=1)**

__Example after mestreg__

Setup
**. webuse catheter**

Random-effects Weibull survival model
**. mestreg age female || patient:, distribution(weibull)**

Compare marginal survivor functions for males and females at age 53
**. stcurve, surv at1(female=0 age=53) at2(female=1 age=53)**
__Example after xtstreg__

Setup
**. webuse catheter**
**. xtset patient**

Random-effects Weibull survival model
**. xtstreg age female, distribution(weibull)**

Compare survivor functions for males and females at mean age conditional
on zero random effects
**. stcurve, surv at1(female=0) at2(female=1)**

__Example after stintreg__

Setup
**. webuse cosmesis**

Fit a Weibull survival model for interval-censored data
**. stintreg i.treat, distribution(weibull) interval(ltime rtime)**

Compare survivor functions for two treatments: radiotherapy only and
radiation plus chemotherapy
**. stcurve, surv at1(treat=0) at2(treat=1)**