Announcement

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

  • How to resolve no observation error for coefficient plots?

    I am trying to generate pre and post-treatment variables and then use them to generate coefficient plots. However, I am getting a no-observation error. I don't understand why.

    input float(MajorLag2 MajorLag4 MajorLag6 MajorLag8 MajorLag10 MajorLag12 MajorLead0 MajorLead2 MajorLead4 MajorLead6 MajorLead8 MajorLead10 MajorLead12) double Unemp_Rate
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.5
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.5
    0 0 0 0 0 0 0 0 0 0 0 0 0 5.7
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.6
    0 0 0 0 0 0 0 0 0 0 0 0 0 6
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.1
    0 0 0 0 0 0 0 0 0 0 0 0 0 6
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.7
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.3
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.2
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.3
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.4
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.6
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.5
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.1
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.6
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.5
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.7
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.6
    0 0 0 0 0 0 0 0 0 0 0 0 0 7.1
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.8
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.2
    0 0 0 0 0 0 0 0 0 0 0 0 0 6
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.2
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.9
    0 0 0 0 0 0 0 0 0 0 0 0 0 6.9
    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0 0 0 0 0 0 0 0 0 0 3.9
    0 0 0 0 0 0 0 0 0 0 0 0 0 3.5
    0 0 0 0 0 0 0 0 0 0 0 0 0 2.9
    0 0 0 0 0 0 0 0 0 0 0 0 0 2.8
    0 0 0 0 0 0 0 0 0 0 0 0 0 3.1
    0 0 0 0 0 0 0 0 0 0 0 0 0 3.1
    0 0 0 0 0 0 0 0 0 0 0 0 0 2.8
    0 0 0 0 0 0 0 0 0 0 0 0 0 2.3
    end
    [/CODE]


    local treat_vars "MajorLead12 MajorLead10 MajorLead8 Hurr_Lead6 Hurr_Lead4 Hurr_Lead2 Hurr_Lead0 MajorLag2 MajorLag4 MajorLag6 MajorLag8 MajorLag10 MajorLag12"

    local dep_vars "Unemp_Rate"

    local i = 1
    foreach dep_var in `dep_vars' {
    qui xtreg `dep_var' `treat_vars', fe vce(cluster fips)
    estimates store Labor_Reg`i'
    local i = `i' + 1
    }

  • #2
    Well, your example data, perhaps for reasons that do not apply to your full data set, is clearly unsuitable for the -xtreg- you want to do. All of the Major* variables are 0 in every observation. As constants they all get deleted from the model. You have no panel var in the model, nor are the variables Hurr_Lead* present, nor fips.

    So please post back with example data that at least contains the variable needed to run the regression, and has some variation in each of the variables. (If that is not possible in your full data set, then you have your answer right there.)

    Comment


    • #3
      I don't understand why I am getting the zeros. Here's the code and dataex
      xtset fips mdate

      forvalues i = 0/12 {
      by fips (mdate), sort: gen Hurr_Lag`i' = L`i'.vmax_sust // creating lags

      }

      forvalues i = 0/12 {
      by fips (mdate), sort: gen Hurr_Lead`i' = F`i'.vmax_sust // creating leads

      }

      ********************** Major *******************

      by fips (mdate), sort: gen MajorLag2 = inrange(Hurr_Lag1, 48, 299) | inrange(Hurr_Lag2, 48, 299)
      by fips (mdate), sort: gen MajorLag4 = inrange(Hurr_Lag3, 48, 299) | inrange(Hurr_Lag4, 48, 299)
      by fips (mdate), sort: gen MajorLag6 = inrange(Hurr_Lag5, 48, 299) | inrange(Hurr_Lag6, 48, 299)
      by fips (mdate), sort: gen MajorLag8 = inrange(Hurr_Lag7, 48, 299) | inrange(Hurr_Lag8, 48, 299)
      by fips (mdate), sort: gen MajorLag10 = inrange(Hurr_Lag9, 48, 299) | inrange(Hurr_Lag10, 48, 299)
      by fips (mdate), sort: gen MajorLag12 = inrange(Hurr_Lag11, 48, 299) | inrange(Hurr_Lag12, 48, 299)

      **********************

      by fips (mdate), sort: gen MajorLead0 = inrange(Hurr_Lead0, 48, 299)
      by fips (mdate), sort: gen MajorLead2 = inrange(Hurr_Lead2, 48, 299)
      by fips (mdate), sort: gen MajorLead4 = inrange(Hurr_Lead4, 48, 299)
      by fips (mdate), sort: gen MajorLead6 = inrange(Hurr_Lead6, 48, 299)
      by fips (mdate), sort: gen MajorLead8 = inrange(Hurr_Lead8, 48, 299)
      by fips (mdate), sort: gen MajorLead10 = inrange(Hurr_Lead10, 48, 299)
      by fips (mdate), sort: gen MajorLead12 = inrange(Hurr_Lead12, 48, 299)

      qui xtreg Unemp_Rate MajorLead12 MajorLead10 MajorLead8 Hurr_Lead6 Hurr_Lead4 Hurr_Lead2 Hurr_Lead0 MajorLag2 MajorLag4 MajorLag6 MajorLag8 MajorLag10 MajorLag12, fe vce(cluster fips)

      input long fips float(MajorLead12 MajorLead10 MajorLead8 Hurr_Lead6 Hurr_Lead4 Hurr_Lead2 Hurr_Lead0 MajorLag2 MajorLag4 MajorLag6 MajorLag8 MajorLag10 MajorLag12)
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      1001 0 0 0 . . . . 0 0 0 0 0 0
      end
      [/CODE]

      Comment


      • #4
        Please note I have changed the variable names for better clarity.

        Comment


        • #5
          Well, in this new example data, all of the Hurr_Lead* variables have only missing values, so the code you have written is giving 0's for all the Major* variables you are trying to derive from them. Why those Hurr_Lead* variables are all missing, I cannot tell because the vmax_sust variable is not there. Also missing is the mdate variable.

          So let's take it back to the very beginning. Please post an example with all and only the variables fips, mdate, and vmax_sust, since everything else derives from those. Make sure your example includes at least a few different fips, and a complete time-series of mdate values for each of those.

          Comment


          • #6
            Hii Clyde, Thanks for responding. I was able to rework the code and get it resolved.

            Comment

            Working...
            X