Is there a way to get the mean with margins and streg? For some reason, it only gives median

StackOverflow https://stackoverflow.com/questions/23500694

سؤال

I'm trying to use the margins command after I fit a parametric survival function.

Eg:

use http://www.ats.ucla.edu/stat/examples/asa2/whas100, clear
stset foltime, id(id) failure(folstatus)
streg i.gender, d(weibull) nohr
margins gender

Produces the following output:

Adjusted predictions                              Number of obs   =        100
Model VCE    : OIM

Expression   : Predicted median _t, predict()

------------------------------------------------------------------------------
             |            Delta-method
             |     Margin   Std. Err.      z    P>|z|     [95% Conf. Interval]
-------------+----------------------------------------------------------------
      gender |
          0  |   2885.113   758.6385     3.80   0.000     1398.209    4372.017
          1  |   1308.823   371.5881     3.52   0.000     580.5232    2037.122
------------------------------------------------------------------------------

As you can see, it gives the median time. If you do any straight up regression, it always gives the mean.

Anyone else ran into this problem?

هل كانت مفيدة؟

المحلول

margins gender, predict(mean time) I did not check that, as I don't have Stata on this computer.

However, the logic behind margins is that if you do not specify the predict() option, margins will assume the default prediction for your model. In case of streg you can look up in help streg_postestimation that the default is the median (which makes perfect sense for this type of model). However, you can predict the mean time, and the option is called mean time.

نصائح أخرى

But unlike a straight-up regression, you're doing survival analysis. It can't estimate the effect for a point that doesn't exist in your data.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top