Announcement

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

  • EVENTDD error message with cross section data

    I'm working with BRFSS data and its a cross section data. Need to create event study analysis and I ran the following command with " eventdd " developed by damian clarke but it's returning me the error " baseline not found
    r(198); " . Any suggestion where I'm going wrong ?

    ```
    g time_to_treat = year - law
    replace time_to_treat = 0 if missing(law)
    g treat = !missing(law)

    qui eventdd insured male i.age white black asian hispanic lths hsgrad higheduc i.year i.statefip , fe timevar(time_to_treat) ci(rcap) noline baseline(-11) cluster(statefip) graph_op(ytitle("Effect of law on Ins") xlabel(-20(5)25))

    ```

  • #2
    I think one issue is that you're baseline doesn't occur. The default is -1 and your time_to_treat variable might not take on a value lower than -11. I suggest taking a look at the result of

    Code:
    tab time_to_treat
    Also,

    Code:
    replace time_to_treat = 0 if missing(law)
    This looks incorrect. Those missing values should be left as is, they act as "pure controls" in the eventdd framework.

    Comment


    • #3
      Yeah you are absolutely right. I recoded everything but law value takes 1 in the year that law is being adopted. So, when I'm generating

      g time_to_treat = year - law. ----- this is returning me the value of 1994 ( the year for that observation ) since the law value is either 0 or 1. That's why my toe_to_treat looks like that. Could you kindly suggest how can I correctly specify so that I can run the eventdd command ?
      Attached Files

      Comment


      • #4
        My question is how can I make the time_to_treat variable -1 - which is the default given that my law is coded as 0 or 1 given the state in that year adopts the law or not ? Year value takes from 1994 to 2019.

        Comment


        • #5
          The time_to_treate variable is a standardized variable where 0 corresponds to the time period in which the event of interest occurs for a given unit. Without seeing your data it's hard to give exact code but you should be able to follow this example and adapt it for your setup.

          Code:
          use "http://www.damianclarke.net/stata/bacon_example.dta", clear 
          gen timeToTreat = year - _nfd

          Comment


          • #6
            thanks so much. I figured that out how to do that. But the problem remains that eventdd most probably works for only panel data but I have a cross section data. After coding everything correctly this is the error message I get

            must specify panelvar; use xtset
            r(459);


            So that means its not gonna work for cross section data.

            Comment


            • #7
              Hi Tariq,

              I'm sorry that I have only seen this now! Just in case this is still of relevance, the eventdd command can be used with cross sectional or repeated cross sectional data. In this case, you'd simply need to use the method(ols) or method(hdfe) options. The error you mention above will occur if using method(fe), without having previously xtset the data. For example, following the code suggested by Justin, you could do something like:

              Code:
              use "http://www.damianclarke.net/stata/bacon_example.dta", clear
              gen timeToTreat = year - _nfd
              eventdd asmrs pcinc asmrh cases i.year i.stfips, timevar(timeToTreat) method(ols, cluster(stfips))

              Comment


              • #8
                Originally posted by Damian Clarke View Post
                Hi Tariq,

                I'm sorry that I have only seen this now! Just in case this is still of relevance, the eventdd command can be used with cross sectional or repeated cross sectional data. In this case, you'd simply need to use the method(ols) or method(hdfe) options. The error you mention above will occur if using method(fe), without having previously xtset the data. For example, following the code suggested by Justin, you could do something like:

                Code:
                use "http://www.damianclarke.net/stata/bacon_example.dta", clear
                gen timeToTreat = year - _nfd
                eventdd asmrs pcinc asmrh cases i.year i.stfips, timevar(timeToTreat) method(ols, cluster(stfips))
                So kind of you for getting back to me with a clear explanation and coding. Will definitely try this to run the regression again. Much appreciate this kind gesture!

                Comment

                Working...
                X