Announcement

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

  • Restrict parameters with two-way fixed effects

    Hi all,

    I'm trying to estimate a regression imposing the restriction that two parameters sum to one, and include two-way fixed effects.

    GMM would be perfect for that, but I'm not sure how to include both fixed effects in it.

    Notice that I have too many fixed effects to include them as dummies.

    Do you have suggestions?

    Thanks!
    Last edited by Luca Gagliardone; 22 Jan 2023, 17:24.

  • #2
    How many levels are there for each fixed effect?

    Comment


    • #3
      I have a very large number of levels, cannot be handled with dummies.

      Baltagi 2001 (demeaning) or Woodford 2021 (Mundlak) should work, but the standard errors are all over the place.

      Ideally I would like to write a program to reproduce the output of ivreghdfe with two absorbing dimensions, without having to rely on dummies.

      Comment


      • #4
        #2 asks for numbers.

        a very large number
        is ambiguous.

        Comment


        • #5
          Can you clarify why are you asking this?

          Let's say I have 120001 levels.

          Comment


          • #6
            This is not a trick question and I am trying to be practical here. You state that you have 2 fixed effects. If this is panel data with an \(N\) and \(T\) dimension, you can be specific with \(N=xx\) and \(T=xx\).

            Comment


            • #7
              N = 5058 and T = 20891

              Comment


              • #8
                I'll assume you have explanatory variables x1 and x2 and you want their coefficients to sum to unit. To impose this, plug in the restriction: b2 = 1 - b1. So

                y = b1*x1 + b2*x2 + ...

                y = b1*x1 + (1 - b1)*x2 + ...

                or

                y - x2 = b1*(x1 - x2) + ...

                So apply any econometric you want after defining a new dependent variable, y - x2, and a new explanatory variable, x1 - x2. For example:

                Code:
                gen y_x2 = y - x2
                gen x1_x2 = x1 - x2
                reghdfe y_x2 x1_x2, absorb(id time)
                Of course, include any other explanatory variables, or use IV if that's what you want to do.

                Comment


                • #9
                  What Prof. Wooldridge explains -- manually imposing the constraint -- is the best policy here.

                  However just out of curiosity, what did the comment in #3 about "standard errors all over the place" mean?

                  If the panel is balanced, another way to go would be to double demean all variables, and then impose the constraint through [R] cnsreg -- Constrained linear regression.

                  Comment


                  • #10
                    Originally posted by Jeff Wooldridge View Post
                    I'll assume you have explanatory variables x1 and x2 and you want their coefficients to sum to unit.
                    Thanks for the reply! Unfortunately the trick does not work here, as the restriction is more complicated.

                    I've been working around the problem using reghdfe with just the FE to demean all the variables separately. Then used GMM to impose the restrictions directly on the Baltagi regression, and block bootstrap for the SE.

                    With the correct sample for all the steps, this replicates reghdfe in simulated data.

                    Let me please know if you spot something here that does not work conceptually.

                    Originally posted by Joro Kolev View Post
                    However just out of curiosity, what did the comment in #3 about "standard errors all over the place" mean?
                    I meant that I could not replicate the SE from reghdfe using the Baltagi or Mundlak regressions. But this is of course a know issue.

                    Comment


                    • #11
                      I'm now confused. What do you mean "the restriction is more complicated"? Is it a nonlinear restriction, or involves many parameters? If it's linear you can always solve out for one parameter as a function of the others.

                      Comment


                      • #12
                        Originally posted by Jeff Wooldridge View Post
                        I'm now confused. What do you mean "the restriction is more complicated"? Is it a nonlinear restriction, or involves many parameters? If it's linear you can always solve out for one parameter as a function of the others.
                        It's nonlinear and involves many parameters. The regression is

                        y = (1-a_0)*(1-a_1)*x_1 + (1-a_0)*a_1*x_2 + a_0*l1.y

                        where a_0 and a_1 are parameters to be estimated, x_1 and x_2 are regressors.

                        Sorry for the confusion, I was looking for a general approach to tackle flexibly this type of issues. Should have clarified that to begin with.

                        Originally posted by Joro Kolev View Post

                        If the panel is balanced, another way to go would be to double demean all variables, and then impose the constraint through [R] cnsreg -- Constrained linear regression.
                        Double demeaning and then running the GMM with the demeaned variables should work as well, if I'm not mistaken. Even in the case of unbalanced panel, provided that I'm selecting the correct sample in all the steps.
                        Last edited by Luca Gagliardone; 27 Jan 2023, 10:35.

                        Comment


                        • #13
                          The double demeaning in balanced panel data is a trivial scalar operation explained in Baltagi's book on panel data, which is given in eq(2.2) in the reference I am going to give momentarily. The double demeaning in the unbalanced case is a mess, the formula is known but the operation is matrix based, and when once upon the time I tried to program this in Stata my head started spinning and I aborted the project. The reference for the double demeaning in the unbalanced case is
                          Wansbeek, T., & Kapteyn, A. (1989). Estimation of the error-components model with incomplete panels. Journal of Econometrics, 41(3), 341-361.
                          the procedure for double demeaning in unbalanced panels is eq.(2.9) to eq.(2.13).

                          If I were you I would do the following:

                          1. I would appeal to Frisch–Waugh–Lovell and residualise y, x1 and x2 in your equation with respect the two dimensional fixed effects, say using Correia's -reghdfe-.

                          2. Then I would use nonlinear least squares (-nl-) to fit the nonlinear in the parameters equation you display in #12, where I use the residualised y, x1, and x2.


                          Comment


                          • #14
                            Originally posted by Joro Kolev View Post
                            The double demeaning in balanced panel data is a trivial scalar operation explained in Baltagi's book on panel data, which is given in eq(2.2) in the reference I am going to give momentarily. The double demeaning in the unbalanced case is a mess, the formula is known but the operation is matrix based, and when once upon the time I tried to program this in Stata my head started spinning and I aborted the project. The reference for the double demeaning in the unbalanced case is
                            Wansbeek, T., & Kapteyn, A. (1989). Estimation of the error-components model with incomplete panels. Journal of Econometrics, 41(3), 341-361.
                            the procedure for double demeaning in unbalanced panels is eq.(2.9) to eq.(2.13).

                            If I were you I would do the following:

                            1. I would appeal to Frisch–Waugh–Lovell and residualise y, x1 and x2 in your equation with respect the two dimensional fixed effects, say using Correia's -reghdfe-.

                            2. Then I would use nonlinear least squares (-nl-) to fit the nonlinear in the parameters equation you display in #12, where I use the residualised y, x1, and x2.

                            Perfect, thank you!

                            Comment

                            Working...
                            X