Announcement

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

  • How to save coefficient of fixed effects?

    Dear Stata Users,

    I have an unbalanced panel data. What I need is to save the coefficient of i.gvkey (for each observation - firm(gvkey)-year) from the following regression:

    Code:
     
     xtset gvkey1 fyear reg bm_w cum_ret_w b1cum_ret_w b2cum_ret_w b3cum_ret_w b4cum_ret_w b5cum_ret_w b6cum_ret_w i.fyear, r
    Can you please specify the way I can proceed with? I found in the previous postings of the forum the following method:
    Code:
    xtset gvkey1
    reg bm_w cum_ret_w b1cum_ret_w b2cum_ret_w b3cum_ret_w b4cum_ret_w b5cum_ret_w b6cum_ret_w i.fyear, r 
    predict gvkey1_effect
    However, I am conserned if stata treats the data as a panel while estimating the coefficient.

    Best regards,
    Alberto

  • #2
    Alberto:
    you did not receive any reply because your codes are inconsistent.
    I fail to get why you -xtset- your data first and then go -regress-.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Sorry, it just should be like this:

      Code:
      xtset gvkey1 fyear
      
      reg bm_w cum_ret_w b1cum_ret_w b2cum_ret_w b3cum_ret_w b4cum_ret_w b5cum_ret_w b6cum_ret_w i.fyear, r
      Fist, I define Panel data structure, and then run pooled ols. (Hope, I understood your question correctly)

      Comment


      • #4
        Alberto:
        I still fail to get why you -xtset- your data first and then go -regress-.
        -regress- does not need -xtset- to work properly, as you can see from the following toy-example:
        Code:
        . use "http://www.stata-press.com/data/r14/nlswork.dta", clear
        (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
        
        
        . xtset idcode year
               panel variable:  idcode (unbalanced)
                time variable:  year, 68 to 88, but with gaps
                        delta:  1 unit
        
        . reg ln_wage tenure
        
              Source |       SS           df       MS      Number of obs   =    28,101
        -------------+----------------------------------   F(1, 28099)     =   4473.23
               Model |  880.984271         1  880.984271   Prob > F        =    0.0000
            Residual |  5533.98035    28,099  .196945811   R-squared       =    0.1373
        -------------+----------------------------------   Adj R-squared   =    0.1373
               Total |  6414.96462    28,100  .228290556   Root MSE        =    .44379
        
        ------------------------------------------------------------------------------
             ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              tenure |   .0471994   .0007057    66.88   0.000     .0458162    .0485826
               _cons |   1.529661   .0034451   444.02   0.000     1.522909    1.536414
        ------------------------------------------------------------------------------
        
        . xtset, clear
        
        . reg ln_wage tenure
        
              Source |       SS           df       MS      Number of obs   =    28,101
        -------------+----------------------------------   F(1, 28099)     =   4473.23
               Model |  880.984271         1  880.984271   Prob > F        =    0.0000
            Residual |  5533.98035    28,099  .196945811   R-squared       =    0.1373
        -------------+----------------------------------   Adj R-squared   =    0.1373
               Total |  6414.96462    28,100  .228290556   Root MSE        =    .44379
        
        ------------------------------------------------------------------------------
             ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              tenure |   .0471994   .0007057    66.88   0.000     .0458162    .0485826
               _cons |   1.529661   .0034451   444.02   0.000     1.522909    1.536414
        ------------------------------------------------------------------------------
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          Thank you for the response, I see.. I just tried to make "Stata" understand that I use panel data.. But skipping "xtset" can you please help me with my question regarding saving the coefficient of "gvkey1" which is a firmID identifier?

          Comment


          • #6
            Alberto:
            see Example #2 under -matrix mkmat- entry, Stata .pdf manual.
            As an aside, should you have any sound methodological reason to run an OLS instead of an -xt- prefixed command with panel data, I would recommend you to cluster your standard errors on -panelid-. Otherwise, -regress-, ignoring that you're dealing with repeated measures on the same sample, will consider observations as independent (which is not the case with panel data).

            Kind regards,
            Carlo
            (Stata 19.0)

            Comment

            Working...
            X