## Stata 15 help for stintreg postestimation

```
[ST] stintreg postestimation -- Postestimation tools for stintreg

Postestimation commands

The following postestimation commands are of special interest after
stintreg:

Command            Description
-------------------------------------------------------------------------
estat gofplot      produce goodness-of-fit plot
stcurve            plot the survivor, hazard, and cumulative hazard
functions
-------------------------------------------------------------------------

The following standard postestimation commands are also available:

Command            Description
-------------------------------------------------------------------------
contrast         contrasts and ANOVA-style joint tests of estimates
estat ic         Akaike's and Schwarz's Bayesian information criteria
(AIC and BIC)
estat summarize  summary statistics for the estimation sample
estat vce        variance-covariance matrix of the estimators (VCE)
estat (svy)      postestimation statistics for survey data
estimates        cataloging estimation results
* hausman          Hausman's specification test
lincom           point estimates, standard errors, testing, and
inference for linear combinations of coefficients
* lrtest           likelihood-ratio test
margins          marginal means, predictive margins, marginal effects,
and average marginal effects
marginsplot      graph the results from margins (profile plots,
interaction plots, etc.)
nlcom            point estimates, standard errors, testing, and
inference for nonlinear combinations of coefficients
predict          predictions, residuals, influence statistics, and
other diagnostic measures
predictnl        point estimates, standard errors, testing, and
inference for generalized predictions
pwcompare        pairwise comparisons of estimates
suest            seemingly unrelated estimation
test             Wald tests of simple and composite linear hypotheses
testnl           Wald tests of nonlinear hypotheses
-------------------------------------------------------------------------
* hausman and lrtest are not appropriate with svy estimation results.

Syntax for predict

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

predict [type] newvar_l newvar_u [if] [in] , statistic2 [options]

predict [type] {stub*|newvarlist} [if] [in], scores

statistic          Description
-------------------------------------------------------------------------
Main
median time      median survival time; the default
median lntime    median ln(survival time)
mean time        mean survival time
mean lntime      mean ln(survival time)
hr               hazard ratio, also known as the relative hazard
xb               linear prediction
stdp             standard error of the linear prediction; SE(xb)
* mgale            martingale-like residuals
-------------------------------------------------------------------------

statistic2         Description
-------------------------------------------------------------------------
Main
hazard           hazard for interval endpoints ltime and rtime
surv             survivor probability for interval endpoints ltime and
rtime
* csnell           Cox-Snell residuals for interval endpoints ltime and
rtime
-------------------------------------------------------------------------

options            Description
-------------------------------------------------------------------------
Main
nooffset           ignore the offset() variable specified in stintreg
oos                make statistic and statistic2 available in and out of
sample
-------------------------------------------------------------------------

Unstarred statistics are available both in and out of sample; type
predict ... if e(sample) ... if wanted only for the estimation sample.
Starred statistics are calculated for the estimation sample by default,
but the oos option makes them available both in and out of sample.
The predicted hazard ratio, option hr, is available only for the
exponential, Weibull, and Gompertz models. The mean time and mean
lntime options are not available for the Gompertz model.
csnell and mgale are not allowed with svy estimation results.

Statistics > Postestimation

Description for predict

predict creates a new variable containing predictions such as median and
mean survival times, hazards, hazard ratios, linear predictions, standard
errors, probabilities, Cox-Snell and martingale-like residuals.

Options for predict

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

median time calculates the predicted median survival time in
analysis-time units.  When no options are specified with predict, the
predicted median survival time is calculated for all models.

median lntime calculates the natural logarithm of what median time
produces.

mean time calculates the predicted mean survival time in analysis-time
units.  This option is not available for Gompertz regression.

mean lntime predicts the mean of the natural logarithm of time.  This
option is not available for Gompertz regression.

hazard calculates the predicted hazard for both the lower endpoint ltime
and the upper endpoint rtime of the time interval.

hr calculates the hazard ratio.  This option is valid only for models
having a proportional-hazards parameterization.

xb calculates the linear prediction from the fitted model. That is, you
fit the model by estimating a set of parameters b0, b1, b2, ..., bk,
and the linear prediction is y = xb.

The x used in the calculation is obtained from the data currently in
memory and need not correspond to the data on the independent
variables used in estimating b.

stdp calculates the standard error of the prediction, that is, the
standard error of y.

surv calculates each observation's predicted survivor probabilities for
both the lower endpoint ltime and the upper endpoint rtime of the
time interval.

csnell calculates the Cox-Snell residuals for both the lower endpoint
ltime and the upper endpoint rtime of the time interval.

mgale calculates interval-censored martingale-like residuals, which are
an interval-censored version of martingale-like residuals for
right-censored data.

nooffset is relevant only if you specified offset(varname) with stintreg.
It modifies the calculations made by predict so that they ignore the
offset variable; the linear prediction is treated as xb rather than
xb + offset.

oos makes csnell and mgale available both in and out of sample.  oos also
dictates that summations and other accumulations take place over the
sample as defined by if and in.  By default, the summations are taken
over the estimation sample, with if and in merely determining which
values of newvar, newvar_l, and newvar_u are to be filled in once the
calculation is finished.

scores calculates equation-level score variables.  The number of score
variables created depends upon the chosen distribution.

The first new variable will always contain the partial derivative of
the log likelihood with respect to the linear prediction (regression
equation) from the fitted model.

The subsequent new variables will contain the partial derivative of
the log likelihood with respect to the ancillary parameters.

Syntax for margins

margins [marginlist] [, options]

margins [marginlist] , predict(statistic ...) [predict(statistic ...)
...] [options]

statistic          Description
-------------------------------------------------------------------------
median time        median survival time; the default
median lntime      median ln(survival time)
mean time          mean survival time
mean lntime        mean ln(survival time)
hr                 hazard ratio, also known as the relative hazard
xb                 linear prediction
stdp               not allowed with margins
hazard             not allowed with margins
surv               not allowed with margins
csnell             not allowed with margins
mgale              not allowed with margins
-------------------------------------------------------------------------

Hazard estimation is not allowed because it produces interval estimates.

Statistics not allowed with margins are functions of stochastic
quantities other than e(b).

For the full syntax, see [R] margins.

Statistics > Postestimation

Description for margins

margins estimates margins of response for median and mean survival times,
hazard ratios, and linear predictions.

Syntax for estat gofplot

estat gofplot [, options]

options                             Description
-------------------------------------------------------------------------
outfile(filename[, replace])      save values used to plot the
goodness-of-fit graph

Plot
connect_options                   affect rendition of plotted
cumulative hazard function

Reference line
rlopts(cline_options)             affect rendition of the reference
line

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
-------------------------------------------------------------------------

Statistics > Postestimation

Description for estat gofplot

estat gofplot plots the Cox-Snell residuals versus the estimated
cumulative hazard function corresponding to these residuals to assess the
goodness of fit of the model visually.

Options for estat gofplot

outfile(filename[, replace]) saves in filename.dta the values used to
plot the goodness-of-fit graph.

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

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

+----------------+
----+ Reference line +---------------------------------------------------

rlopts(cline_options) affects the rendition of the reference line; see
[G-3] cline_options.

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

addplot(plot) provides a way to add other plots to the generated graph;

+-----------------------------------------+
----+ 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

Setup
. webuse cosmesis

Fit Weibull survival model
. stintreg i.treat, distribution(weibull) interval(ltime rtime)

Predict median survival time
. predict time, time

Predict log-median survival time
. predict lntime, lntime

Predict adjusted Cox-Snell residuals
. predict double cs, csnell adjusted

Predict martingale-like residuals
. predict double mg, mgale

Graphically test goodness of fit of the model
. estat gofplot

```