Announcement

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

  • Lincom vs. Margins to combine coeffecients

    Hello - new to StataList service. I am trying to get trends in surgical mortality estimates at a hospital referral region to use as an an outcome predictor for another model. This is a patient level model, I am also risk adjusting with demographic and comorbidity data.

    local elix "htn_c chf valve pulmcirc perivasc para neuro chrnlung dm dmcx hypothy renlfail liver ulcer aids lymph mets tumor arth coag obese wghtloss lytes bldloss anemdef psych depress"
    regress death30 year i.hrrnum i.hrrnum#c.year i.race1 i.sex1 i.elective i.`elix', vce(cluster hrrnum)
    lincom year + 345.hrrnum#c.year

    I want to sum the year + i.hhrnum#c.year coeffecients to get the risk-adjusted sloped for each hrr leve (306 levels).
    It seems that I would have to write a loop that would calculate lincom for each hrr level and store the estimates? Is there an easier way to do this?


  • #2
    If I follow what you want to do, you can do this with the -margins- command.

    First, there is a slight error in your -regress- command. When you write i.`elix', the result is to put i. in front of htn_c,, but none of the other numerous variables in `elix'. So in the regress command, you have to write that part is i.(`elix'). Stata will then known to "distribute" the i. across all of the variables in `elix'.

    Once you fix that up and re-run your regression, the results you are looking for come from a single line of code:

    Code:
    margins hrrnum, dydx(year)

    Comment


    • #3
      Thanks so much Clyde this was very helpful. I was able to run the model with margins hrrnum, dydx(year). However for several HRRs I got "not estimable". I thought it was because there were too few events in those HRRs but for example if I look at proportion of death by year in HRR 7 (below) every year has an event. Do you think there is a better way to do this? Or have any idea why its not estimable.

      Click image for larger version

Name:	Screen Shot 2017-04-29 at 8.58.32 AM.png
Views:	2
Size:	85.6 KB
ID:	1386069

      Click image for larger version

Name:	Screen Shot 2017-04-29 at 9.11.00 AM.png
Views:	1
Size:	77.2 KB
ID:	1386067
      Attached Files

      Comment


      • #4
        It's not just a matter of how many observations or events there are for each category of hrrnum in the data set. It's a question of how many there are in the estimation sample of the regression.

        I don't see what the relevance of that table in the middle of your post is. And I can't tell what the three rows within each super-row are. (It is never a good idea to post Stata output without also showing the code that created it.) It seems to cross-tabulate death30 with year, but it has nothing to do with hrrnum, which is your issue. What is more relevant to look at is -tab hrrnum year if e(sample)- to see what's going on after every observation with missing values on any of the other variables has been removed.

        Comment

        Working...
        X