Announcement

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

  • FE regression uneven space

    Hey everyone,

    I have a problem running a FE regression in Stata due to the data structure I have. I have observations for several countries and times, but some years appear multiple times per country. Here is a stylized example:
    Country Year Var
    A 2020 1
    A 2020 2
    A 2021 1
    B 2020 4
    B 2021 7
    If I set "xtset Country Year", it says that multiple time values appear (which I get). My idea was to assign different dates to observations that took place in the same year, e.g. 2020/01/01, 2020/01/02 and so on to have unique dates. This solves the multiple time value problem but I cannot run a FE regression, probably because the distances between the time points are not even.

    Do you have an idea how I can run a FE regression with my data set?

    Best,
    Jules

  • #2
    As long as you are not using time-series operators, such as lags, leads, and differences, you can xtset your data with the panel-identifier only.

    Code:
    xtset Country
    See https://journals.sagepub.com/doi/abs...6867X231162020 for some discussion.

    Comment


    • #3
      Thank you for your quick response. This certainly solves the problem of multiple time values. But I want to use country fixed effects as well as time fixed effects in my regression model. Is this possible with setting just one panel-identifier as you described?

      Comment


      • #4
        Yes. The time variable is only needed if you are using time-series operators, as I stated.

        Code:
        xtset Country
        xtreg y x controls i.Year, fe robust

        Comment


        • #5
          Thank you! When I run the regression now as you suggested, Stata shows me "option FE not allowed r(196)". Without the "fe" specification and with "i.Year" it works:

          Code:
          xtreg y x controls i.Year, robust
          But is this now a regression with time and country fixed effects or just with time FE?

          Comment


          • #6
            Jules:
            you actually coded -xtreg- wity the -re- specification (which is the default specification for -xtreg-).
            Kind regards,
            Carlo
            (Stata 19.0)

            Comment


            • #7
              Carlo Lazzaro: If xtreg is the random effects specification, how do I get FE for country and time? Would this work:
              Code:
              xtreg y x controls i.Year i.Country, robust

              Comment


              • #8
                Jules:
                1) -xtreg <depvar> <predictors> <controls>, re = -xtreg <depvar> <predictors> <controls>, re;
                2) the categorical predictors you typed will give back their contributions to variation in the <depvar> between panel units (and not within each panel, as the -fe- estimator is expected to do);
                3) just out of curiosity: how can it be that Stata tells you that -fe- option is not allowed?
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  1)+2) Thanks for clarification. But how do I run then a within-panel FE regression if the command is not allowed?
                  3) I currently have no idea why Stata does not let me run a FE regression. It also shows the same error if i type , RE instead of FE

                  Comment


                  • #10
                    What happens if you run

                    Code:
                    webuse grunfeld, clear
                    xtreg invest mvalue kstock, fe
                    which xtreg
                    ? Copy and paste the output here.

                    Comment


                    • #11
                      This is the output I get:
                      [ATTACH=CONFIG]n1735085[/ATTACH]
                      Attached Files

                      Comment


                      • #12
                        Jules:
                        you probably need to update your copy of Stata:
                        Code:
                        . webuse grunfeld, clear
                        
                        . 
                        . xtreg invest mvalue kstock, fe
                        
                        Fixed-effects (within) regression               Number of obs     =        200
                        Group variable: company                         Number of groups  =         10
                        
                        R-squared:                                      Obs per group:
                             Within  = 0.7668                                         min =         20
                             Between = 0.8194                                         avg =       20.0
                             Overall = 0.8060                                         max =         20
                        
                                                                        F(2,188)          =     309.01
                        corr(u_i, Xb) = -0.1517                         Prob > F          =     0.0000
                        
                        ------------------------------------------------------------------------------
                              invest | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
                        -------------+----------------------------------------------------------------
                              mvalue |   .1101238   .0118567     9.29   0.000     .0867345    .1335131
                              kstock |   .3100653   .0173545    17.87   0.000     .2758308    .3442999
                               _cons |  -58.74393   12.45369    -4.72   0.000    -83.31086     -34.177
                        -------------+----------------------------------------------------------------
                             sigma_u |  85.732501
                             sigma_e |  52.767964
                                 rho |  .72525012   (fraction of variance due to u_i)
                        ------------------------------------------------------------------------------
                        F test that all u_i=0: F(9, 188) = 49.18                     Prob > F = 0.0000
                        
                        . 
                        . which xtreg
                        C:\Program Files\Stata17\ado\base\x\xtreg.ado
                        *! version 1.9.1  10feb2021
                        
                        .
                        Kind regards,
                        Carlo
                        (Stata 19.0)

                        Comment

                        Working...
                        X