Effect of the Program
A training program was given to some shops and not to others. df has one row per shop per period: treated is 1 for shops that got the program, after is 1 for the period after it started, and sales is the outcome.
Return the difference-in-differences estimate of the program's effect: the change in the treated shops from before to after, minus the change in the others over the same time. Get it as the coefficient of the interaction in a regression of sales on treated, after and their interaction.
Example 1
The other shops went from 10 to 12, a change of 2. The treated shops went from 20 to 27, a change of 7. The program accounts for 7 - 2 = 5.
Example 2
Both groups rose by 3, so the program changed nothing.
Constraints
12 <= len(df) <= 60- All four combinations of
treatedandafterappear
Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.
More statsmodels problems
- Enough PeopleHard
- Honest ErrorHard
- Next Three ValuesHard
- Slope Through TimeHard
- The Repeating PartHard
- Which Findings SurviveHard
- How Much Is ExplainedBeginner
- How Sure Is the SlopeBeginner