Announcement

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

  • Using higher level fixed effects in xtreg/spxtregress

    Forgive this question if it is elementary, but I'm forgetting how to get around this specific issue:

    I have a dataset with nationwide hospital-week level data for which I want to do a spatial regression. I would like to use county + year-month fixed effects, but obviously I can't use xtreg to calculate that--it'll force the lowest level to avoid repeated values, i.e., hospital-week fixed effects. Ordinarily that wouldn't be a problem (I'd use absorb and reghdfe), but I cannot do that for spatial regression unfortunately, and my RHS variables of interest are either fixed across hospitals and census tracts or are county level and change over time, so would drop out under a hospital-week fixed effect framework.

    Is there another "shortcut" to model higher-level fixed effects in a xtregress command "framework"?

  • #2
    Code:
    xtset county
    
    xtreg y x1 x2 i.year , fe

    Comment


    • #3
      Great point. I should have clarified however, that spxtregress requires a time variable as part of xtset, unfortunately:

      HTML Code:
      xtset countyfips
      
      Panel variable: countyfips (unbalanced)
      
      spbalance
      time variable not xtset
          Data are xtset on the panel variable countyfips only.
          Type xtset countyfips timevar.
      r(459);
      
      . 
      
      xtset countyfips_month
      
      Panel variable: countyfips_month (unbalanced)
      
      spbalance
      time variable not xtset
          Data are xtset on the panel variable countyfips_month only.
          Type xtset countyfips_month timevar.
      r(459);
      
      
      . xtset countyfips monthyear
      repeated time values within panel
      r(451);

      Comment


      • #4
        You are not taking into account the panel structure of your data, otherwise you'd xtset the data using hospital and week. Take a look at

        Code:
        help spregress
        instead.

        Comment


        • #5
          Thanks--and I understand the above, but where I struggle is that econometrically you can choose/should be able to choose the level of your fixed effects. My data unfortunately has little variation across hospital and week levels, (the main predictor is a fixed hospital-level predictor), so even when I use "interacted" fixed effects at that level (e.g., by creating a custom variable), all of my predictors fall out. I rather do county and month. is there a workaround here?

          Comment


          • #6
            I do not think that there is any difficulty doing what you propose using spregress. Just add country and time dummies to the spatial POLS model.

            Comment


            • #7
              You run into matrix problems with this. spxtregress recognizes that your spatial weights matrix is panel even when you do it, as Stata's manual indicates, on single level of a panel dataset (e.g., spmatrix create idistance W if week==1). spregress expects there to be only one weight per row and gives me an error otherwise. Also, I am using manually created interacted county and year-month fixed effects right now for the entire US and I don't know if spregress will compute all those fixed effects, but I am using STATA MP and set maxvar just in case.

              Code:
              spregress icucrowded2 i.finalmatch2, gs2sls dvarlag(IO)
                (217958 observations)
                (144573 observations excluded due to missing values)
                (73385 observations (places) used)
                (weighting matrix defines 2158 places)
              estimation sample defines places not in weighting matrix
                  You must specify if or in to restrict the estimation sample to the places in the weighting matrix or use a
                  different weighting matrix.

              Comment


              • #8
                Okay, it seems that spxtregress requires a proper panel dataset and spregress requires a proper cross-sectional dataset and nothing else for both commands. The only other thing to consider is whether to aggregate your data to the county level. How and whether this makes sense is something you would know.

                Comment

                Working...
                X