Announcement

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

  • fixed effects by gvkey

    I'm using stata 13 in a windows 10 environment

    I'm trying to run a linear regression with firm and year fixed effects. For the firm FE, I'm using the gvkey as i.gvkey.

    The thing is, I keep getting an error of too many variables. I changed matsize to 11000 (most allowed) and this error keeps showing up.

    Anyone have some insights about what I'm doing wrong and how should I do it?

  • #2
    how many distinct values of gvkey are there (use codebook or download distinct from ssc to find out)? if there are a lot of distinct values, you need to ask why you want a dummy for each; you might be able to solve the issue with "areg" but I think that thinking about the role of gvkey is more important than obtaining possibly useless estimates

    Comment


    • #3
      I have 10045 unique gvkeys. I know it's a lot. I agree with stata.
      Is that a different way to use firm FE?

      Comment


      • #4
        Yes. Are you familiar with the -xt- commands? There's a whole manual full of them, and if you do this kind of work regularly, you will definitely benefit from knowing them.

        Anyway, try:

        Code:
        xtset gvkey
        xtreg outcome predictors i.year, fe
        In particular, you don't explicitly mention gvkey in the -xtreg- command: the use of the -fe- option tells Stata to look at the -xtset- results to figure out that you want to absorb gvkey effects in the model and handles it. The best part is that you don't even need a matrix large enough to accommodate them all when you do it this way because the estimation is done on de-meaned observations rather than by incorporating a zillion indicators.

        You're actually lucky that you can't set a matrix size large enough for the way you were doing it. If it had worked, your output would have included 10,044 lines with the gvkey-indicator coefficients which are, for most purposes, useless. (If you do want those gvkey-level effect estimates, by the way, you can get them with -predict- See -help xtreg postestimation- for details.)

        Comment


        • #5
          Thanks Clyde. I thought of that, but I wasn't sure that was a right way to go.

          Comment

          Working...
          X