Hello all,


I could use some input as to how to go about a research design that I am look at doing. I have also explored a number of related threads before posting this.


I have data, let's call them states. Where they observed on a week basis (i.e., 10 weeks, but will modify for robustness) and in the middle (i.e., week 5) all of the states are treated. I've decided that the onset of the treatment (since it affects all of the states will actually be used like a period (time) variable, so it will take on the value 0/1 before before and after treatment. There will be another variable that reflects 'treatment' which will reflect 3 bins of a variable based on state political ideology (e.g., purple, blue, red), so 3 groups. I want to examine an outcome variable relative to this time and treatment. I believe the code for this would be something like:

DiD: xtreg y post bins i.post##i.3bins i.week, cluster(state)

I also want to add another continuous variable based on prior state characteristics (prior stategdp) that I believe will affect the extent of intensity of the 'post" variable. I believe this is effectively a differences-in-differences-in-differences and that is coded by?:

DiDiD: xtreg y post bins i.post##i.3bins##i.priorstatecharacteristic i.week, cluster(state)

Apart from this, I would also like to explore other factors (based on theory) may 'moderate' the post variable in the original difference-in-difference setup I proposed. These other factors I would like to explore are time-varying and may become 'onset' in any given week, mostly after the pre/post, but sometimes before (e.g., in week 3 or week 4). For example, this variable may reflect whether a state's political official made some statement or it may reflect the valence of state political activity. Since these variable do not necessarily occur at week 5 in conjunction with the pre/post and are time-varying based on week, what would the code for this look like and is this doable?

Not sure if this looks something like:

xtreg y post bins i.post##i.3bins##statetimevarying i.week, cluster(state)

Lastly, I know that I would have to graph these interactions and examine the margins command somehow, but since I am unfamiliar with DiD, I am not sure what the code for these margins commands would look like, so I would love to know.


If someone could provide some guidance on my proposed research design, the code, and how to proceed, I would be very much indebted. I know it is a handful.


Thanks very much for your time.