Announcement

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

  • Dynamic DiD model

    Hello everyone

    I am facing a problem with Dynamic DiD model. The issue is

    1- I am using csdid command
    HTML Code:
    csdid  gb roll , ivar(code) time(year) gvar( group ) method(dripw)
    gb = green inovation, roll= liquidity, code= firm ID, year= time, and group2= is the time after treated , zero before.

    when I include ivar option which is firm ID here I get the following error message
    Panel is not balanced
    Will use observations with Pair balanced (observed at t0 and t1)
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxx
    Difference-in-difference with Multiple Time Periods

    Number of obs = 0
    Outcome model : least squares
    Treatment model: inverse probability
    ------------------------------------------------------------------------------
    | Coefficient Std. err. z P>|z| [95% conf. interval]
    -------------+----------------------------------------------------------------
    g2016 |
    t_2015_2016 | 0 (omitted)
    t_2015_2017 | 0 (omitted)
    t_2015_2018 | 0 (omitted)
    t_2015_2019 | 0 (omitted)
    t_2015_2020 | 0 (omitted)
    t_2015_2021 | 0 (omitted)
    t_2015_2022 | 0 (omitted)
    t_2015_2023 | 0 (omitted)
    -------------+----------------------------------------------------------------
    g2017 |
    I think it is becuase this code only works with one observation for every firm ( I am not sure 100%). So, I excluded it

    the error message has gone but the outcomes are the same see below
    HTML Code:
    . csdid  gb roll ,  time(year) gvar( group2 ) method(dripw)
    Units always treated found. These will be ignored
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxx
    Difference-in-difference with Multiple Time Periods
    
                                                                 Number of obs = 0
    Outcome model  : least squares
    Treatment model: inverse probability
    ------------------------------------------------------------------------------
                 | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
    g2016        |
     t_2015_2016 |          0  (omitted)
     t_2015_2017 |          0  (omitted)
     t_2015_2018 |          0  (omitted)
     t_2015_2019 |          0  (omitted)
     t_2015_2020 |          0  (omitted)
     t_2015_2021 |          0  (omitted)
     t_2015_2022 |          0  (omitted)
     t_2015_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2017        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2016_2018 |          0  (omitted)
     t_2016_2019 |          0  (omitted)
     t_2016_2020 |          0  (omitted)
     t_2016_2021 |          0  (omitted)
     t_2016_2022 |          0  (omitted)
     t_2016_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2018        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2017_2018 |          0  (omitted)
     t_2017_2019 |          0  (omitted)
     t_2017_2020 |          0  (omitted)
     t_2017_2021 |          0  (omitted)
     t_2017_2022 |          0  (omitted)
     t_2017_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2019        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2017_2018 |          0  (omitted)
     t_2018_2019 |          0  (omitted)
     t_2018_2020 |          0  (omitted)
     t_2018_2021 |          0  (omitted)
     t_2018_2022 |          0  (omitted)
     t_2018_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2020        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2017_2018 |          0  (omitted)
     t_2018_2019 |          0  (omitted)
     t_2019_2020 |          0  (omitted)
     t_2019_2021 |          0  (omitted)
     t_2019_2022 |          0  (omitted)
     t_2019_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2021        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2017_2018 |          0  (omitted)
     t_2018_2019 |          0  (omitted)
     t_2019_2020 |          0  (omitted)
     t_2020_2021 |          0  (omitted)
     t_2020_2022 |          0  (omitted)
     t_2020_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2022        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2017_2018 |          0  (omitted)
     t_2018_2019 |          0  (omitted)
     t_2019_2020 |          0  (omitted)
     t_2020_2021 |          0  (omitted)
     t_2021_2022 |          0  (omitted)
     t_2021_2023 |          0  (omitted)
    -------------+----------------------------------------------------------------
    g2023        |
     t_2015_2016 |          0  (omitted)
     t_2016_2017 |          0  (omitted)
     t_2017_2018 |          0  (omitted)
     t_2018_2019 |          0  (omitted)
     t_2019_2020 |          0  (omitted)
     t_2020_2021 |          0  (omitted)
     t_2021_2022 |          0  (omitted)
     t_2022_2023 |          0  (omitted)
    ------------------------------------------------------------------------------
    Control: Never Treated
    Here is a sample of the data
    HTML Code:
    input double(code year) float(gb roll group2)
     2 2015 0 .0015    0
     2 2016 0 .0017    0
     2 2017 0 .0045    0
     2 2018 0  .004    0
     2 2019 0 .0024    0
     2 2020 0 .0016    0
     2 2021 0 .0021    0
     2 2022 3 .0026 2022
     2 2023 0 .0033    0
     4 2015 0 .0546    0
     4 2016 0 .0868    0
     4 2017 0 .0925    0
     4 2018 0 .2977    0
     4 2019 0 .2918    0
     4 2020 0 .0543    0
     4 2021 0 .0697    0
     4 2022 0 .0937    0
     4 2023 0 .0454    0
     5 2015 0 .0126    0
     5 2016 0 .0344    0
     5 2017 0  .068    0
     5 2018 0 .2144    0
     5 2019 0 .0793    0
     5 2020 0 .1106    0
     5 2021 0 .1476    0
     5 2022 0 .2271    0
     6 2015 0 .0096    0
     6 2016 0 .0205    0
     6 2017 0 .0166    0
     6 2018 0  .049    0
     6 2019 0  .051    0
     6 2020 0 .0244    0
     6 2021 0 .0751    0
     6 2022 0 .0276    0
     6 2023 0 .0211    0
     7 2015 0 .0365    0
     7 2016 0 .0286    0
     7 2017 0 .0754    0
     7 2018 0 .0655    0
     7 2019 0  .075    0
     7 2020 0 .0685    0
     7 2021 0 .0952    0
     7 2022 0 .0558    0
     7 2023 0 .1564    0
     8 2015 0 .0274    0
     8 2016 0 .0362    0
     8 2017 0 .0342    0
     8 2018 0 .0388    0
     8 2019 0 .0335    0
     8 2020 0 .0417    0
     8 2021 0 .0406    0
     8 2022 0 .0539    0
     8 2023 0 .0397    0
     9 2015 0 .0055    0
     9 2016 0 .0087    0
     9 2017 0 .0126    0
     9 2018 0 .0503    0
     9 2019 0 .0269    0
     9 2020 0 .0096    0
     9 2021 0 .0055    0
     9 2022 0 .0066    0
     9 2023 0 .0127    0
    10 2015 0  .027    0
    10 2016 0  .054    0
    10 2017 0 .0507    0
    10 2018 0 .1357    0
    10 2019 0 .2967    0
    10 2020 0 .1918    0
    10 2021 0 .1192    0
    10 2022 0 .0898    0
    10 2023 0 .0459    0
    11 2015 0 .0265    0
    11 2016 0 .0267    0
    11 2017 0 .0256    0
    11 2018 0 .0913    0
    11 2019 0 .0961    0
    11 2020 0 .0263    0
    11 2021 0 .0541    0
    11 2022 0 .0512    0
    11 2023 0 .0453    0
    12 2015 0 .0119    0
    12 2016 0 .0195    0
    12 2017 0  .019    0
    12 2018 0  .056    0
    12 2019 0 .0588    0
    12 2020 0 .0204    0
    12 2021 0 .0122    0
    12 2022 0 .0175    0
    12 2023 0 .0202    0
    14 2015 0 .0363    0
    14 2016 0 .0651    0
    14 2017 0 .0539    0
    14 2018 0 .0546    0
    14 2019 0 .0834    0
    14 2020 0 .0896    0
    14 2021 0 .2143    0
    14 2022 0 .0446    0
    14 2023 0 .0319    0
    16 2015 0 .0106    0
    16 2016 0 .0389    0
    end
    Can anyone help why I get zero observations

    how I can fixe this issue ?
    Thank you very much
    Last edited by ALKEBSEE RADWAN; 18 Jan 2025, 21:07.

  • #2
    One more question
    I want to construct seven indicator variables Before(- 3), Before(- 2), Before(- 1), Current, After( + 1), After( + 2), and After(3 + ) for the six years around a (gb) event. Specifcally, Before(- 3)
    indicates a frm-year observation from three years prior to the gb, Before(- 2) for two years before, and Before(- 1) for the year right before the gb; Current represents the gb year, After( + 1) is the year right after the gb, After( + 2) is the second year after the gb, and After(3 + ) is an indicator equal to one if a frm-year is at least three years after the gb, and zero otherwise.
    Last edited by ALKEBSEE RADWAN; 19 Jan 2025, 00:52.

    Comment


    • #3
      Clyde Schechter
      Andrew Musau

      Could you please help me at least for the second question (how to create the dummies above)

      Thank you

      Comment


      • #4
        As I do not use -csdid- and know little about it, I won't attempt to respond to #1.

        With regard to #2, the variable names you are requesting are not legal in Stata. Instead this code will give you variable names that are legal and somewhat resemble what you asked for.

        Code:
        xtset code year
        by code (year): egen gb_event_year = max(cond(gb > 0, year, .))
        gen years_from_gb_event = year - gb_event_year
        forvalues i = 1/3 {
            gen byte before`i' = (years_from_gb_event == -`i')
            gen byte after`i' = (years_from_gb_event == `i')
        }
        gen byte current = (years_from_gb_event == 0)

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          As I do not use -csdid- and know little about it, I won't attempt to respond to #1.

          With regard to #2, the variable names you are requesting are not legal in Stata. Instead this code will give you variable names that are legal and somewhat resemble what you asked for.

          Code:
          xtset code year
          by code (year): egen gb_event_year = max(cond(gb > 0, year, .))
          gen years_from_gb_event = year - gb_event_year
          forvalues i = 1/3 {
          gen byte before`i' = (years_from_gb_event == -`i')
          gen byte after`i' = (years_from_gb_event == `i')
          }
          gen byte current = (years_from_gb_event == 0)
          Dear Clyde Schechter,
          Thank you very much for your kind reply

          I got your point
          I will use this code, if I face any issue with this code I will get back to you
          once again thank you very much

          Comment

          Working...
          X