Announcement

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

  • Seemingly unrelated regression with panel data fixed effects

    I have a panel data set with id=52 and time variable year, 2000 to 2018 (988 observations). I would like to model log of number of marriages (y1), log of number of divorces (y2) and log of number of births (y3) at id level (where id are provinces). I ran a Hausman test and estimated a fe model accordingly. Same x covariates (gdp, pop, education, unemployment... ) in each model specification.

    xtset id year
    xtreg y1 x i.year, fe vce(robust)
    xtreg y2 x i.year, fe vce(robust)
    xtreg y3 x i.year, fe vce(robust)

    Since I think it makes sense to suppose that the underlying processes for the three dependent variables might be similar, I would like to perform a seemingly unrelated regression.

    First, I considered sureg - but not sure if it works with panel data. So, I had a look at xtsur (http://fmwww.bc.edu/RePEc/bocode/x/xtsur.html) - but it uses re estimators. I tried to run xtsur adding i.id to the list of regressor (does it make sense?), but Stata 15 failed in calculating...

    So, I got back to sureg and tried this:

    xtset id year
    sureg (y1 x i.year i.id) (y2 x i.year i.id) (y3 x i.year i.id), corr

    Is this a correct approach for estimating SUR with fixed effects panel data? Any alternative?

    Thanks!

  • #2
    Originally posted by Levi Perez View Post
    I have a panel data set with id=52 and time variable year, 2000 to 2018 (988 observations). I would like to model log of number of marriages (y1), log of number of divorces (y2) and log of number of births (y3) at id level (where id are provinces). I ran a Hausman test and estimated a fe model accordingly. Same x covariates (gdp, pop, education, unemployment... ) in each model specification.

    xtset id year
    xtreg y1 x i.year, fe vce(robust)
    xtreg y2 x i.year, fe vce(robust)
    xtreg y3 x i.year, fe vce(robust)

    Since I think it makes sense to suppose that the underlying processes for the three dependent variables might be similar, I would like to perform a seemingly unrelated regression.

    First, I considered sureg - but not sure if it works with panel data. So, I had a look at xtsur (http://fmwww.bc.edu/RePEc/bocode/x/xtsur.html) - but it uses re estimators. I tried to run xtsur adding i.id to the list of regressor (does it make sense?), but Stata 15 failed in calculating...

    So, I got back to sureg and tried this:

    xtset id year
    sureg (y1 x i.year i.id) (y2 x i.year i.id) (y3 x i.year i.id), corr

    Is this a correct approach for estimating SUR with fixed effects panel data? Any alternative?

    Thanks!
    Please, did you ever get a solution to this problem?

    Comment


    • #3
      Have you considered using a correlated random effect model?

      Comment


      • #4
        Yes, the command

        Code:
        sureg (y1 x i.year i.id) (y2 x i.year i.id) (y3 x i.year i.id)
        gives you a Seemingly Unrelated Regression with fixed effects at the id and year levels.

        I do not think there is reason here to -xtset- the data, the command above would work by itself.

        Comment


        • #5
          Joro is correct, except that when you have too many fixed effect groups, making that strategy infeasible.

          Comment


          • #6
            One has to be very careful with "extensions" like this. Fernando points to possible computational problems but there might be statistical issues as well. I think we don't know the statistical properties of such a procedure. SUR involves residuals from first-stage OLS, and those involve the estimated fixed effects. Plus, it's not at all clear how one does proper inference. Even ignoring the possible incidental parameters problem, sureg doesn't allow for any kind of robust inference (a mistake in my view).

            If the coefficients are allowed to be different in every equation, I doubt efficiency gains would be substantial. There's nothing wrong with using regular fixed effects on each equation.

            I like Fernando's thought about CRE, but, again, if used with sureg (and probably xtsur, although I haven't used it) there's still the issue of proper inference.

            Comment


            • #7
              Computational problems are easily overcome: if one has too many fixed effects in one dimension, so that including dummies with say i.id is infeasible, one can apply manually the within transformation through -xtdata-. And then proceed with a sureg on the within transformed data.

              My postestimation command -suregr- (type -findit suregr- from within Stata and follow instructions to install) provides robust and cluster robust inference post -sureg-.

              Otherwise Professor Wooldridge is right that I did not think this through very well.
              If one has 100 ids, and 2 time periods, and 3 equations, one would be estimating 300 fixed effects on 200 observations. This does not sound right...
              Also here the Least Squares Dummy Variable (LSDV) regression and the within transformation would not give the same results, as the estimated fixed effects across equations with the LSDV representation are not constrained to be the same.

              We need to investigate this more. Sounds like an Econometrica ​​​​​​paper is cooking here :P.

              Comment


              • #8
                I have been thinking about the Fixed Effects Seemingly Unrelated Regression overnight, and I do not see anything wrong with entertaining a model:

                Yitj = Xitj*Bj + Aij + Eitj,
                where i = 1,2...N (the cross sectional units)
                t = 1,2,...T the time periods
                j = 1,2,...M the equations, and
                Aij is the equation level fixed effect.

                The motivation for applying the within transformation, or the LSDV regression is to eliminate/control for the unit and equation specific fixed effects.

                I do not see anything wrong with having some equations within-transformed, and some equations in levels.

                Additionally, it turns out that the LSDV regression and the Within transformation are giving equivalent estimates for this Fixed Effects Seemingly Unrelated Regression.

                Here is an example:

                Code:
                . use grunfeld, clear
                
                . 
                . keep if year < 1937
                (180 observations deleted)
                
                . 
                . gen normal = rnormal()
                
                . 
                . sureg (invest normal i.company) (mvalue kstock i.company)
                
                Seemingly unrelated regression
                ------------------------------------------------------------------------------
                Equation             Obs   Params         RMSE  "R-squared"      chi2   P>chi2
                ------------------------------------------------------------------------------
                invest                20       10     25.55559      0.9551     429.36   0.0000
                mvalue                20       10     219.1132      0.9649     572.89   0.0000
                ------------------------------------------------------------------------------
                
                ------------------------------------------------------------------------------
                             | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                invest       |
                      normal |   -4.97356   4.649767    -1.07   0.285    -14.08694    4.139816
                             |
                     company |
                          2  |    -73.573   25.47564    -2.89   0.004    -123.5043   -23.64166
                          3  |  -318.7766   25.60579   -12.45   0.000     -368.963   -268.5902
                          4  |  -296.0674   25.51459   -11.60   0.000    -346.0751   -246.0597
                          5  |    -307.62   25.49872   -12.06   0.000    -357.5966   -257.6434
                          6  |  -336.4358   25.84854   -13.02   0.000     -387.098   -285.7736
                          7  |  -327.6669   25.61515   -12.79   0.000    -377.8716   -277.4621
                          8  |  -329.7558    25.9583   -12.70   0.000    -380.6331   -278.8784
                          9  |  -328.1426    25.4795   -12.88   0.000    -378.0815   -278.2037
                         10  |  -352.2549   25.43892   -13.85   0.000    -402.1143   -302.3955
                             |
                       _cons |   354.2605   17.99235    19.69   0.000     318.9961    389.5249
                -------------+----------------------------------------------------------------
                mvalue       |
                      kstock |    17.4705   4.135172     4.22   0.000     9.365715    25.57529
                             |
                     company |
                          2  |  -2712.504   236.9919   -11.45   0.000        -3177   -2248.008
                          3  |  -3559.235   371.5755    -9.58   0.000     -4287.51    -2830.96
                          4  |  -2939.337   226.0317   -13.00   0.000    -3382.351   -2496.323
                          5  |  -6605.656   718.7303    -9.19   0.000    -8014.342   -5196.971
                          6  |  -3377.313   225.0035   -15.01   0.000    -3818.312   -2936.314
                          7  |  -5184.296   411.3361   -12.60   0.000      -5990.5   -4378.092
                          8  |  -3055.129   240.5426   -12.70   0.000    -3526.584   -2583.674
                          9  |  -6030.362   618.4933    -9.75   0.000    -7242.586   -4818.137
                         10  |  -3387.194   234.6562   -14.43   0.000    -3847.112   -2927.276
                             |
                       _cons |   3386.167   189.9786    17.82   0.000     3013.816    3758.518
                ------------------------------------------------------------------------------
                
                . 
                . for var invest normal mvalue kstock: egen double Xmean = mean(X), by(company) \ gen double Xdm =
                >  X - Xmean
                
                ->  egen double investmean = mean(invest), by(company)
                
                ->  gen double investdm = invest - investmean
                
                ->  egen double normalmean = mean(normal), by(company)
                
                ->  gen double normaldm = normal - normalmean
                
                ->  egen double mvaluemean = mean(mvalue), by(company)
                
                ->  gen double mvaluedm = mvalue - mvaluemean
                
                ->  egen double kstockmean = mean(kstock), by(company)
                
                ->  gen double kstockdm = kstock - kstockmean
                
                . 
                . keep *dm 
                
                . 
                . rename *dm *
                
                . 
                . sureg (invest normal) (mvalue kstock)
                
                Seemingly unrelated regression
                ------------------------------------------------------------------------------
                Equation             Obs   Params         RMSE  "R-squared"      chi2   P>chi2
                ------------------------------------------------------------------------------
                invest                20        1     25.55559      0.0729       1.14   0.2848
                mvalue                20        1     219.1132      0.4817      17.85   0.0000
                ------------------------------------------------------------------------------
                
                ------------------------------------------------------------------------------
                             | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
                -------------+----------------------------------------------------------------
                invest       |
                      normal |   -4.97356   4.649767    -1.07   0.285    -14.08694    4.139816
                       _cons |          0   5.688198     0.00   1.000    -11.14866    11.14866
                -------------+----------------------------------------------------------------
                mvalue       |
                      kstock |    17.4705   4.135172     4.22   0.000     9.365715    25.57529
                       _cons |          0   47.92857     0.00   1.000    -93.93828    93.93828
                ------------------------------------------------------------------------------

                Comment


                • #9
                  Hi Joro,
                  I think what you suggest is going through the within transformation first, (FWL) before running the regression.
                  On this regard, however, i believe there would be problems if one does not transform all covariates in the model. In this case "problem" means that the results would not be equivalent. Although i can see that could be a better approach, since it would impose different assumptions on the model, that may be of interest.
                  Going back to the Correlated Random effects modeling, I'm attaching a piece of code that i wrote to help making the CRE modeling easier, which could be used with sureg or suest (for robust inference).

                  Bellow an example:

                  Code:
                  use http://fmwww.bc.edu/RePEc/bocode/o/oaxaca.dta
                  ** model 1
                  reg lnwage educ age female i.isco
                  est sto m1
                  ** model 2
                  reg exper educ age female i.isco
                  est sto m2
                  ** nonrobust
                  sureg (lnwage educ age female i.isco) (exper educ age female i.isco)
                  est sto m12a
                  ** robust
                  suest m1 m2
                  est sto m12b
                  ** using cre
                  ** we need to "keep" the new variables
                  cre, abs(isco) keep prefix(m):reg lnwage educ age female 
                  est sto m3
                  ** Notice how the prefix changes, and the new variables are available
                  cre, abs(isco) keep prefix(n):reg exper educ age female 
                  est sto m4
                  
                  **
                  ** nonrobust
                  sureg (lnwage educ age female m?_* ) (exper educ age female n?_* )
                  est sto m34a
                  ** robust
                  suest m3 m4
                  est sto m34b
                  
                  esttab m1 m3
                  esttab m2 m4
                  
                  esttab m12a m34a
                  esttab m12b m34b
                  You will see small differences in SE which is due to degrees of freedom.
                  F
                  Attached Files

                  Comment


                  • #10
                    Hi FernandoRios ,

                    What you and Professor Jeff Wooldridge call Correlated Random Effects (CRE) model and what I call the Mundlak device/approach -- we should by the way sit down and do a historical survey to see what is the appropriate name for this device/approach/model -- is a good idea. I did not engage with your suggestion simply because in the fixed effects panel data model estimated by OLS the Mundlak device is equivalent to the LSDV and the within transformed estimates, and this follows by the very FWL theorem that you cited. So to me the Mundlak device is just a convenient reparametrisation which, e.g., makes testing of random vs fixed effects very easy.

                    You can verify that in the system context that we speak about here, the Mundlak device will be equivalent to the LSDV regression, and the within transformed regression that I proposed, if the regressors in each equation of the system are the same. That is, if we have Multivariate Regression and not Seemingly Unrelated Regression.

                    As it turns out the Mundlak device is not equivalent to what I proposed in the Seemingly Unrelated Regression context that we discuss here, but I learnt this only after I tried it.

                    In short I checked and for the Seemingly Unrelated Regression context that we are discussing here (with different regressors in the different equations), the LSDV approach and the within transformed approach gives the same estimates. The Mundlak approach gives similar, but numrically different estimates.

                    As Professor Wooldridge pointed out, it still needs to be verified whether these estimators are consistent in the usual setting as N grows large and T is fixed. At this point I believe they are, but beliefs are not a demonstration.

                    Comment


                    • #11
                      It's interesting that within and LSDV are the same! Not totally surprising because the residuals are the same from the first step, but I haven't seen it show that unrestricted GLS with dummies and using the within transformation.

                      The fact that you can do GLS using the within equation gives me pause because the within errors, stacked over time, have a singular variance-covariance matrix. That is why GLS on a single within equation is tricky. That you can use a SUR version is because (I think) the method you propose ignores any serial correlation or heteroskedasticity over time. I don't think it's worth doing SUR in that scenario, but maybe there are cases. SUR that deals only with correlation within a unit but ignores it over time is not likely to be very efficient. But again, it's something that can be explored. With large N, small T and few equations, what one should do is GLS that accounts for serial correlation and within unit correlation. But still always computing fully robust standard errors.

                      Comment


                      • #12
                        Dear Jeff Wooldridge ,
                        I just did an additional check, and I realize I missed something in my previous post. The differences in standard errors are due to degrees of freedom, but also due to differences in the errors themselves.
                        However, when estimating clustered standard errors (at the same level as the "absorbed" fixed effects), SEs are exactly the same. I believe you showed that as well in both of your Econometric textbooks.

                        I wonder, however, if you have other suggestions when more than 1 fixed effects is "absorbed" using the Mundlak/random correlated model approach.

                        In my code, for example, the following two lines would produce same point estimates:

                        reghdfe y x1 x2 x3, abs(fe1 fe2)
                        cre, abs(fe1 fe2):reg y x1 x2 x3

                        but I'm not certain of what should be best practice to report the standard error. what would you suggest?
                        Fernando

                        Comment


                        • #13
                          Dear all...

                          can I conclude from your conversation that if I have a fixed effect system of equations, I can use SUR via sureg to estimate them together but I shall add I. Individuals dummy (or make time de-meaning i.e. the within transformation) and use cluster/robust standard error ? is this model valid really, please ?
                          Last edited by Nariman Sayed; 29 Jan 2023, 13:31.

                          Comment


                          • #14
                            Originally posted by Joro Kolev View Post
                            I have been thinking about the Fixed Effects Seemingly Unrelated Regression overnight, and I do not see anything wrong with entertaining a model:

                            Yitj = Xitj*Bj + Aij + Eitj,
                            where i = 1,2...N (the cross sectional units)
                            t = 1,2,...T the time periods
                            j = 1,2,...M the equations, and
                            Aij is the equation level fixed effect.

                            The motivation for applying the within transformation, or the LSDV regression is to eliminate/control for the unit and equation specific fixed effects.

                            I do not see anything wrong with having some equations within-transformed, and some equations in levels.

                            Additionally, it turns out that the LSDV regression and the Within transformation are giving equivalent estimates for this Fixed Effects Seemingly Unrelated Regression.

                            Here is an example:

                            Code:
                            . use grunfeld, clear
                            
                            .
                            . keep if year < 1937
                            (180 observations deleted)
                            
                            .
                            . gen normal = rnormal()
                            
                            .
                            . sureg (invest normal i.company) (mvalue kstock i.company)
                            
                            Seemingly unrelated regression
                            ------------------------------------------------------------------------------
                            Equation Obs Params RMSE "R-squared" chi2 P>chi2
                            ------------------------------------------------------------------------------
                            invest 20 10 25.55559 0.9551 429.36 0.0000
                            mvalue 20 10 219.1132 0.9649 572.89 0.0000
                            ------------------------------------------------------------------------------
                            
                            ------------------------------------------------------------------------------
                            | Coefficient Std. err. z P>|z| [95% conf. interval]
                            -------------+----------------------------------------------------------------
                            invest |
                            normal | -4.97356 4.649767 -1.07 0.285 -14.08694 4.139816
                            |
                            company |
                            2 | -73.573 25.47564 -2.89 0.004 -123.5043 -23.64166
                            3 | -318.7766 25.60579 -12.45 0.000 -368.963 -268.5902
                            4 | -296.0674 25.51459 -11.60 0.000 -346.0751 -246.0597
                            5 | -307.62 25.49872 -12.06 0.000 -357.5966 -257.6434
                            6 | -336.4358 25.84854 -13.02 0.000 -387.098 -285.7736
                            7 | -327.6669 25.61515 -12.79 0.000 -377.8716 -277.4621
                            8 | -329.7558 25.9583 -12.70 0.000 -380.6331 -278.8784
                            9 | -328.1426 25.4795 -12.88 0.000 -378.0815 -278.2037
                            10 | -352.2549 25.43892 -13.85 0.000 -402.1143 -302.3955
                            |
                            _cons | 354.2605 17.99235 19.69 0.000 318.9961 389.5249
                            -------------+----------------------------------------------------------------
                            mvalue |
                            kstock | 17.4705 4.135172 4.22 0.000 9.365715 25.57529
                            |
                            company |
                            2 | -2712.504 236.9919 -11.45 0.000 -3177 -2248.008
                            3 | -3559.235 371.5755 -9.58 0.000 -4287.51 -2830.96
                            4 | -2939.337 226.0317 -13.00 0.000 -3382.351 -2496.323
                            5 | -6605.656 718.7303 -9.19 0.000 -8014.342 -5196.971
                            6 | -3377.313 225.0035 -15.01 0.000 -3818.312 -2936.314
                            7 | -5184.296 411.3361 -12.60 0.000 -5990.5 -4378.092
                            8 | -3055.129 240.5426 -12.70 0.000 -3526.584 -2583.674
                            9 | -6030.362 618.4933 -9.75 0.000 -7242.586 -4818.137
                            10 | -3387.194 234.6562 -14.43 0.000 -3847.112 -2927.276
                            |
                            _cons | 3386.167 189.9786 17.82 0.000 3013.816 3758.518
                            ------------------------------------------------------------------------------
                            
                            .
                            . for var invest normal mvalue kstock: egen double Xmean = mean(X), by(company) \ gen double Xdm =
                            > X - Xmean
                            
                            -> egen double investmean = mean(invest), by(company)
                            
                            -> gen double investdm = invest - investmean
                            
                            -> egen double normalmean = mean(normal), by(company)
                            
                            -> gen double normaldm = normal - normalmean
                            
                            -> egen double mvaluemean = mean(mvalue), by(company)
                            
                            -> gen double mvaluedm = mvalue - mvaluemean
                            
                            -> egen double kstockmean = mean(kstock), by(company)
                            
                            -> gen double kstockdm = kstock - kstockmean
                            
                            .
                            . keep *dm
                            
                            .
                            . rename *dm *
                            
                            .
                            . sureg (invest normal) (mvalue kstock)
                            
                            Seemingly unrelated regression
                            ------------------------------------------------------------------------------
                            Equation Obs Params RMSE "R-squared" chi2 P>chi2
                            ------------------------------------------------------------------------------
                            invest 20 1 25.55559 0.0729 1.14 0.2848
                            mvalue 20 1 219.1132 0.4817 17.85 0.0000
                            ------------------------------------------------------------------------------
                            
                            ------------------------------------------------------------------------------
                            | Coefficient Std. err. z P>|z| [95% conf. interval]
                            -------------+----------------------------------------------------------------
                            invest |
                            normal | -4.97356 4.649767 -1.07 0.285 -14.08694 4.139816
                            _cons | 0 5.688198 0.00 1.000 -11.14866 11.14866
                            -------------+----------------------------------------------------------------
                            mvalue |
                            kstock | 17.4705 4.135172 4.22 0.000 9.365715 25.57529
                            _cons | 0 47.92857 0.00 1.000 -93.93828 93.93828
                            ------------------------------------------------------------------------------
                            So is
                            sureg (invest normal i.company) (mvalue kstock i.company) the best way of doing SUR FE models for now?

                            Comment

                            Working...
                            X