1

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)).

  • 1
    What doesn't seem right? – rg255 Apr 02 '20 at 21:35
  • 1
    Ps code to make a reproducible example is very useful – rg255 Apr 02 '20 at 21:37
  • Im not sure what you mean with "diff in diff" in this case. You regress political involvement on year, treated and year*treated. What is the variable treated? Is the variable political involvement scaled ordinal? I think it takes integer values between 1 and 10? If that is the case you cant do a linear regression with OLS like you did. You need an ordered logit or probit regression for this. – Triss Apr 03 '20 at 00:16
  • Ah sorry, I mean the p value does not seem right because it is very low, or maybe I just don't know hoe to interpret it. – Bérénice Nieto Apr 03 '20 at 07:10
  • Ah yes @Triss, could you explain to me how I could make this diff in diff correctly? Hungary is the treated variable (after 2008). Political involvement is from 1 very important to 4 not at all important. – Bérénice Nieto Apr 03 '20 at 07:13
  • Ah one more thing. The country that is treated is 1, the other 0, and the year 2008 or after is 1, the other is 0. – Bérénice Nieto Apr 03 '20 at 07:30

0 Answers0