#data
load("~/Desktop/NORFACE/trilogues_duration.RData")

Interactions duration of trilogues

int1 <-  glm.nb(duration_negotiations_days ~ 
                             proposal_t_eupolarizarion + proposal_t_wmean_eu_salience  +
                             Interinst_conflict + ep_amendments_tabled + council_dissent +
                             N_eurovoc_terms + factor(package_deal) + competence_length + factor(new) + factor(form) + factor(elections_dummy) +  lr_proposal_probability + lr_proposal_probability*proposal_t_eupolarizarion +
                              factor(term),
                           data = trilogues_duration)

#summary(int1)

int2 <- glm.nb(duration_negotiations_days ~ 
                             proposal_t_eupolarizarion + proposal_t_wmean_eu_salience  +
                             Interinst_conflict + ep_amendments_tabled + council_dissent +
                             N_eurovoc_terms + factor(package_deal) + competence_length + factor(new) + factor(form) + factor(elections_dummy) +  lr_proposal_probability + lr_proposal_probability*proposal_t_wmean_eu_salience +
                              factor(term),
                           data = trilogues_duration)

#summary(int2)

stargazer(int1, int2, type = "text")
## 
## ======================================================================================
##                                                             Dependent variable:       
##                                                      ---------------------------------
##                                                         duration_negotiations_days    
##                                                            (1)              (2)       
## --------------------------------------------------------------------------------------
## proposal_t_eupolarizarion                                1.280**           0.480*     
##                                                          (0.552)          (0.283)     
##                                                                                       
## proposal_t_wmean_eu_salience                              0.249           1.929**     
##                                                          (0.426)          (0.754)     
##                                                                                       
## Interinst_conflict                                       -0.236*          -0.256*     
##                                                          (0.132)          (0.131)     
##                                                                                       
## ep_amendments_tabled                                     0.002***         0.002***    
##                                                          (0.001)          (0.001)     
##                                                                                       
## council_dissent                                           0.052            0.046      
##                                                          (0.042)          (0.042)     
##                                                                                       
## N_eurovoc_terms                                           0.052            0.067*     
##                                                          (0.035)          (0.035)     
##                                                                                       
## factor(package_deal)1                                    0.778***         0.636***    
##                                                          (0.173)          (0.178)     
##                                                                                       
## competence_length                                         -0.008          -0.012**    
##                                                          (0.005)          (0.005)     
##                                                                                       
## factor(new)1                                              0.156            0.159      
##                                                          (0.143)          (0.142)     
##                                                                                       
## factor(form)Directive                                    0.943***         0.928***    
##                                                          (0.267)          (0.265)     
##                                                                                       
## factor(form)Regulation                                   0.854***         0.826***    
##                                                          (0.249)          (0.248)     
##                                                                                       
## factor(elections_dummy)1                                  -0.179           -0.260     
##                                                          (0.191)          (0.191)     
##                                                                                       
## lr_proposal_probability                                  2.147***         4.467***    
##                                                          (0.570)          (1.305)     
##                                                                                       
## factor(term)8                                             -0.022           -0.084     
##                                                          (0.143)          (0.141)     
##                                                                                       
## proposal_t_eupolarizarion:lr_proposal_probability        -1.845*                      
##                                                          (0.971)                      
##                                                                                       
## proposal_t_wmean_eu_salience:lr_proposal_probability                     -3.961***    
##                                                                           (1.532)     
##                                                                                       
## Constant                                                 1.717**           0.874      
##                                                          (0.680)          (0.783)     
##                                                                                       
## --------------------------------------------------------------------------------------
## Observations                                               391              391       
## Log Likelihood                                          -2,045.392       -2,043.815   
## theta                                                0.672*** (0.043) 0.677*** (0.044)
## Akaike Inf. Crit.                                       4,122.785        4,119.629    
## ======================================================================================
## Note:                                                      *p<0.1; **p<0.05; ***p<0.01
#visualizations of interaction effects

predict_int1 <- ggpredict(int1, terms = c("proposal_t_eupolarizarion", "lr_proposal_probability[0.1, 0.99]"))

ggplot(predict_int1, aes(x=x, y=predicted, group=group)) +
        geom_line(aes(color=group)) +
               geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill=group , color=group),
                          alpha = .3, linetype="dotted") +
  scale_fill_manual(values = c("deepskyblue2", "palevioletred4"), labels = c("Low", "High"), name="Integration potential of proposal") +
  scale_color_manual(values = c("deepskyblue2", "palevioletred4"), labels = c("Low", "High"), name="Integration potential of proposal") + 
  theme_minimal() +
  labs(title = NULL, x = "Polarization (time proposal)", y = "Predicted duration of trilogues (days)") 

predict_int2 <- ggpredict(int2, terms = c("proposal_t_wmean_eu_salience", "lr_proposal_probability[0.1, 0.99]"))

ggplot(predict_int2, aes(x=x, y=predicted, group=group)) +
        geom_line(aes(color=group)) +
               geom_ribbon(aes(ymin = conf.low, ymax = conf.high, fill=group , color=group),
                          alpha = .3, linetype="dotted") +
  scale_fill_manual(values = c("deepskyblue2", "palevioletred4"), labels = c("Low", "High"), name="Integration potential of proposal") +
  scale_color_manual(values = c("deepskyblue2", "palevioletred4"), labels = c("Low", "High"), name="Integration potential of proposal") + 
  theme_minimal() +
  labs(title = NULL, x = "Salience (time proposal)", y = "Predicted duration of trilogues (days)")