*! version 1.4.9 22Jun2022
help stmt postestimation
also see: stmt

Title

[ST] stmt postestimation -- Post-estimation tools for stmt

Description

The following standard post-estimation commands are available:

command description

estat post estimation statistics

predict predictions, residuals etc

Syntax for predict

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

Note: in the table below, vn is an abbreviation for varname.

statistic

Main
at(vn # [vn # ...]) predict at values of specified covariates

ci calculate confidence intervals

hazard hazard function

nodes(#) specifies the number of nodes used in Gauss-Legendre quadrature numerical integration
when predicting the cumulative hazard and calculating the survival (default is 30)

per(#) express hazard rates (and differences) per # person years

xb the linear predictor

zeros sets all covariates to zero (baseline prediction)

Timescale-related
time1var(varname) variable which defines timescale 1 for predictions

time2var(varname) variable which defines timescale 2 for predictions

time3var(varname) variable which defines timescale 3 for predictions

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

Statistics are available both in and out of sample; type
predict ... if e(sample) ... if wanted only for the
estimation sample.

Options for predict

Main

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.

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

hazard predicts the hazard function.

nodes(#) specifies the number of nodes to be used when numerically integrating
the estimated hazard function using Gauss-Legendre quadrature. Numerical integration is required
when predicting the cumulative hazard and survival functions. The default number of nodes is 30.

per(#) express hazard rates and difference in hazard rates per # person years.

xb predicts the linear predictor, including the spline function.

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

Timescale-related

time1var(varname) specifies a the variable in the dataset which defines the for values
of timescale 1 that the user wishes to predict over.

time2var(varname) specifies a the variable in the dataset which defines the for values
of timescale 2 that the user wishes to predict over.

time3var(varname) specifies a the variable in the dataset which defines the for values
of timescale 3 that the user wishes to predict over.

Subsidiary

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

Examples

Setup

webuse brcancer

Rename variable for age at diagnosis

rename x1 agediag

Stset with time since diagnosis as timescale 1

stset rectime, f(censrec==1) scale(365.25) exit(time 365.25*5)

Fit model with attained age as timescale 2 and time-dependent effects of hormon on both timescales

stmt hormon, time1(df(5) tvc(hormon) dftvc(2)) time2(df(2) start(agediag) tvc(hormon) dftvc(2) logtoff)

Predict the hazard rate with predictions on timescale 1 (time since diagnosis) from 0 to 3 years where variable hormon is set to 1
when timescale 2 (attained age) is 53. Note that the user must create the timescale variables first before using the predict command.

range time1 0 3 200

gen time2=53

predict h, h time1var(time1) time2var(time2) at(hormon 1)

Predict the hazard ratio over timescale 1 (0-3) at attained age 53, comparing hormon =1 and hormon =0

predictnl hr= exp(ln(predict(h time1var(time1) time2var(time2) at(hormon 1)))- ln(predict(h time1var(time1) time2var(time2) at(hormon 0))))

scatter hr time1, sort name(hr_scatter, replace)

Predict the hazard rate on timescale 2 (attained age) from 50 to 60 years for 2 years post diagnosis where variable hormon is set to 1

cap drop time1 time2

gen time1=2

range time2 50 60 200

predict h2, h time1var(time1) time2var(time2) at(hormon 1)

Predict the hazard with predictions on timescale 1 (time since diagnosis) between
0 and 3 years, in steps of 0.1. Predictions on timescale 2 (attained age) from age 50 until age 53, in steps of 0.25. Predictions are then made of every combination of timescale 1 and 2.
Firstly create timescales using the following:

cap drop time1 time2

preserve

forvalues j=0(0.1)3 {

qui clear

qui set obs 13

qui gen time1 = `j'

qui range time2 50 53 13

qui tempfile temppred`n'

qui save `temppred`n''

local datalist `datalist' `temppred`n''

local n=`n'+1

}

clear

set obs 0

append using `datalist'

tempfile timedata

save `timedata'

restore

merge 1:1 _n using `timedata', nogen

Then use the following predict command:

{ stata "predict h3, h time1var(time1) time2var(time2) at(hormon 1) "}

References

H. Bower, M.J. Crowther, P. C. Lambert. strcs: A command for fitting flexible parametric
survival models on the log-hazard scale. The Stata Journal, 2016;16:989-1012.

P. Royston, P.C. Lambert. Flexible parametric survival analysis in Stata:
Beyond the Cox model StataPress, 2011

Also see

Online: [ST] stmt;

Online: [ST] strcs;