Announcement

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

  • Csdid gvar error

    Hello all,

    I am trying to use csdid command as my treatment group has a different starting time of the policy intervention across the institutions. So, I just used treatment variable as a gvar in command. The treatment variable is 1 for treated and 0 for non-treated.
    However, I still get an error like this: "Gvar max value is 1 and there are no periods available before that treatment. Verify that Gvar is correctly defined."
    May I ask if I need to use a different type of treatment variable to be used in gvar?

    Code:
    csdid outcome $cov, ivar(id) time(year) gvar(treat) notyet

    Thank you in advance.

  • #2
    Hi Garam
    What you need to do is construct treat so that it looks like the variable in the example file.
    gvar=0 if never treated
    and gvar = year first treated if ever treated.
    If you have the latest version of csdid, perhaps you can create the variable with the following code (assuming treat has values 0 and 1)
    Code:
    egen gvar=csgvar(treat), tvar(year) ivar(id)
    but to make sure it looks alright, do the tabulation
    Code:
    tab year gvar
    and compare it with a similar tabulation but using the example dataset.
    HTH

    Comment


    • #3
      Thank you for your clarification! The codes worked and I will try to study more about this command and the underlying assumptions!
      May I ask one additional quick question? Does an unbalanced panel make serious bias in the model? I just got a message that the panel is unbalanced (and surely most of my data would be like this), and was a little bit concerned.

      I also got a message below and I am going to look into more about the data and use the help commands suggested below. But just to clarify, may I ask any serious problems occurred with my data?
      Code:
      matsize too small
          You have attempted to create a matrix with too many rows or columns or attempted to fit a model with too many
          variables.  You need to increase matsize; it is currently 400.  Use set matsize; see help matsize.
      
          If you are using factor variables and included an interaction that has lots of missing cells, either increase
          matsize or set emptycells drop to reduce the required matrix size; see help set emptycells.
      
          If you are using factor variables, you might have accidentally treated a continuous variable as a categorical,
          resulting in lots of categories.  Use the c. operator on such variables.

      Comment


      • #4
        I need more information on this. How many controls are you using? how many treatment and control units?
        My main guess is that you were trying to use fixed effects outside the panel id. This creates a large number of dummies.
        Most of the time, adding other fixed effects in the framework of csdid is not valid.

        Comment


        • #5
          Hi Fernando. I am using CSDID for my analysis and facing a specific problem. I have a panel data and I am dividing my treatment group based on Propensity Scores. If bank i has propensity score >= 0.5 at time t, it will be considered high PS bank. If Bank i has PS < 0.5 at time t, it will be considered Low Propensity bank. So in this setup I have two treatment groups and I want to see if there is any variation in the outcome. The problem is if I drop the banks based on PS for unit i and time t, the observation at t-1 or t+1 may also be dropped based on PS. Is there any way in CSDID that I can define the treatment group with this specification without dropping observations ?

          Comment


          • #6
            Hi Md
            sorry I don’t understand the nature of your problem
            can you try restating it?

            Comment


            • #7
              Hi Fernando. Sorry for the late reply. The problem was with my specification which didn't make sense in this setting. I have figured it out. I another question related to CSDID. How do I specify CSDID in terms of a regression equation ? I understand that CSDID is the weighted average of all the possible 2x2 DID outcome but I don't know how we can write this in terms of regression equation.

              Comment


              • #8
                Well, depending on what estimator you use, you have different model especifications for each attgt
                perhaps that’s is what you are considering?

                Comment


                • #9
                  Let's assume I am using outcome regression estimator. Then what will be the model specification ?

                  Comment


                  • #10
                    One more assumption, say you are using panel data
                    then the models
                    Control group:
                    Code:
                    y_t - y_base = DY_c = x beta + e
                    Dy_hat = x beta_hat
                    ATT GT

                    Code:
                    ATTGT=E(DY - DY_hat| Treated)
                    ATT

                    Code:
                    ATT=E(ATTGT * w_gt)
                    w_gt the weight for a given ATTGT

                    Comment


                    • #11
                      Thank you Fernando. It is clear now.

                      Comment


                      • #12
                        Hello! I am trying to run csdid and have created gvar=0 if never treated, else gvar=year the treatment was first in place. However, when I run the command csdid outcome, ivar(fips) time(year) gvar(bbce_date), I get the following error: Gvar max value is . and there are no periods available before that treatment. Verify that Gvar is correctly defined. request may not be combined with by. I have run a tab with my gvar variable and everything looks okay. Any thoughts on what is going wrong? Thank you!

                        Comment


                        • #13
                          can you provide the following
                          tab year bbce_date

                          Comment


                          • #14
                            I was acctually just going back to share that I figured it out Thanks for your quick reply!!

                            Comment


                            • #15
                              Hi Fernando. I stupidly did not comprehensively document my solution to the issue of running csdid with gvar=0 if never treated, else gvar=year the treatment was first in place and getting the error: Gvar max value is . and there are no periods available before that treatment. Verify that Gvar is correctly defined. request may not be combined with by." I've pasted a tab of my time var (yar) and gvar (bbce_date) below. Any thoughts on what I am doing incorrectly?


                              bbce_date
                              year | 0 2007 2008 2009 2010 2011 | Total
                              -----------+------------------------------------------------------------------+----------
                              2005 | 12 1 2 10 10 6 | 41
                              2006 | 12 1 2 10 10 6 | 41
                              2007 | 12 1 2 10 10 6 | 41
                              2008 | 12 1 2 10 10 6 | 41
                              2009 | 12 1 2 10 10 6 | 41
                              2010 | 12 1 2 10 10 6 | 41
                              2011 | 12 1 2 10 10 6 | 41
                              2012 | 12 1 2 10 10 6 | 41
                              2013 | 12 1 2 10 10 6 | 41
                              2014 | 12 1 2 10 10 6 | 41
                              2015 | 12 1 2 10 10 6 | 41
                              2016 | 12 1 2 10 10 6 | 41
                              2017 | 12 1 2 10 10 6 | 41
                              2018 | 12 1 2 10 10 6 | 41
                              2019 | 12 1 2 10 10 6 | 41
                              -----------+------------------------------------------------------------------+----------
                              Total | 180 15 30 150 150 90 | 615

                              Comment

                              Working...
                              X