# treatment effect on unbalanced panel data

I have an unbalanced dataset that contains movie sales data along with some of the characteristics of the movies for several years.

One treatment (event) happened in the society in a specific year in between.

Now, I want to investigate using R software whether this treatment affected sales of the movies with some special characteristics or not. My issue is that as I checked a lot of difference-in-differences (DiD) and fixed effects (FE) models, the treatment population is the same before and after the treatment which is not in my case. The movies released before the event are completely different from the ones released after that event, and I am looking for any change in the coefficient of a movie character on its sale.

Kindly, would you please guide me to which model or R package should I use?

• Welcome. Two things. First, is there a group (society) that did not experience the event (i.e., a control group)? Second, panel data is not required in DiD settings. Could you describe your treatment in a bit more detail? – Thomas Bilach Oct 15 at 15:38
• @ThomasBilach thank you for your comment. yes, the non US movies does not experience the treatment. I have movies descriptive stats of weekly box office for US and NonUs movies, including its genre, production year, the distributor, production budget, number theatres and its total duration and the duration of violence scenes. so, I want to check whether the coefficient for the violence science proportion (on movies sales) changed after 2011 on US movies or not. – Leila.Y Oct 15 at 16:31
• You can do DID in a repeated cross section setting. – Dimitriy V. Masterov Oct 16 at 6:54
• @DimitriyV.Masterov from which r package? – Leila.Y Oct 16 at 8:34
• That's exactly what repeated cross-section means. Now you might worry about compositional changes over time (say if some periods may have lots of comedies and other don't), but your controls may take care of some of that. – Dimitriy V. Masterov Oct 16 at 17:08

## 1 Answer

Take note of the comments by @DimitriyV.Masterov. Difference-in-differences works well with repeated cross-sections data. Your equation would look something like the following:

$$y_{ist} = \alpha + \gamma S_s + \lambda A_{t} + \delta (S_s \times A_{t}) + \theta X_{ist} + \epsilon_{ist}$$

where $$y_{ist}$$ denotes movie $$i$$ in society $$s$$ at time period $$t$$. The variable $$S_s$$ is a treatment dummy equal to 1 for your non-US society, 0 otherwise. If I understood you correctly, you only observe movie sales within two societies (i.e., US and non-US) across time. $$A_{t}$$ is a post-treatment indicator for all years after 2011 in both treatment and control groups. $$X_{ist}$$ is a vector of all your individual level (i.e., movie-level) covariates and/or any other time-varying controls at the society level. Often times we think about this equation as only applying to panel data. This is not true, though. In your setting, all that's required is random samples of movies from your societies before and after treatment.

If you think about it, you could create a pseudo-panel by aggregating your data up to the society level. In other words, in each society $$s$$ and time period $$t$$ you calculate the proportion of sales for violent Sci-Fi movies. It wasn't clear what your outcome is but you get the general idea. Given the richness of your data at the individual (movie) level, there is no requirement to aggregate your data up to the level of the society. I only noted this to help with your intuition. Again, all that's necessary is a random collection of movies from societies in the periods pre- and post-shock. Moreover, this shock (i.e., treatment) is usually at some higher, well-defined level of aggregation. In your case, your treatment influences all non-US movies so you can certainly proceed with the classical difference-in-differences approach.

As for question regarding software, models such as the one suggested earlier can be run in base R using the lm() function (e.g., lm(y ~ S*A + X, data = ...). Everything should run smoothly once the variables are coded properly. If you want to extend this model to more societies (i.e., regions, counties, cities, etc.) and/or time periods and also introduce group and/or time fixed effects, then you may want to look into the plm or lfe packages.

• I got it, thanks for your comprehensive response :) – Leila.Y Oct 17 at 10:54