*! version 1.2 Chao Wang 09/07/2018
help medsurv

Title

medsurv -- Calculate the median survival time after Cox/Poisson
regression

Syntax

medsurv, id(varname) riskset(varname)

Description

This program calculates the median survival time after a Cox/Poisson model, and
stores the result in a new variable medsurv for each subject (where possible). A
Poisson model must be fitted before running this command (see below for an example).
For the motivation of fitting the Cox model as a Poisson model see
"Cox regression as Poisson regression" in the Stata manual for Survival Analysis,
or Carstensen (2005). Also unlike predict after streg (at the time
of writing, July 2018), the prediction from this program is not made from t = 0 conditional
on constant covariates; therefore it can handle multiple-record-per-subject data
with time-varying covariates, and produce distinct predicted median survival time for each subject.

Options

id(varname) specifies the subject variable. riskset(varname)
specifies the risk sets which can be generated from the stsplit (see below).

Examples

. use http://www.stata-press.com/data/cggm3/hip2, clear

. stset

. stsplit, at(failures) riskset(interval)

. generate time_exposed = _t - _t0

. poisson _d ibn.interval protect age calcium, exposure(time_exposed) noconstant irr

. medsurv, id(id) riskset(interval)

Reference

Carstensen B. Demography and epidemiology: Practical use of the Lexis diagram in the computer age. Annual meeting of Finnish Statistical Society. 2005. Available from: https://biostat.ku.dk/reports/2006/rr-06-2.pdf

Author

Chao Wang, BEng MSc DIC PhD, Senior Lecturer in Health & Social Care Statistic, Faculty of Health, Social Care and Education,
Kingston University and St George's, University of London, excelwang@gmail.com.

Please cite this program if used in your research.