Hello
I have fit a Cox model using gender as a categorical variable and bmi as a continuous,with interaction.
stcox c.bmi##i.gender,nohr This is Hosmer,Lemeshow and May Ch.4 exercises Question 1.(g) p.130.
Now I want the hazard ratio for gender at bmi =15,20,25,30,35.
This is simple to do with lincom:
lincom 1.gender+1.gender#bmi*15,hr and so on for each value of bmi.
This is the answer for bmi=15
------------------------------------------------------------------------------
_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | .8284485 .2734861 -0.57 0.569 .4337787 1.582205
------------------------------------------------------------------------------
But I wanted a quick way with margins.If I use
margins gender,at(bmi=(15(5)35)),I get
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_at#gender |
1 0 | .1728764 .0608328 2.84 0.004 .0536464 .2921064
1 1 | .1432192 .0911335 1.57 0.116 -.0353991 .3218375
2 0 | .0963047 .0451844 2.13 0.033 .007745 .1848644
2 1 | .0979411 .0604691 1.62 0.105 -.0205762 .2164584
3 0 | .0536487 .0314637 1.71 0.088 -.008019 .1153165
3 1 | .0669775 .041052 1.63 0.103 -.0134829 .1474379
4 0 | .0298862 .0210331 1.42 0.155 -.0113379 .0711104
4 1 | .0458029 .0285439 1.60 0.109 -.0101422 .101748
5 0 | .0166488 .0136698 1.22 0.223 -.0101435 .0434411
5 1 | .0313225 .0202816 1.54 0.122 -.0084287 .0710737
------------------------------------------------------------------------------
and then if you divide each gender hazard ratio for each value of bmi you get the same as the lincom value(for bmi=1(15),.1432192/.1728764=.
I have fit a Cox model using gender as a categorical variable and bmi as a continuous,with interaction.
stcox c.bmi##i.gender,nohr This is Hosmer,Lemeshow and May Ch.4 exercises Question 1.(g) p.130.
Now I want the hazard ratio for gender at bmi =15,20,25,30,35.
This is simple to do with lincom:
lincom 1.gender+1.gender#bmi*15,hr and so on for each value of bmi.
This is the answer for bmi=15
------------------------------------------------------------------------------
_t | Haz. Ratio Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
(1) | .8284485 .2734861 -0.57 0.569 .4337787 1.582205
------------------------------------------------------------------------------
But I wanted a quick way with margins.If I use
margins gender,at(bmi=(15(5)35)),I get
------------------------------------------------------------------------------
| Delta-method
| Margin Std. Err. z P>|z| [95% Conf. Interval]
-------------+----------------------------------------------------------------
_at#gender |
1 0 | .1728764 .0608328 2.84 0.004 .0536464 .2921064
1 1 | .1432192 .0911335 1.57 0.116 -.0353991 .3218375
2 0 | .0963047 .0451844 2.13 0.033 .007745 .1848644
2 1 | .0979411 .0604691 1.62 0.105 -.0205762 .2164584
3 0 | .0536487 .0314637 1.71 0.088 -.008019 .1153165
3 1 | .0669775 .041052 1.63 0.103 -.0134829 .1474379
4 0 | .0298862 .0210331 1.42 0.155 -.0113379 .0711104
4 1 | .0458029 .0285439 1.60 0.109 -.0101422 .101748
5 0 | .0166488 .0136698 1.22 0.223 -.0101435 .0434411
5 1 | .0313225 .0202816 1.54 0.122 -.0084287 .0710737
------------------------------------------------------------------------------
and then if you divide each gender hazard ratio for each value of bmi you get the same as the lincom value(for bmi=1(15),.1432192/.1728764=.
8284485,same as the lincom value for bmi=15.)
How do I get margins to give me the lincom output all at once,so I don't have to write 5 lincom commands?
Regards
Chris
How do I get margins to give me the lincom output all at once,so I don't have to write 5 lincom commands?
Regards
Chris
Comment