I need to run a diff in diff analysis for university (economics) and I am new to r.
I need to find out through the examples of Hungary and Turkey if joining the European Union increases ones political involvement or not. I have data from before and after Hungary joined the European Union.
I cleaned up my data until I only had 3 variables left (year, country, and political involvement).
My code goes as follows:
#DID
##
#create dummy variable to set year
Data$year = ifelse(Data$year >= 2008, 1, 0)
#dummy variable group
Data$treated <- ifelse(Data$country == "Hungary", 1, 0)
#interaction bedtween time and treatment
Data$did <- Data$year * Data$treated
didreg1 = lm(pol ~ treated*year, data = Data)
summary(didreg1)
And it returns this:
lm(formula = pol ~ country * year, data = Data)
Residuals:
Min 1Q Median 3Q Max
-1.72649 -0.44759 0.04877 0.55241 1.05241
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.451230 0.020920 117.169 <2e-16 ***
country 0.275262 0.030974 8.887 <2e-16 ***
year -0.003637 0.025642 -0.142 0.887
country:year -0.059278 0.039000 -1.520 0.129
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.7183 on 6021 degrees of freedom
Multiple R-squared: 0.02705, Adjusted R-squared: 0.02657
F-statistic: 55.8 on 3 and 6021 DF, p-value: < 2.2e-16
So my code works but I am not sure how to interpret the results. (Note the values in the data are backwards: the most political involvement has the lowest value(1)).