Survival in STATA
description
Transcript of Survival in STATA
-
Survival in STATA If you want to then use command. useful options (things you put after
the comma) Tell STATA you have a censored outcome with observation time obstime and event indicator
status
stset obstime, failure(status)
some exist in STATA, but you wont
need them currently
Graph a Kaplan-Meier Survival curve sts graph by(varname) allows you to graph separate survival curves on same plot
by level of varname gwood adds Greenwood 95% CIs around
the survival curve Graph a smoothed curve of the baseline
hazard function using kernel density estimation (based on the data, not any
model)
sts graph hazard makes a graph of baseline hazard instead of K-M survival curve cihazard adds confidence bands around
hazard function
List Kaplan-Meier survival estimates sts list by(varname) lists K-M survival estimates by levels of varname
Perform a logrank test of equality of survival functions
sts test varname wilcoxon allows you to do a Wilcoxon-Breslow test instead of a logrank test
Fit a Cox Proportional Hazards model stcox predictor list nohr gives estimated beta coefficients instead of hazard ratios
robust provides robust standard error estimates
cluster(id) lets STATA know you have dependent data by id
schoenfeld(varname*) stores Schoenfeld residuals for each observation in a
variable for each predictor in predictor list
scaledsch(varname*) stores scaled Schoenfeld residuals
mgale(varname) stores Martingale residuals for each observation
basesurv(varname) stores estimates of baseline survival in varname
basehc(varname) stores estimates of baseline hazard in varname
-
Test the Proportional Hazards assumption (after fitting a Cox model)
stphtest global test requires having specified schoenfeld() in stcox
individual tests require having specified scaledsch() in stcox
Plot a ln(-ln(S(t)) plot (after fitting a Cox model)
stphplot by(varname) specifies plotting by levels of varname
Plot survival predicted by Cox model with observed survival by Kaplan-Meier
stcoxkm by(varname) specifies plotting by levels of varname
Plot estimates of the hazard (survival) function at mean values of covariates (after
fitting a Cox model)
stcurve hazard is for plotting hazard function (requires basehc() option to have been
specified in stcox) survival is for plotting survival
function (requires basesurv() to have been specified in stcox)
at(varname=#) allows plotting of curve at covariate values specified by
varname=# at1(varname=#) allows you to plot
curve for another set of covariates on same plot as at()
range(startnum endnum) allows you to plot in a range between startnum and
endnum (useful for zooming in on plots to get survival estimates)
Plot Scaled Schoenfeld residuals vs. time and look for flatness of the smooth (flat smooth
implies PH is okay for that covariate, increasing or decreasing smooth implies
problems with PH)
lowess varname _t (here, varname is the stored scaled
Schoenfeld residuals corresponding to covariate you are checking for PH)
bwidth(#) allows bandwidth specification by a number #
(lower bandwidth makes curve try and fit each data point more)
Plot Martingale residuals for continuous covariates and look for shape of smooth (flat smooth implies functional form for covariate is okay, curved smooth implies transforming
covariate in the model)
lowess varname covariate (here, varname is the stored
Martingale residuals, covariate is a continuous covariate)
bwidth(#) allows bandwidth specification by a number #
mean uses running-mean smoothing instead of least-squares smoothing
(might want to do this when plotting Martingale residuals)