Announcement

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

  • Matrix row names as legends from coefficients

    I'm trying to retrieve a set of fixed effects in the most efficient way.

    Suppose I have panel data with "id" as the identifier. Regressing:

    Code:
    reg i.pid
    mat def B = e(b)
    will make a matrix that will be the set of X id-specific coefficients.

    I'd like to make the row names of matrix "B" the corresponding "id" value. That way, I can create a new .dta with "id" and "fixed_effects" variables and simply merge that to the database.

    This would be easier if every id was included in the regression; however, some are dropped out (e.g. the base has 500 unique values for id and e(b) is a 432x1 vector).

    Since Stata report legends from coefficients, I'm wondering if it's possible to connect those with the row names in a simple way.

  • #2
    It is seldom helpful in Stata to put numbers into a matrix unless you are going to do matrix algebra with them. It sounds like your real goal is to incorporate the estimates of the fixed effects into your data set. You can do that by running your regression as -xtreg, fe- and then running -predict new_fixed_effect_variable, u-.

    Comment

    Working...
    X