Hi all, I am trying to detect association between a covariate and a disease outcome using R. This covariate shows time-varying effect, I add a time-covariate interaction item to build Cox model as follows: COX <- coxph(as.formula("Surv(TIME,outcome)~eGFR_BASE+eGFR_BASE:TIME"),ori.data); coef exp(coef) e(coef) z p eGFR_BASE 6.40 603.5133 0.3702 17.3 0 eGFR_BASE:TIME -3.41 0.0329 0.0772 -44.2 0 But the result seems very different from that got by SPSS: B SE Wald df Sig. Exp(B) eGFR_BASE -13.603 .548 616.007 1 .000 .000 T_COV_*eGFR_BASE .860 .115 55.859 1 .000 2.362 so my questions are : 1, Is it correct to deal with time dependent covariate in Cox regression using R? if not, how to do it ? 2, How T_COV_ was calculated in SPSS, and is it the same with the survival time? Many thanks. GZ [[alternative HTML version deleted]]
David Winsemius
2011-Dec-26 12:49 UTC
[R] Problem of COX model with time dependent covariate
On Dec 26, 2011, at 3:02 AM, JiangGZ wrote:> > Hi all, > > > I am trying to detect association between a covariate and a disease > outcome using R. This covariate shows time-varying effect, I add a > time-covariate interaction item to build Cox model as follows: > COX <- coxph(as.formula("Surv(TIME,outcome)~eGFR_BASE > +eGFR_BASE:TIME"),ori.data); > > > coef exp(coef) e(coef) z p > eGFR_BASE 6.40 603.5133 0.3702 17.3 0 > eGFR_BASE:TIME -3.41 0.0329 0.0772 -44.2 0 > > > But the result seems very different from that got by SPSS: > > > B SE Wald df Sig. Exp(B) > eGFR_BASE -13.603 .548 616.007 1 .000 .000 > T_COV_*eGFR_BASE .860 .115 55.859 1 .000 2.362 > > > > so my questions are : > 1, Is it correct to deal with time dependent covariate in Cox > regression using R? if not, how to do it ?The usual way to represent time dependent covariates is to set up records with start and stop time and use the Surv(time, time2, event) usage. This is clearly described in the help page and there is vignette describing time-dependent covariate methods in the package documentation.> 2, How T_COV_ was calculated in SPSS, and is it the same with the > survival time?How could we possibly know how _you_ calculated T_COV? (And this is very definitely the wrong mailing list for that question.) The description in the IBM/SPSS documentation says using the time variable on the RHS is used for testing non-proportionality of hazards rather than for investigating the association of a covariate with an outcome: http://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=3&ved=0CDcQFjAC&url=http%3A%2F%2Fwww.unileon.es%2Fficheros%2Fservicios%2Finformatica%2Fspss%2Fenglish%2FIBM-SPSS_advanced_statistics.pdf&ei=P2j4TtbDMITi0QG6k-2DAg&usg=AFQjCNH_4hFxKUdl-Ie1VDxEFXRL35nIqw The SPSS documentation appears designed to lead the naive user into an incorrect model formulation, since the only example of use with its dialog box shows the user setting up the test for non-proportionality. Given that you proposed using a time variable on the RHS in an R formula, I am guessing you also do not know how to properly use SPSS for the purposes you intend. -- David.> > > Many thanks. > GZ > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code.David Winsemius, MD West Hartford, CT
Terry Therneau
2011-Dec-28 15:50 UTC
[R] Problem of COX model with time dependent covariate
I'll add just a little to what David said. The normal meaning of a "time dependent covariate" is a covariate that changes with time. For instance in a model that included x="most recent available blood pressure" the value of x will change at each patient visit. You obviously can't get those new values as x=baseline + c*time unless you are willing to assume a very odd biology for the patient. I would think the same about glomular filtration rate (GFR). A different question is a time dependent coefficient. That is, the variable stays the same but it's effect changes over time. Now in this case a model that beta(t) = a + bt has some possible merit, but in my optinion the biology it implies is still quite odd. So I don't find that model very interesting, even though some packages impliment it. In R there is a more useful approach: fit <- coxph(Surv(time, outcome) ~ eGFR.base, ori.data) zfit <- cox.zph(fit) plot(zfit) This produces a smoothing spline estimate of beta(t) with confidence bands. You can look at the plot and begin to understand the data, not just create p-values. Terry T. On Dec 26, 2011, at 3:02 AM, JiangGZ wrote:> > Hi all, > > > I am trying to detect association between a covariate and a disease > outcome using R. This covariate shows time-varying effect, I add a > time-covariate interaction item to build Cox model as follows: > COX <- coxph(as.formula("Surv(TIME,outcome)~eGFR_BASE > +eGFR_BASE:TIME"),ori.data); > > > coef exp(coef) e(coef) z p > eGFR_BASE 6.40 603.5133 0.3702 17.3 0 > eGFR_BASE:TIME -3.41 0.0329 0.0772 -44.2 0 > > > But the result seems very different from that got by SPSS: