Dear Statalist,
I'm fairly new to Stata and a novice regarding statistics, please apologize if I used dataex or CODE wrong. Let me first introduce the focus of my question. I have some failure-time data, here is a sample of the two variables of interest.
First, I set up my data with stset. Then, I ran the Cox regression.
The vce cluster is because I used a propensity score matching and adjusted the standard errors computing.
Now the point of the question. I would like to test level 1 versus level 0 of MB_vs_SIS_nn_psmatch (dichotomous) at different values of stricture_lenght (continuous; values: 1, 2, 3, 4, and 5). To do so, I was thinking about using margins and contrast commands. I have tried several times without success. I don't have all the attempts, but I will show you the last one (codes suggested by chatGBT):
I am sure I'm missing something in the codes, can someone help me find the right syntax? Also, if possible, with a brief explanation of the operators used for this specific case.
Thank you
I'm fairly new to Stata and a novice regarding statistics, please apologize if I used dataex or CODE wrong. Let me first introduce the focus of my question. I have some failure-time data, here is a sample of the two variables of interest.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input double stricture_lenght float MB_vs_SIS_nn_psmatch 3 0 4 0 2.5 0 1.5 0 3 0 3 0 3 0 3 0 3 0 2 0 4 0 5 0 2 0 6 0 4 0 4 0 3 0 2 0 4 0 4 0 5 0 1.5 0 1.5 0 3.5 0 5 0 4 1 1.5 1 2.5 1 2 1 3 1 3.5 1 3 1 3 1 6 1 3 1 4 1 5 1 5 1 4 1 3 1 3 1 3 1 4 1 3 1 3 1 3 1 2 1 4 1 2.5 1 1.5 1 . . 1 . . . . . . . 1.5 . . . . . . . . . 1 . . . 1 . 1 . 2 . . . 1 . 2.5 . 1.5 . 1 . 1 . 3.5 . 1 . . . 2 . . . 1.5 . 2.5 . 1.5 . .5 . . . . . . . . . 1 . 2 . . . . . . . . . 4 . 1.5 . . . 3 . 1 . 3.5 . 1 . 2 . . . . . end
Code:
stcox c.stricture_lenght i.MB_vs_SIS_nn_psmatch Uretrotomie FLUSSOPOST , vce(cluster clust_var) Failure _d: failure_bef_156m Analysis time _t: FU_kaplan_plus12 Exit on or before: time 156 Iteration 0: log pseudolikelihood = -44.997185 Iteration 1: log pseudolikelihood = -34.312221 Iteration 2: log pseudolikelihood = -32.92996 Iteration 3: log pseudolikelihood = -32.878874 Iteration 4: log pseudolikelihood = -32.878746 Refining estimates: Iteration 0: log pseudolikelihood = -32.878746 Cox regression with Breslow method for ties No. of subjects = 50 Number of obs = 50 No. of failures = 12 Time at risk = 5,345.7488 Wald chi2(4) = 53.12 Log pseudolikelihood = -32.878746 Prob > chi2 = 0.0000 (Std. err. adjusted for 25 clusters in clust_var) ---------------------------------------------------------------------------------------- | Robust _t | Haz. ratio std. err. z P>|z| [95% conf. interval] -----------------------+---------------------------------------------------------------- stricture_lenght | 1.877969 .4056031 2.92 0.004 1.229833 2.86768 1.MB_vs_SIS_nn_psmatch | 4.404797 2.674084 2.44 0.015 1.340215 14.47696 Uretrotomie | 11.01003 13.12806 2.01 0.044 1.06375 113.9561 FLUSSOPOST | .8636839 .0208727 -6.06 0.000 .8237279 .9055779 ----------------------------------------------------------------------------------------
Now the point of the question. I would like to test level 1 versus level 0 of MB_vs_SIS_nn_psmatch (dichotomous) at different values of stricture_lenght (continuous; values: 1, 2, 3, 4, and 5). To do so, I was thinking about using margins and contrast commands. I have tried several times without success. I don't have all the attempts, but I will show you the last one (codes suggested by chatGBT):
Code:
margins MB_vs_SIS_nn_psmatch, at(stricture_lenght=(1(1)5)) predict(hr) post Predictive margins Number of obs = 50 Model VCE: Robust Expression: Predicted hazard ratio, predict(hr) 1._at: stricture_lenght = 1 2._at: stricture_lenght = 2 3._at: stricture_lenght = 3 4._at: stricture_lenght = 4 5._at: stricture_lenght = 5 ------------------------------------------------------------------------------------------ | Delta-method | Margin std. err. z P>|z| [95% conf. interval] -------------------------+---------------------------------------------------------------- _at#MB_vs_SIS_nn_psmatch | 1 0 | .7837271 .8449675 0.93 0.354 -.8723787 2.439833 1 1 | 3.452159 4.061674 0.85 0.395 -4.508576 11.41289 2 0 | 1.471815 1.645008 0.89 0.371 -1.75234 4.695971 2 1 | 6.483048 7.726402 0.84 0.401 -8.660423 21.62652 3 0 | 2.764023 3.304474 0.84 0.403 -3.712626 9.240673 3 1 | 12.17496 15.15627 0.80 0.422 -17.53077 41.8807 4 0 | 5.190751 6.773259 0.77 0.443 -8.084593 18.46609 4 1 | 22.8642 30.43905 0.75 0.453 -36.79524 82.52365 5 0 | 9.74807 14.02292 0.70 0.487 -17.73635 37.23249 5 1 | 42.93827 62.04979 0.69 0.489 -78.67707 164.5536 ------------------------------------------------------------------------------------------ . contrast rb0.MB_vs_SIS_nn_psmatch#r.stricture_lenght variable stricture_lenght not found r(111);
Thank you