Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# st: RE: time varying covariate Cox regression

 From Tim Evans To "'statalist@hsphsun2.harvard.edu'" Subject st: RE: time varying covariate Cox regression Date Thu, 9 Feb 2012 17:12:20 +0000

```Thanks for the response Jan. I'm confused though because recoding using your example below seems to me to put worst and best prognosis values together i.e.

recode TCATOG2_1 (1=0) (2=1) (3=0)

What I need is to say that 1 is the base, and compare 2, and then separately 3 against the base. I can only see that I am combining two groups (in your example mid and worst prognosis and good and worst prognosis) together as the base.

Perhaps I am missing something?

Best wishes

Tim

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Reinhardt Jan Dietrich
Sent: 08 February 2012 17:34
To: statalist@hsphsun2.harvard.edu
Subject: st: AW: time varying covariate Cox regression

The easiest is to recode your time varying covariate into two dummies: level1 and level2 (level 3 is the reference then)

E.g.

Gen TCATOG2_1 = TCATOG2
RECODE TCATOG2_1 (1=1) (2=0) (3=0)
Gen TCATOG2_2 = TCATOG2
RECODE TCATOG2_1 (1=0) (2=1) (3=0)

Then use both dummies instead of i.TCATOG2 ...

Jan

________________________________________
Von: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu]&quot; im Auftrag von &quot;Tim Evans [Tim.Evans@wmciu.nhs.uk]
Gesendet: Mittwoch, 8. Februar 2012 18:24
An: 'statalist@hsphsun2.harvard.edu'
Betreff: st: time varying covariate Cox regression

I have a time varying covariate that I am using in a Cox regression which relates to stage at diagnosis for a particular cancer type. The accepted view is that later stage tumours will have higher hazard ratios. However I have a variable with three levels that purports to suggest that later stage tumours will actually reduce the hazard ratio. I think this is being confounded by a larger number of earlier stage tumours.

What I would like to know is how do I treat a categorical variable that varies with time since I don't appear to be able to use the i. prefix when using tvc.

My code is thus:

foreach var of varlist DELAY_* TDELAY_1 {
stcox `var' age i.ttype i.grade SEX2, tvc(TCATOG2 sizegrp)
}

Output:

------------------------------------------------------------------------------
_t | Haz. Ratio   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
main         |
DELAY_1_NEW |   1.157908   .0788916     2.15   0.031     1.013162    1.323332
age |   1.053658   .0038644    14.25   0.000     1.046111     1.06126
|
ttype |
2  |   2.079459   .2228057     6.83   0.000     1.685573    2.565389
3  |   1.635624   .1590821     5.06   0.000     1.351745    1.979119
|
2  |    1.23092    .104672     2.44   0.015     1.041952    1.454161
3  |   2.162566   .2359455     7.07   0.000     1.746222    2.678176
|
SEX2 |   1.171438   .0926916     2.00   0.046     1.003152    1.367955
-------------+----------------------------------------------------------------
tvc          |
TCATOG2 |    .956024   .0074053    -5.81   0.000     .9416196    .9706488
sizegrp |   1.001568   .0038096     0.41   0.680     .9941292    1.009063
------------------------------------------------------------------------------

```