Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: KM curve adjusted by the Inverse Probability of Treatment Weights(IPTW)

From   Adam Olszewski <>
Subject   Re: st: KM curve adjusted by the Inverse Probability of Treatment Weights(IPTW)
Date   Thu, 20 Dec 2012 12:31:35 -0500

Hi Marcos,
In Stata, you just need to stset your dataset indicating appropriate weights:
stset time [pw=iptw], fail(remission)

Then you can graph anything you want, and the weight adjustment is
done automatically:
sts graph, by(tx)

I'm not going into the intricacies of what such graphs might or might
not represent, since I trust you understand them. Curve comparison can
be only done with a Cox regression (or another regression model if you
prefer, such as Royston-Parmar). You will not be able to use the efron
or exact tie adjustment.

sts test tx
which should be the same as
stcox test

I am not a statistician and do not understand very well why/if
non-parametric tests can or cannot be done with pweighted data, but
simple logrank certainly cannot be done and Stata will refuse to
perform it (it will default to Cox). On the other hand, the
-stpepemori- (available through SSC) command from Enzo Coviello works
in a pweighted dataset and I had at least one expert declare that it
should be valid to use. If any of our statisticians on the list can
(p)weigh in on the subject I would be delighted to hear!

Great reference:
Cole, S. R. and M. A. Hernan (2004). "Adjusted survival curves with
inverse probability weights." Comput Methods Programs Biomed 75(1):
And of course the famous:
Hernan, M. A., et al. (2000). "Marginal structural models to estimate
the causal effect of zidovudine on the survival of HIV-positive men."
Epidemiology 11(5): 561-570.

Adam Olszewski

On Thu, Dec 20, 2012 at 11:55 AM, Marcos Vinicius
<> wrote:
> Hello,
> I would like to generate a Kaplan Meier curve adjusted(controlled/corrected) by the Inverse Probability of Treatment Weights(IPTW).
> Supose I have a dataset with columns: tx=treatment (0/1)  , ps=propensity score weig=  Inverse Probability of Treatment Weights (iptw),time (=survival time)remission(1/0) (0=censored),
> In IPTW, individuals are weighted by the inverse probability of receiving the treatment that they actually received.
> In SAS I tried this code but it is not working although it is indicated in the SAS/STAT
> 12.1 User’s Guide The LIFETEST Procedure (Chapter)
> Someone could help me with a Stata code to produte and compare 2 Km curves according to treatment group but adjusted by iptw(weig)
> proc lifetest method=km data=ps plots = (survival );
> time time*remission(0);
>  weight weig;
> survival out=surv_data conftype=loglog ;
> /*weight weig;*/
> ODS EXCLUDE ProductLimitEstimates Means LogrankHomCov WILHOMCOV HomStats TaroneHomCov PetoHomCov Rank HomTests  ;
> /*weight weig;*/
> strata tx;
> /*weight weig;*/
>  run;
> [
> Error message from SAS log
> ERROR 180-322: Statement is not valid or it is used out of
>                proper order.
> After program the  propensity score weight , also referred to as the inverse probability oftreatment weight (IPTW)( weig in the  SAS code) I tried to use the weight statatement from proc Lifetest to produce a Kaplan-Meier curve adjusted by iptw. It is not working.
> Someone could help me in the code implementation  or guide another way to produce the KM curve adjusted by propensity score?:
> Many thanks,
> Vinicius.
> ____________________________________________________________
> Works with AIM®, MSN® Messenger, Yahoo!® Messenger, ICQ®, Google Talk™ and most webmails
> *
> *   For searches and help try:
> *
> *
> *

*   For searches and help try:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index