Hello everyone,
I have been working on data from cohort:
Baseline at 1995, follow-up 2005 and end of study 2017.
During follow-up a lot of participants changed their status of covariates e.g. at 1995 baseline have no diabetes, at 2005 have diabetes (variable = Diabetes)
I have used stsplit to split data at 2005 for those participants that changed their status generating new observations with same ID. I have now new variable that have different status before 2005 and after 2005 in those participants that have duplicate observations (variable = Diabetes_Split). My question is, do I use this variable in .stcox as part of TVC or not? e.g.
OR
My full code:
Also, I am not sure if I need to stset data again to indicate different follow-up time time for each duplicate observation:
It is interesting how these two stset gives completely different results and risk time:
Somehow putting t1 ignores duplicate ID risk time, hence those who changed their status after 2005 are ignored. Then makes me wonder if the first stset command does it right. Ok so I figured using browser that using t1 would give incorrect results, because somehow t0 becomes 0 (and not actual diagnosis age) and that doesnt work with splitted multiple observations. It is interesting how stata manual advises to make t1 after splitting.
On the other note, if variable (e.g. Sex) does not meet proportional hazard assumption, do I do this:
OR
I hope my question is clear! Thank you in advance.
I have been working on data from cohort:
Baseline at 1995, follow-up 2005 and end of study 2017.
During follow-up a lot of participants changed their status of covariates e.g. at 1995 baseline have no diabetes, at 2005 have diabetes (variable = Diabetes)
I have used stsplit to split data at 2005 for those participants that changed their status generating new observations with same ID. I have now new variable that have different status before 2005 and after 2005 in those participants that have duplicate observations (variable = Diabetes_Split). My question is, do I use this variable in .stcox as part of TVC or not? e.g.
Code:
. stcox i.Exposure Sex Diabetes_Split, tvc(Diabetes_Split)
Code:
. stcox i.ExposureSex Diabetes_Split
Code:
generate DiabeteAge = PartAg_2005 if DiaEv_1995 == 0 & DiaEv_2005 == 1 stset ageexit, failure(AMI==1) id(ID) enter(agediag) stsplit Diabetes_Split, after(DiabeteAge) at(1) recode Diabetes_Split -1=1 replace Diabetes_Split=DiaEv_1995 if Diabetessplitage==.
Code:
generate t1 =_t - _t0 . stset t1, failure(AMI==1) id(ID)
Code:
. stset _t, failure(AMI==1) id(ID) enter(_t0) . stset t1, failure(AMI==1) id(ID)
On the other note, if variable (e.g. Sex) does not meet proportional hazard assumption, do I do this:
Code:
. stcox i.Exposure Sex, tvc(Sex)
Code:
. stcox i.Exposure, tvc(Sex)