Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to save estimates from stcox

    Hi everyone,

    This is probably super easy, but I've searched the web and this forum for a solution and I just can't seem to find it. I'm looking how to save estimates from stcox in order to use them in a forest plot later on. I'm interested in the HR and in the lower and upper CI.

    My code is: stcox i.variable, vce(robust) nolog

    My variable can take the values 1, 2 and 3.

    I'm using Stata v16.1 (on Mac).

    Hope someone has a solution to this. Many thanks!

    Gunnar

  • #2
    Like all Stata estimation commands, -stcox- leaves behind a temporary matrix, r(table), which contains the coefficients, standard errors, test statistic, p-value, and confidence intervals. You can keep it in permanent matrix by just running:
    Code:
    matrix my_stcox_results = r(table)
    immediately after -stcox- itself runs. You can then use that matrix when you need it later in the same program.

    If you need to save things for running in a completely different session, you can always save the results of any Stata estimation command to a file with the -estimates save- command. This creates a .ster file that contains a great deal of output including the coefficients and standard errors (but not the confidence intervals). You can either recalculate the confidence intervals yourself, or you can re-create the r(table) output by:
    Code:
    estimates use my_saved_estimates.ster
    estimates replay

    Comment


    • #3
      Thanks a lot, Clyde! That's exactly what I was looking for. Very helpful!

      Comment

      Working...
      X