Announcement

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

  • xtlogit with double cluster

    Hi,
    I am running a logit model with firm fixed effect and year fixed effect. I wish to double cluster the standard error on firm and year. However, Stata would not allow me to use clustered standard error with xtlogit.
    I tried to only use one clustered standard error by running the code: xtlogit y $xlist i.year, fe vce(firm). Stata shows "vcetype firm not allowed".
    I was wondering how can I fix it?
    Thanks in advance!

    Kind regards,
    Lily

  • #2
    It's -vce(cluster firm)-.

    Comment


    • #3
      Hi Clyde,

      Yes, I used -vce(cluster firm)- (that was a typo in my previous post). Stata still shows "vcetype 'cluster' not allowed".
      Also, How can I double cluster standard error (on firm and year) for logit model?
      Thanks!

      Lily

      Comment


      • #4
        You can't do it directly. But you can do this
        Code:
        egen dbl_clstr = group(firm year)
        xtlogit ...., vce(cluster dbl_clstr)
        By the way, I didn't comment on it before, but it is an unsafe programming practice to use global macros in any situation where there is an alternative. Global macros can have name clashes with anything else that is running while you execute your code--and you have no way to know what else might be running! The bugs that can result can be maddeningly difficult to track down and fix. In your case, you are using a global macro to hold a list of variables for a regression. It would be much safer to do this with a local macro.

        There really are very few situations in Stata where global macros are needed. It probably wouldn't hurt you to almost forget you ever knew about globals and just use locals whenever you use a macro. You will hardly ever go wrong that way.

        Comment


        • #5
          Stata still shows "vcetype 'cluster' not allowed".
          xtlogit with the fixed effects option does not allow cluster robust standard errors. You may

          1. Use vce(bootstrap) in place of vce(cluster clustervar)
          2. Use clogit which allows cluster robust standard errors.

          Clyde's advice on how to cluster by both firm and year stands. But for panel data where you have one observation per firm-year combination, this is equivalent to clustering at the observation level.

          Code:
          egen obs_n= _n
          clogit ...., group(firm) cluster(obs_n)

          Comment

          Working...
          X