Announcement

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

  • Two way cluster and driscoll kraay error in ivreghdfe

    Dear all,

    I'm using the ivreghdfe command to run a two-way cluster analysis with driscoll kraay error for panel dyadic data, and got the following error message -

    ivreghdfe y x (z=z_IV1 z_iV2), absorb(Year fID sID) cluster (fID sID) dkraay(4)
    invalid use of dkraay option - must cluster on Year (or omit cluster option)
    r(198);

    Could anyone help to let me know if cluster has to be done on the Year dimension? Is it possible to do a two-way cluster (not cluster on Year dimension) with the dkraay(#) option?

    Thanks in advance for anyone's insights!

  • #2
    Could anyone help? Appreciate any information!

    Comment


    • #3
      Sining, adding option dkraay is equivalent to clustering SE ONLY at the Year level, which contradicts your option cluster(fID sID). If you'd like to cluster on Year but NOT ONLY on Year, you may just use option cluster(fID sID Year). If clustering on Year is not an option, then just drop dkraay(4) from your code.
      Last edited by Fei Wang; 31 Oct 2021, 21:09.

      Comment


      • #4
        Originally posted by Fei Wang View Post
        Sining, adding option dkraay is equivalent to clustering SE ONLY at the Year level, which contradicts your option cluster(fID sID). If you'd like to cluster on Year but NOT ONLY on Year, you may just use option cluster(fID sID Year). If clustering on Year is not an option, then just drop dkraay(4) from your code.
        Thanks very much, Fei. I gave cluster (fID sID Year) a try but it didn't work. It seems that cluster by Year is the only option if I use driscoll kraay error in ivreghdfe. I can also use xtscc for driscoll kraay errors but it does not allow me to use the two-way cluster. Is there a way to do both?

        Thanks!

        Comment


        • #5
          Originally posted by sining song View Post

          Thanks very much, Fei. I gave cluster (fID sID Year) a try but it didn't work. It seems that cluster by Year is the only option if I use driscoll kraay error in ivreghdfe. I can also use xtscc for driscoll kraay errors but it does not allow me to use the two-way cluster. Is there a way to do both?

          Thanks!
          I just realized ivreghdfe doesn't support multi-way clustering. Then you may install clus_nway, and run the following code if you'd like to cluster SE on fID, sID and Year.

          Code:
          clus_nway ivreghdfe y x (z=z_IV1 z_iV2), absorb(Year fID sID) cluster (fID sID Year)
          Usually, I feel it's unnecessary to cluster at such many levels. You may want to read a well-known paper for instructions of clustering: https://www.nber.org/papers/w24003.

          Comment


          • #6
            Originally posted by Fei Wang View Post

            I just realized ivreghdfe doesn't support multi-way clustering. Then you may install clus_nway, and run the following code if you'd like to cluster SE on fID, sID and Year.

            Code:
            clus_nway ivreghdfe y x (z=z_IV1 z_iV2), absorb(Year fID sID) cluster (fID sID Year)
            Usually, I feel it's unnecessary to cluster at such many levels. You may want to read a well-known paper for instructions of clustering: https://www.nber.org/papers/w24003.
            Hi Fei, thank you so much. I agree that it's unnecessary to cluster at so many levels. My original plan is to use cluster at fID and sID with the dkraay() option, but it didn't work in a combined way. I will read the paper you shared and thanks again for all your information. This is very helpful to me!

            Comment

            Working...
            X