Announcement

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

  • Post-estimation commands to calculate the contribution of each regressor

    Hi Statalists,

    I am trying to estimate the contribution of each regressor after a regression of the form:
    Code:
    reg Y x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 if ID=="1"
    basically I would like to have
    contrib_x_1_ID1 = beta_1*x_1
    contrib_x_2_ID1 =beta_2*x_2
    ...
    contrib_x_10_ID1 =beta_10*x_10

    This is something I can do easily. The problem is that I have a panel of countries, however the regression is estimated at a country-level (ID) for each ID. This complicates a bit the calculation of the contribution of each regressor after each regression withour a proper command.

    So, the question is: is there a post-estimation command that does it automatically after each regression?

    Thanks
    Ale

  • #2
    The way I solve the issue "manually":
    Code:
    local i=1
    foreach var in x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 {
        gen coeff_`var'_1 = e(b)[1,`i'] if ID1=="1"
        gen contr_`var'_1 = `var'*coeff_`var'_1 if ID1=="1"
        local ++i  /* this increase the counter at each iteration */
    }

    Comment

    Working...
    X