Announcement

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

  • Using xtlogit

    Hi everyone,

    I want to run the equivalent of this in xtlogit:
    Code:
    foreach v of varlist inad_hous hous_hmlss_svcs_act_ind hous_all_act_ind {
    reghdfe `v' beta1 gender2 race2 age_at_refer if ym>=`=tm(2018m1)', absorb(i.yearmonth i.hh_zip2) vce(cluster hh_zip2)
    sum `v' if city_pit==1
    scalar cm = r(mean)  
    outreg2 using "twowayfe_housing_all.xls", addstat("control mean", cm)
    }
    I tried this way but it does not work (gives error that fe invalid)

    Code:
    foreach v of varlist inad_hous hous_hmlss_svcs_act_ind hous_all_act_ind {
    reghdfe `v' beta1 gender2 race2 age_at_refer if ym>=`=tm(2018m1)', absorb(i.yearmonth i.hh_zip2) vce(cluster hh_zip2)
    sum `v' if city_pit==1
    scalar cm = r(mean)  
    outreg2 using "twowayfe_housing_all.xls", addstat("control mean", cm)
    }
    CAn you assist with how to correct this? Thank you!

  • #2
    You seem to have presented two copies of your code using reghdfe - I think you intended the second copy to be the code using xtlogit.

    Comment


    • #3
      Oh whoops! Thank you so much! SO, I have been working on it now. But I keep getting an error that the outcome does not vary in any group? I am not sure what is going wrong.
      Code:
      xtset mci yearmonth
      capture erase twowayfe_housing_all_prob.txt
      foreach v of varlist inad_hous hous_hmlss_svcs_act_ind hous_all_act_ind {
      xtlogit `v' beta1 gender2 race2 age_at_refer i.yearmonth i.hh_zip2 if ym>=`=tm(2018m1)', fe
      sum `v' if city_pit==1
      scalar cm = r(mean)  
      outreg2 using "twowayfe_housing_all_prob.xls", addstat("control mean", cm)
      }

      Comment


      • #4
        In your reghdfe the fixed effects you absorbed were yearmonth and hh_zip2.

        In your xtlogit you included the fixed effects for yearmonth and hh_zip2 as independent variables. You also specified the fe option, which causes the panel variable mci to be treated as a fixed effect. This fixed effect was not in your reghdfe.

        Your report of the error message is imprecise. I am guessing that Stata is telling you that for each value of mci, the outcome does not vary over time. With a fixed effect for the group, nothing useful can be learned about the other coefficients.

        Comment


        • #5
          Oh I think I see what you mean. I will not use the fe option, because I don't want individual (mci) fixed effects. How can I use hhzip and yearmonth fe in xtlogit?

          Comment


          • #6
            Hmm...I keep running into issues. So, I want to run a logit model, where my outcome is a 0 or 1 variable at the mci (individual level) but I use fixed effects for zip code and for yearmonth. Can you advise? I now tried this:


            Code:
            foreach v of varlist inad_hous hous_hmlss_svcs_act_ind hous_all_act_ind {
            logit `v' beta1 gender2 race2 age_at_refer i.yearmonth i.hh_zip2 if ym>=`=tm(2018m1)',
            sum `v' if city_pit==1
            scalar cm = r(mean)  
            outreg2 using "twowayfe_housing_all_prob.xls", addstat("control mean", cm)
            }
            but it just seems to run forever and ever saying note: 15480.hh_zip2!=0 predicts failure perfeclty; 15480.hh_zip2!=0 dropped and 1 obs not used

            Over and over again for various zipcodes

            Comment


            • #7
              The issue is exactly the same as it was for individuals (mci). If a given value of a categorical variable (mci, hh_zip2) has either no successes or has no failures, then it is impossible to estimate a coefficient.

              You might ask, why did it work with reghdfe. That is because reghdfe is fitting a linear regression model and logit is fitting a logistic regression model.

              Comment

              Working...
              X