Announcement

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

  • standard error correction with 25 clusters and multiple fixed effects

    Hello,

    I am using ivreghdfe because I have an instrumental variable and state, age, and year fixed effects. I am seeking to cluster my SEs at the state level, where I have 25 states. I understand this to be an insufficient number of clusters and that I should correct for this using a wild cluster bootstrap adjustment. The postestimation command "boottest" should help with this but is not compatible with ivreghdfe when you have multiple fixed effects. I am wondering if it is sufficient to use ivreg2 and include the fixed effects in the regression as "i.state i.year i.age" and then produce a 95% confidence interval for the SEs using "boottest". Or if there is another approach that is more suitable.

    I have noticed that I do not get the same result for the boottest using ivreghdfe vs. ivreg2. Different things I have tried are:

    ivreg2 ln_earninc_bm (c17shr_b=frate_vs_b) i.age i.year i.statefip if age>=25 & age<=54 & mainyears==1 [aw=tot_b17], cluster(statefip)
    boottest c17shr_b, cluster(statefip)

    ivreghdfe ln_earninc_bm (c17shr_b=frate_vs_b) i.age i.year if age>=25 & age<=54 & mainyears==1 [aw=tot_b17], absorb(statefip) cluster(statefip)
    boottest c17shr_b, cluster(statefip)


    ivreghdfe ln_earninc_bm (c17shr_b=frate_vs_b) i.age i.year i.statefip if age>=25 & age<=54 & mainyears==1 [aw=tot_b17], cluster(statefip)
    boottest c17shr_b, cluster(statefip)

    Where I get slightly different results each time. Any advice would be greatly appreciated. I am using Stata MP 19.5. Thank you!

  • #2
    boottest, from SSC, does not support ivreghdfe. You could instead use the official xtivreg after xtset with the fixed effects variable that has the largest number of levels. The remaining absorbed variables can then be added as indicator variables.

    Comment


    • #3
      Hi Andrew,

      Thank you for the quick response! It appears that xtivreg does not support weights which I would like to include in the estimation. Do you have a sense of the advantage of using xtivreg versus ivreg2 where I add the fixed effects as indicators, versus something similar to what you suggest but using ivreghdfe instead (which does allow weights)? In other words, could you tell me why your proposed strategy would be an improvement over any of the 3 I suggested above?

      Thanks again,
      Mary Kate

      Comment


      • #4
        ivreg2 is fine, as it is supported by boottest. As I mentioned in #2, ivreghdfe is not supported, so it is out of the question. The advantage of xtivreg over ivreg2 is that, after xtset, you effectively absorb one of the fixed effects variables, whereas with ivreg2, you must include all fixed effects as indicators. However, ivreg2 has a -partial- option that allows you to partial out RHS variables whose coefficients are not of immediate interest:


        The partial(varlist) option requests that the exogenous regressors in varlist are "partialled out" from all the other variables (other regressors and excluded instruments) in the estimation. If the equation includes a constant, it is also automatically partialled out as well. The coefficients corresponding to the regressors in varlist are not calculated. By the Frisch-Waugh-Lovell (FWL) theorem, in IV, two-step GMM and LIML estimation the coefficients for the remaining regressors are the same as those that would be obtained if the variables were not partialled out. (NB: this does not hold for CUE or GMM iterated more than two steps.) The partial option is most useful when using cluster and #clusters < (#exogenous regressors + #excluded instruments). In these circumstances, the covariance matrix of orthogonality conditions S is not of full rank, and efficient GMM and overidentification tests are infeasible since the optimal weighting matrix W = S^-1 cannot be calculated. The problem can be addressed by using partial to partial out enough exogenous regressors for S to have full rank. A similar problem arises when the regressors include a variable that is a singleton dummy, i.e., a variable with one 1 and N-1 zeros or vice versa, if a robust covariance matrix is requested. The singleton dummy causes the robust covariance matrix estimator to be less than full rank. In this case, partialling-out the variable with the singleton dummy solves the problem. Specifying partial(_cons) will cause just the constant to be partialled-out, i.e., the equation will be estimated in deviations-from-means form. When ivreg2 is invoked with partial, it reports test statistics with the same small-sample adjustments as if estimating without partial, with the exception of the information in the output header (the model F, R-sqs and total sums-of-squares refer to the model after the variables are partialled-out). Note that after estimation using the partial option, the post-estimation predict can be used only to generate residuals.
        I don't think this affects how boottest works, but you can experiment by running boottest with some variables included as indicators versus the same variables partialled out. Be sure to set the bootstrap seed so that you can compare results consistently.
        Last edited by Andrew Musau; 25 Aug 2025, 15:11.

        Comment


        • #5
          A few comments and corrections.
          • boottest does support ivreghdfe
          • With all the linear hdfe commands (reghdfe, ivreghdfe, reghdfejl), it will only work with one set of absorbed fixed effects. Generally you should put the most numerous set of fixed effects in a() and put rest in the regressor list with "i." prefixes.
          • If doing that slows down your estimation a lot, you can try my reghdfejl. It accepts both OLS- and IV-style command lines.
          • boottest uses a random simulation process, so you should expect to get slightly different answers each time, unless you use the seed() option to start the random number generation at the same place. As you increase the number of replications---999 is the default but larger numbers are often practical--the variance will diminish.
          • Let me know if you have any experiences that contradict the above.

          Comment


          • #6
            Originally posted by David Roodman View Post
            With all the linear hdfe commands (reghdfe, ivreghdfe, reghdfejl), it will only work with one set of absorbed fixed effects.
            It would be helpful to add this point to the documentation. Additionally, official estimators such as xtreg also have an absorb option, but it is not clear whether the same applies to them, since xtset + absorb() effectively absorbs two FE variables.

            Comment


            • #7
              Thank you Andrew. I will add that to the help file.
              Yeah, the boottest algorithm can only ever handle one set of absorbed fixed effects, and that includes the one implied by xtreg, fe. So it can't handle the xtreg absorb() option.

              Comment


              • #8
                David and Andrew: Thank you both! This is all extremely helpful information. I tried the following:

                ivreg2:
                1) ivreg2 y (x=z) i.age i.year i.state if sample==1 [aw=weight]
                boottest x, cluster(state) ptype(equaltail) nograph seed (442419)

                ivreghdfe varying choice of absorbed FE:
                2) ivreghdfe y (x=z) i.age i.year if sample==1 [aw=weight], absorb(state)
                boottest x, cluster(state) ptype(equaltail) nograph seed (442419)

                3) ivreghdfe y (x=z) i.age i.state if sample==1 [aw=weight], absorb(year)
                boottest x, cluster(state) ptype(equaltail) nograph seed (442419)

                4) ivreghdfe y (x=z) i.state i.year if sample==1 [aw=weight], absorb(age)
                ​​​​​​​boottest x, cluster(state) ptype(equaltail) nograph seed (442419)


                I chose ptype(equaltail) based on the recommendation in "Fast and Wild" section 8.4 to use this option with instrumental variables. Estimating these 4 equations, I got the same 95% CI for each variation of ivreghdfe, telling me choice of which FE to absorb does not affect the results. For ivreg2, I get a similar result -- the CI is typically consistent up to the 3rd digit, sometimes up or down 1 number in the 3rd digit depending on choice of y variable. I noticed boottest gives me a z-statistic after ivreg2 but a t-statistic after ivreghdfe.

                I don't have a particular preference in terms of runtime or anything else, but if you happen to have any advice on what approach would be technically preferred, that would be really helpful!

                Comment


                • #9
                  All four estimations are equivalent. What distinguishes ivreghdfe from ivreg2 is the -absorb()- option in ivreghdfe. Without it, ivreghdfe = ivreg2, as stated in the documentation:

                  ivreghdfe is essentially ivreg2 with an additional absorb() option from reghdfe. See the links above for the detailed help files of each program.
                  Regarding efficiency, if the variable state has the largest number of categories (i.e., more than either age or year), then the most efficient estimation of the model is:

                  ivreghdfe y (x=z) i.age i.year if sample==1 [aw=weight], absorb(state)
                  boottest x, cluster(state) ptype(equaltail) nograph seed(442419)
                  Otherwise, if all models can be estimated and execution time is not a concern, you can use any of the methods.

                  Comment


                  • #10
                    I forgot to add on the z-statistic vs. t-statistic: If the sample size is sufficiently large, this distinction does not matter because the t-distribution converges to the standard normal distribution, so inference based on either statistic will be asymptotically equivalent.

                    Comment


                    • #11
                      On z vs t. The statistics are actually the same, they're just interpreted a bit differently in classical inference when computing confidence intervals and p values. The distinction makes no difference in boottest, at least when you're not multiway clustering.

                      You should see that for presentation, boottest labels the statistics in the same way as the preceding estimation command. ivreg2 reports z statistics unless the small option is added. reghdfe always does t statistics.
                      Last edited by David Roodman; Yesterday, 14:01.

                      Comment

                      Working...
                      X