Announcement

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

  • Coarsened Exact Matching (CEM) for large panel data Difference-in-Differences analysis

    Hello Statalist users,

    I currently work on my master's thesis where I use Stata to conduct a Difference in Difference analysis. I have a large panel data set with multiple observations per entity ("id") over time ("monthly"). I'll try to estimate the DID estimator (i.post##i.treat) with entity-fixed and time-fixed effects later in an -xtreg- command, I'm not yet at this stage but it will look sth. like this:

    xtreg y i.post##i.treat covariates i.monthly, fe vce(cluster id)

    In order to generate an appropriate control group that holds the parallel trends assumption, I want to apply a Coarsened Exact Matching (CEM) on the pre-treatment period. However, weights must be constant within the panel variable (in my case "id") in order to use them in an -xtreg- command. I've already tried different things in order to keep weights constant within the panel variable, for example:

    cem id(#0) score price reviews, treatment(treat) (#1)

    cem id(1(1)36208) score price reviews, treatment(treat) (#2)

    cem id(#1) score price reviews, treatment(treat) (#3)

    However, nothing works (#2 and #3 come close, but still don't keep weights completely constant within the panel variable). Do you have any recommendations for me that I could try? Or is there another way to apply a difference-in-differences analysis with panel data and entity- and time-fixed effects other than -xtreg- (I don't want to use the -diff- command because it doesn't allow for the same range of postestimation options)?
    Last edited by Max Zorn; 28 Oct 2017, 04:55.

  • #2
    One way to get constant weights is to have equal numbers of treated and control subjects within each stratum. You can make this happen with the k2k option in cem.
    Last edited by Steve Samuels; 29 Oct 2017, 18:59.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Originally posted by Steve Samuels View Post
      One way to get constant weights is to have equal numbers of treated and control subjects within each stratum. You can make this happen with the k2k option in cem.
      I'm surprised to find out that cem in Stata do not support an if expression, I wonder if there is a way to tackle this problem, thanks

      Comment


      • #4
        I'm not sure what my post has to do with your question, but my answer in any case is: use keep if to define the estimation sample.
        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment


        • #5
          The post is older however it might help other people.
          U need to reshape your data wide before matching, match on wide data (anyway you probably want to match on ids not on various time points of one id) and save cem_weights in a separate dataset. Afterwards reshape back and merge with your data.

          Comment


          • #6
            Code:
            bys id:  egen cemw = max(cem_weights)

            Comment

            Working...
            X