Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Risk tables for Cumulative Incidence Functions?
From
Phil Clayton <[email protected]>
To
[email protected]
Subject
Re: st: Risk tables for Cumulative Incidence Functions?
Date
Tue, 2 Aug 2011 09:09:12 +1000
Hi Richard,
As far as I know you can't easily add at-risk tables to graphs other than those drawn with -sts graph- (at least in version 11.2). But as a work-around you can draw an invisible K-M plot and add the cumulative incidence function(s) as an added plot.
This example, which draws the baseline CIF for two groups, is from the manual for -stcrreg postestimation-
use http://www.stata-press.com/data/r11/hiv_si, clear
stset time, failure(status == 2)
stcrreg if !ccr5, compete(status == 1) noshow
predict cif_si_0, basecif
label var cif_si_0 "ccr5 = 0"
stcrreg if ccr5, compete(status == 1) noshow
predict cif_si_1, basecif
label var cif_si_1 "ccr5 = 1"
twoway line cif_si* _t if _t<13, connect(J J) sort ///
yscale(range(0 0.5)) title(SI) ytitle(Cumulative Incidence) ///
xtitle(analysis time)
You can adapt the above line plot and put it inside an invisible K-M plot as follows:
sts graph, by(ccr5) risktable plotopts(lstyle(none)) /// hides the K-M plot
addplot(line cif_si* _t if _t<13, sort c(J J) lstyle(p1 p2) /// lstyle to get first 2 colours/styles
legend(order(3 "ccr5 = 0" 4 "ccr5 = 1"))) /// first 2 lines are hidden
title(SI)
This tends to squash the CIF plot a little, because the K-M plot y axis is forced to range from 0 to 1. You can use the -fail- option for -sts graph- but it will still squash it a bit because the K-M failure estimator overestimates the cumulative incidence in the presence of the competing risk. So I usually multiply the CIF by 100 and plot it as a %:
replace cif_si_0=100*cif_si_0
replace cif_si_1=100*cif_si_1
sts graph, by(ccr5) risktable plotopts(lstyle(none)) ///
addplot(line cif_si* _t if _t<13, sort c(J J) lstyle(p1 p2) ///
legend(order(3 "ccr5 = 0" 4 "ccr5 = 1"))) ///
ylab(0(10)40, format(%1.0f)) /// override default K-M plot format of 1 decimal place
yline(0(10)40, lstyle(grid)) ytitle("Cumulative incidence (%)") title(SI)
Of course you can adapt the above to draw at-risk tables with any plot, for example adjusted predictions after a regression.
There is also a program from 2004 called -stsatrisk- by Jean Marie Linhart and Jeff Pitblado which acts as a wrapper to -sts graph- - my guess is that this was a precursor to the current functionality of the -risktable- option. It may be possible to adapt it for your situation.
Hope this helps,
Phil
On 02/08/2011, at 4:59 AM, Richard Sylvester wrote:
> Hi,
>
> Using sts graph, it is possible to show the number at risk at various time points for the Kaplan-Meier survivor function via risktable. However is it possible to show the number at risk when plotting the cumulative incidence function? stscurve doesn't seem to have this possibility.
>
> Thanks,
>
> Richard Sylvester
>
>
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/statalist/faq
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/