Announcement

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

  • Using two clusters in logistic regression

    Dear Statalister,

    I want to use two clusters in logit regression.

    I tried to do it, but it doesn’t work. A very simple

    logit Y X1 X2 i.Year i.Industry, cluster (Firm State)

    Is there any solution to do this?

    Thanks in advance.

  • #2
    If you mean that you want to cluster on the combinations of Firm and State:
    Code:
    egen firm_state = group(Firm State), label
    logit Y X1 X2 i.Year i.Industry, cluster(firm_state)
    Note: This assumes that many firms operate in more than one state. If firms are actually nested in states, then this approach is equivalent to just clustering on Firm, and I'm really not sure what you want to do in that case.

    Last edited by Clyde Schechter; 15 Nov 2025, 20:01.

    Comment


    • #3
      Thanks. But the combination now gives me number of clusters equal to the number of observations. I understand your point. For example, ifI want to cluster on firm and year, should I also create another variable? I mean any two clusters should I do the same? As the logit doesn’t support the multiple clusters.

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        If you mean that you want to cluster on the combinations of Firm and State:
        Code:
        egen firm_state = group(Firm State), label
        logit Y X1 X2 i.Year i.Industry, cluster(firm_state)
        Note: This assumes that many firms operate in more than one state. If firms are actually nested in states, then this approach is equivalent to just clustering on Firm, and I'm really not sure what you want to do in that case.
        Thanks. But the combination now gives me number of clusters equal to the number of observations. I understand your point. For example, ifI want to cluster on firm and year, should I also create another variable? I mean any two clusters should I do the same? As the logit doesn’t support the multiple clusters.

        Comment


        • #5
          See the logit2.ado file from https://www.kellogg.northwestern.edu...rogramming.htm. Otherwise, you could also use boottest from SSC or vcemway (also from SSC) to implement two-way clustering.

          Comment

          Working...
          X