Announcement

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

  • Panel Fixed Effect, Clustering Standard Error (Panels are not nested within clusters)

    Hi there,

    First off, thank you for taking your time to read through my question.
    I have a panel data, which id is facility and time is year. It is an unbalanced panel of 25 years.

    I am running panel fixed effect regression with year and industry fixed effects controlled for.
    I have coded district and state of the facility location. Since each district / state may influence facility performance, I am wanting to cluster by district or by state.
    Facility does not move district or state.

    I have a following questions:

    1) When I ran xtreg y X_i, i.year i.industry, fe vce(cluster state_abbreviation), where state_abbreviation is a string variable with abbreviated state name, e.g. "NY", "CA." The code would run fine and I would get clustered standard error.

    However, when I run the code xtreg y X_i i.year i.industry fe vce(cluster state_id), where state_id is a state code ranging from 1 to 56 e.g. Alabama = 1, Alaska =2, I get an error message panels are not nested within clusters.

    If anything, I had expected string variable clustervar would give an error, but not the integer clustervar, but while I can run cluster standard error with state_abbreviation, I cannot with state_id.

    Has anyone experienced this? What might be the cause of this?

    2) Likewise, when I tried to cluster by district of the state by using "district_state" (3 or 4 digit integer) created by egen district_state = concat (district state_id), I also get panel not nested within clusters.

    In sum, what would be the cause of such error? Is unbalanced panel be the cause? Or does it have to do with some state/ district over-represented?

    3) Lastly, do I even need clustered standard error? Could I say that since I am using panel fixed effect and all my facilities do not move in location, fixed effect would control for heterogeneity from location (district | state). Hence, if I do fixed effect and clustering, there is a redundancy?

    My conceptualization of clustering may be completely off. This concept never clicked to me..

    Your thoughts and feedback would be greatly appreciated.
    Thank you for your time.

    Please let me know if anything is unclear and I would be happy to elaborate.

    Best.
    DH






























  • #2
    You don't show an example of the data that illustrates the problem. If everything is as you describe, you shouldn't have any problem with using state_id for your cluster vce variable. But I suspect things are not as you describe.

    The first question is how you -xtset- your data in the first place. Did you use the variable that identifies facilities? It is the -xtset- panel variable that must be nested within clusters.

    But more likely as the source of your difficulty, I think that some values of state_id are miscoded, so that state_id does change over time for one or more facility. Here's how you can find the offending observations:

    Code:
    by facility (state_id), sort: gen byte funky = (state_id[1] != state_id[_N])
    browse facility state_id if funky
    I imagine that the same is true of the district code. Just change the variable in the above code to find the problems there.

    Could I say that since I am using panel fixed effect and all my facilities do not move in location, fixed effect would control for heterogeneity from location (district | state).
    That is true, but this has nothing to do with clustered standard errors. The purpose of clustered standard errors is not to account for heterogeneity but to account for non-independence of observations within clusters. It's a completely separate issue.

    Comment


    • #3
      Thank you Clyde,

      You were absolutely right, I had few observations, where state_id changed over time.
      Is it correct that you cannot cluster on time-varying variable i.e. the variable you are clustering on should not change over time for a panel id (in my case facility id).

      Thank you for your help and sorry for the delayed response.





      Comment

      Working...
      X