```-------------------------------------------------------------------------------
help stgenreg postestimation                                also see:  stgenreg
-------------------------------------------------------------------------------

Title

stgenreg postestimation -- Postestimation tools for stgenreg

Description

The following standard postestimation commands are also available:

command             description
-------------------------------------------------------------------------
INCLUDE help post_estat
INCLUDE help post_estimates
INCLUDE help post_lincom
INCLUDE help post_lrtest
INCLUDE help post_nlcom
predict         predictions
INCLUDE help post_predictnl
INCLUDE help post_test
INCLUDE help post_testnl
-------------------------------------------------------------------------

Syntax for predict

predict newvar [if] [in] [, statistic]

statistic                  Description
-------------------------------------------------------------------------
Main
hazard                   hazard function
survival                 survival function
cumhazard                cumulative hazard function
ci                       calculate confidence intervals
stdp                     standard error of predicted function
timevar(varname)         time variable used for predictions (default
_t)
at(vn # [vn # ...])      predict at values of specified covariates
zeros                    sets all covariates to zero (baseline
prediction)
mata                     the user-defined [log] hazard function
contains a Mata only function, see details

Subsidiary
level                    sets confidence level (default 95)
-------------------------------------------------------------------------

Options for predict

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

hazard calculates the predicted hazard.

survival calculates the predicted survivor function

cumhazard calculates the predicted cumulative hazard.

ci calculate a confidence interval for the requested statistic and stores
the confidence limits in newvar_lci and newvar_uci.

stdp calculates standard error of prediction and stores it in newvar_se.

timevar(varname) defines the variable used as time in the predictions.
Default varname is _t. This is useful for large datasets where for
plotting purposes predictions are only needed for 200 observations
for example.  Note that some caution should be taken when using this
option as predictions may be made at whatever covariate values are in
the first 200 rows of data.  This can be avoided by using the at()
option and/or the zeros option to define the covariate patterns for
which you require the predictions.

at(varname # [ varname # ...]) requests that the covariates specified by
the listed varname(s) be set to the listed # values. For example,
at(x1 1 x3 50) would evaluate predictions at x1 = 1 and x3 = 50. This
is a useful way to obtain out of sample predictions. Note that if
at() is used together with zeros all covariates not listed in at()
are set to zero. If at() is used without zeros then all covariates
not listed in at() are set to their sample values. See also zeros.

zeros sets all covariates to zero (baseline prediction). For example,
predict s0, survival zeros calculates the baseline survival function.

mata uses Mata to calculate the prediction, required when a Mata only
function is included in the user-defined [log] hazard function used
to fit the model. ci is not available when mata is used.

+------------+
----+ Subsidiary +-------------------------------------------------------

level(#) sets the confidence level; default is level(95) or as set by set
level.

Examples

Setup
webuse brcancer
stset rectime, failure(censrec = 1) scale(365.25)

Weibull proportional hazards model
stgenreg, loghazard([ln_lambda] :+ [ln_gamma] :+
(exp([ln_gamma]):-1):*log(#t)) ln_lambda(hormon)
predict h1, hazard ci
predict s1, survival ci

Restricted cubic spline model on the log hazard scale
stgenreg, loghazard([xb]) xb(hormon | #rcs(df(3)))
predict h2, hazard ci
predict s2, survival ci
```