I am attempting to create an automated table using collect of the univariable and adjusted results of some Cox models. In the adjusted analysis, I am adjusting for age, sex and HIV viral load status at drug start. However with the code I am using the estimates for the variables I am adjusting for are being overwritten/cancelled out. Please can you suggest a way to avoid this?
This is the code I am using:
collect _r_b _r_ci _r_p, ///
tag(model[(2)] colname[1.age]) ///
: stcox age i.vl_group sex
collect _r_b _r_ci, ///
tag(model[(2)]) ///
: stcox i.age_gp i.vl_group sex
collect get _r_p=(r(p)), tag(model[(2)] colname[1.age_gp]): testparm i.age_gp
collect _r_b _r_ci _r_p, ///
tag(model[(2)] colname[1.sex]) ///
: stcox sex i.vl_group age
collect _r_b _r_ci, ///
tag(model[(2)]) ///
: stcox i.vl_group age sex
collect get _r_p=(r(p)), tag(model[(2)] colname[1.vl_group]): testparm i.vl_group
collect _r_b _r_ci _r_p, ///
tag(model[(2)]) ///
: stcox prevfail i.vl_group age sex
and this is the output:
Apologies that I haven't provided a dataset to test with.
Thanks!
This is the code I am using:
collect _r_b _r_ci _r_p, ///
tag(model[(2)] colname[1.age]) ///
: stcox age i.vl_group sex
collect _r_b _r_ci, ///
tag(model[(2)]) ///
: stcox i.age_gp i.vl_group sex
collect get _r_p=(r(p)), tag(model[(2)] colname[1.age_gp]): testparm i.age_gp
collect _r_b _r_ci _r_p, ///
tag(model[(2)] colname[1.sex]) ///
: stcox sex i.vl_group age
collect _r_b _r_ci, ///
tag(model[(2)]) ///
: stcox i.vl_group age sex
collect get _r_p=(r(p)), tag(model[(2)] colname[1.vl_group]): testparm i.vl_group
collect _r_b _r_ci _r_p, ///
tag(model[(2)]) ///
: stcox prevfail i.vl_group age sex
and this is the output:
Adjusted for age, sex & VL status at drug start | |||
Hazard ratio | 95% CI | p-value | |
Age (years) | |||
0 to <6 | 1.00 | 0.497 | |
6 to <12 | 1.93 | (0.25,14.92) | |
12 to <18 | 2.51 | (0.34,18.29) | |
Sex | |||
Naive | <0.001 | ||
ART experienced, VL≥200c/mL | |||
ART experienced, VL<200c/mL | |||
ART experienced, VL unknown | |||
Previous treatment failure | 2.64 | (1.47, 4.72) | 0.001 |
Thanks!
Comment