Script – Preliminary Findings

### GENERAL CHARACTERISTICS OF PARTICIPANTS ###

demog <- read.csv("demographics.csv") # A subset of the data with only demographic variables

## AGE ##

require(Hmisc)

wtd.mean(demog$age, demog$weight)

require(ggplot2)

ggplot(demog, aes(age, weight=weight)) + 
 geom_histogram(fill="#5882FA", colour="#CECEF6", binwidth=5) + 
 labs(title="Weighted distribution of age", x="Age", y="Count")

## POLITICAL PROFILE ##

demog$leftrightcat <- factor(demog$leftright, ordered=TRUE, levels=1:9, 
 labels=c("Far Left", "Left", "Moderate Left", "Centre-Left", 
 "Centre", "Centre-Right", "Moderate Right", "Right", 
 "Far Right"))

leftcentreright.by.country <- aggregate(LeftCentreRight ~ country2, data=demog, FUN=summary)
write.csv(leftcentreright.by.country, "LeftCentreRight-by-country.csv")
# Weighting frequencies on a separate spreadsheet leads to accurate descriptives

ggplot(demog[is.na(demog$leftrightcat) == F, ], aes(leftrightcat, weight=weight)) + 
 geom_bar(fill="#5882FA", colour="#CECEF6", binwidth=10) + 
 labs(title="Weighted distribution on Left-Right Scale", x="Political Position", y="Count")

## OTHER ##
# Exporting spreadsheets where weighted frequencies are to be calculated

SNAtype.by.country <- aggregate(SNAtype ~ country2, data=demog, FUN=summary)
write.csv(SNAtype.by.country, "SNAtype-by-country.csv")

represent.by.country <- aggregate(represent ~ country2, data=demog, FUN=summary)
write.csv(represent.by.country, "represent-by-country.csv")

gender.by.country <- aggregate(gender ~ country2, data=demog, FUN=summary)
write.csv(gender.by.country, "gender-by-country.csv")

#####################################################################################

### OPINIONS OF PARTICIPANTS ###

library(likert)
library(plyr)

data <- read.csv("stackedbars.csv") #subset with Likert-scale responses

attach(data)

###COMPONENTS OF MLP VARIABLE###

##Prepare the subset for likert plotting##

toplot.MLP <- data.frame(cbind(MLP.mainactors, MLP.directrel, MLP.intorg, MLP.intlaw, MLP.nonnat))

toplot.MLP$MLP.mainactors <- factor(toplot.MLP$MLP.mainactors, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Completely disagree", "Somewhat disagree", 
 "Neither disagree \nnor agree", 
 "Somewhat agree", "Completely agree"))
toplot.MLP$MLP.directrel <- factor(toplot.MLP$MLP.directrel, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Completely disagree", "Somewhat disagree", 
 "Neither disagree \nnor agree", 
 "Somewhat agree", "Completely agree"))
toplot.MLP$MLP.intorg <- factor(toplot.MLP$MLP.intorg, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Completely disagree", "Somewhat disagree", 
 "Neither disagree \nnor agree", 
 "Somewhat agree", "Completely agree"))
toplot.MLP$MLP.intlaw <- factor(toplot.MLP$MLP.intlaw, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Completely disagree", "Somewhat disagree", 
 "Neither disagree \nnor agree", 
 "Somewhat agree", "Completely agree"))
toplot.MLP$MLP.nonnat <- factor(toplot.MLP$MLP.nonnat, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Completely disagree", "Somewhat disagree", 
 "Neither disagree \nnor agree", 
 "Somewhat agree", "Completely agree"))

##Create likert object##

toplot.MLP <- rename(toplot.MLP, c(MLP.mainactors = "SNAs should be among the main actors of \nEuropean politics", 
 MLP.directrel = "It is important for SNAs to have \ndirect relations with SNAs from other countries", 
 MLP.intorg = "It is important for SNAs to be \nrepresented in international organizations", 
 MLP.intlaw = "SNAs should berecognized as \nactors in international law", 
 MLP.nonnat = "The external relations of SNAs should \nnot be obstructed by national constraints"))

splot.MLP <- likert(toplot.MLP)

##Create weighted likert object##

splot.MLP.wtd <- splot.MLP
MLP.wtd.vals <- read.csv("MLP-wtd-vals.csv")
MLP.wtd.vals <- rename(MLP.wtd.vals, c(Completely.disagree="Completely disagree", 
 Somewhat.disagree="Somewhat disagree", 
 Neither.disagree.nor.agree="Neither disagree \nnor agree", 
 Somewhat.agree="Somewhat agree", 
 Completely.agree="Completely agree"))
splot.MLP.wtd$results <- MLP.wtd.vals

##Plot weighted likert object##

likert.bar.plot(splot.MLP.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1") + 
 labs(title = "Opinions on Multi-Layered Politics (weighted)")

###COMPONENTS OF EU VARIABLE###

##Prepare the subset for likert plotting##

toplot.EU <- data.frame(cbind(EU.socpol, EU.ecpol, EU.intaf, EU.foraf, EU.overall))

toplot.EU$EU.socpol <- factor(toplot.EU$EU.socpol, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.EU$EU.ecpol <- factor(toplot.EU$EU.ecpol, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.EU$EU.intaf <- factor(toplot.EU$EU.intaf, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.EU$EU.foraf <- factor(toplot.EU$EU.foraf, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.EU$EU.overall <- factor(toplot.EU$EU.overall, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))

##Create likert object##

toplot.EU <- rename(toplot.EU, c(EU.socpol = "Social policy", EU.ecpol = "Economic policy", 
 EU.intaf = "Domestic affairs", EU.foraf = "Foreign affairs", 
 EU.overall = "In general"))

splot.EU <- likert(toplot.EU)

##Create weighted likert object##

splot.EU.wtd <- splot.EU
EU.wtd.vals <- read.csv("EU-wtd-vals.csv")
EU.wtd.vals <- rename(EU.wtd.vals, c(Very.weak="Very weak", Somewhat.weak="Somewhat weak", 
 Neither.weak.nor.strong="Neither weak \nnor strong", 
 Somewhat.strong="Somewhat strong", Very.strong="Very strong"))
splot.EU.wtd$results <- EU.wtd.vals

#Plot weighted likert object##

likert.bar.plot(splot.EU.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1") + 
 labs(title = "Opinions on the strength of European institutions (weighted)")
likert.bar.plot(splot.EU.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1", legend.position="right") + 
 labs(title = "Opinions on the strength of European institutions (weighted)")

###COMPONENTS OF SUBNATIONAL COMPETENCES VARIABLE###

##Prepare the subset for likert plotting##

toplot.DEV <- data.frame(cbind(Dev.socpol, Dev.ecpol, Dev.intaf, Dev.foraf, Dev.overall))

toplot.DEV$Dev.socpol <- factor(toplot.DEV$Dev.socpol, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.DEV$Dev.ecpol <- factor(toplot.DEV$Dev.ecpol, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.DEV$Dev.intaf <- factor(toplot.DEV$Dev.intaf, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.DEV$Dev.foraf <- factor(toplot.DEV$Dev.foraf, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))
toplot.DEV$Dev.overall <- factor(toplot.DEV$Dev.overall, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very weak", "Somewhat weak", 
 "Neither weak nor strong", 
 "Somewhat strong", "Very strong"))

##Create likert object##

toplot.DEV <- rename(toplot.DEV, c(Dev.socpol = "Social policy", Dev.ecpol = "Economic policy", 
 Dev.intaf = "Domestic affairs", Dev.foraf = "Foreign affairs", 
 Dev.overall = "In general"))

splot.DEV <- likert(toplot.DEV)

##Create weighted likert object##

splot.DEV.wtd <- splot.DEV
DEV.wtd.vals <- read.csv("DEV-wtd-vals.csv")
DEV.wtd.vals <- rename(DEV.wtd.vals, c(Very.weak="Very weak", Somewhat.weak="Somewhat weak", 
 Neither.weak.nor.strong="Neither weak \nnor strong", 
 Somewhat.strong="Somewhat strong", Very.strong="Very strong"))
splot.DEV.wtd$results <- DEV.wtd.vals

#Plot weighted likert object##

likert.bar.plot(splot.DEV.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1") + 
 labs(title = "Opinions on the strength of Sub-national authorities (weighted)")
likert.bar.plot(splot.DEV.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1", legend.position="right") + 
 labs(title = "Opinions on the strength of Sub-national authorities (weighted)")

###ADDITIONAL: MLG, SUBSIDIARITY, DECENTRALIZATION, FEDERALISM###

##Prepare the subset for likert plotting##

toplot.ad <- data.frame(cbind(multilevelgov, subsidiarity, federalism, decentralization))

toplot.ad$multilevelgov <- factor(toplot.ad$multilevelgov, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very negative", "Somewhat negative", 
 "Neither negative nor positive", 
 "Somewhat positive", "Very positive"))
toplot.ad$subsidiarity <- factor(toplot.ad$subsidiarity, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very negative", "Somewhat negative", 
 "Neither negative nor positive", 
 "Somewhat positive", "Very positive"))
toplot.ad$federalism <- factor(toplot.ad$federalism, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very negative", "Somewhat negative", 
 "Neither negative nor positive", 
 "Somewhat positive", "Very positive"))
toplot.ad$decentralization <- factor(toplot.ad$decentralization, ordered = TRUE, 
 levels = c(1, 2, 3, 4, 5), 
 labels = c("Very negative", "Somewhat negative", 
 "Neither negative nor positive", 
 "Somewhat positive", "Very positive"))

##Create likert object##

toplot.ad <- rename(toplot.ad, c(multilevelgov = "Multi-level governance", 
 subsidiarity = "Subsidiarity", 
 federalism = "Federalism", 
 decentralization = "Decentralization"))

splot.ad <- likert(toplot.ad)

##Create weighted likert object##

splot.ad.wtd <- splot.ad
ad.wtd.vals <- read.csv("additional-wtd-vals.csv")
ad.wtd.vals <- rename(ad.wtd.vals, c(Very.negative="Very negative", Somewhat.negative="Somewhat negative", 
 Neither.negative.nor.positive="Neither negative \nnor positive", 
 Somewhat.positive="Somewhat positive", Very.positive="Very positive"))
splot.ad.wtd$results <- ad.wtd.vals

#Plot weighted likert object##

likert.bar.plot(splot.ad.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1") + 
 labs(title = "Opinions on severals aspects related to \nMLP and domestic competences (weighted)")
likert.bar.plot(splot.ad.wtd, plot.percent.low=F, plot.percent.high=F, plot.percent.neutral=F, neutral.color="#EBEBD1", legend.position="right") + 
 labs(title = "Opinions on severals aspects related to \nMLP and domestic competences (weighted)")

detach(data)

#####################################################################################

### OBSERVED ASSOCIATIONS AMONG VARIABLES OF INTEREST ###

library(moments)
library(gridExtra)
library(psychometric)
library(reshape2)
library(psych)


data <- read.csv("complete2.csv") #complete dataset where index variables are included
attach(data)

#normalization of continuous variables:
data$MLP.fin <- MLP7^3/25
data$EI.fin <- EuInteg^2/5
data$SNA.fin <- devolution5
data$TNI.fin <- log(TNI.sum)
data$TNOuse.fin <- UsefulIntOrg^2/5

detach(data)
attach(data)

## continuous v continuous ##

covcor.matrix.cont <- 
 cov.wt(na.omit(cbind(data[ , 35:38], MLP.fin)), wt=na.omit(data[ , 33:38])$weight, cor=T)

cor.matrix.cont <- covcor.matrix.cont$cor 
cor.matrix.cont.ci <- apply(cor.matrix.cont, c(1,2), 
 CIr, n=covcor.matrix.cont$n.obs, level=0.99)

cor.matrix.cont.upper <- cor.matrix.cont
cor.matrix.cont.upper[lower.tri(cor.matrix.cont)] <- NA
cor.matrix.cont.upper.long <- na.omit(melt(cor.matrix.cont.upper))

#manual entry of confidence intervals looking at cor.matrix.cont.ci:
cont.cor.value.labels <- c("1", "0.15\n(0.06-0.25)", "1", "0.19\n(0.09-0.28)", 
 "0.13\n(0.03-0.22)", "1", "0.30\n(0.21-0.39)", 
 "0.23\n(0.14-0.32)", "0.34\n(0.26-0.43)", "1", 
 "0.32\n(0.23-0.40)", "0.43\n(0.35-0.50)", "0.35\n(0.26-0.43)", 
 "0.37\n(0.28-0.45)", "1")
cor.matrix.cont.upper.long.labels <- cbind(cor.matrix.cont.upper.long, cont.cor.value.labels)

cor.matrix.cont.heatmap <- 
 ggplot(cor.matrix.cont.upper.long, aes(x=Var2, y=Var1, fill=value)) + 
 geom_tile() + 
 scale_fill_gradient2(low="red", high="blue", mid="white",
 midpoint=0, name="Pearson cor.\ncoefficient") + 
 labs(title="Correlations between continuous variables") + 
 labs(x=NULL, y=NULL) + 
 geom_text(data=cor.matrix.cont.upper.long.labels, 
 aes(label=cont.cor.value.labels), size=4) +
 scale_x_discrete(labels=c("Strength of European \ninstitutions", 
 "Sub-national competences", 
 "Effect of transnational \ninstitutions", 
 "Perceived usefulness of \ntransnational organizations", "MLP")) + 
 scale_y_discrete(labels=c("Strength of European \ninstitutions", 
 "Sub-national competences", 
 "Effect of transnational \ninstitutions", 
 "Perceived usefulness of \ntransnational organizations", "MLP"))

## dichotomous v dichotomous ##

covcor.matrix.dic <- 
 cov.wt(na.omit(cbind(data[ , 9:13], data[ , 19:23])), 
 wt=na.omit(cbind(data[ , 9:13], data[ , 19:23], weight))$weight, 
 cor=T)

cor.matrix.dic <- covcor.matrix.dic$cor 
cor.matrix.dic.ci <- apply(cor.matrix.dic, c(1,2), CIr, n=781, level=0.99)

cor.matrix.dic.upper <- cor.matrix.dic
cor.matrix.dic.upper[lower.tri(cor.matrix.dic)] <- NA
cor.matrix.dic.upper.long <- na.omit(melt(cor.matrix.dic.upper))

cor.matrix.dic.heatmap <- 
 ggplot(cor.matrix.dic.upper.long, aes(x=Var2, y=Var1, fill=value)) + 
 geom_tile() + 
 scale_fill_gradient2(low="red", high="blue", mid="white",
 midpoint=0, name="Phi\ncoefficient") + 
 geom_text(data=cor.matrix.dic.upper.long, 
 aes(label=round(value, 2)), size = 4) + 
 labs(title="Correlations between dichotomous variables") + 
 labs(x=NULL, y=NULL) + 
 scale_x_discrete(labels=c("Receiving\nEuropean funds", 
 "Assessing European funds\nas important", 
 "Effectiveness of\ntransnational organizations", 
 "Effectiveness of\ndirect relations", 
 "Effectiveness of \nnational mediation", 
 "Local political\nidentification", 
 "National political\nidentification", 
 "European political\nidentification", 
 "Cultural political\nidentification", 
 "Ideological political\nidentification")) + 
 scale_y_discrete(labels=c("Receiving\nEuropean funds", 
 "Assessing European \nfunds as important", 
 "Effectiveness of\ntransnational organizations", 
 "Effectiveness of\ndirect relations", 
 "Effectiveness of \national mediation", 
 "Local political\nidentification", 
 "National political\nidentification", 
 "European political\nidentification", 
 "Cultural political\nidentification", 
 "Ideological political\nidentification")) + 
 theme(axis.text.x=element_text(angle=90, hjust=1, vjust=0.5))

## continuous v dichotomous ##

matrix.dic <- matrix(c(- wtd.mean(data[fundsRec==0, ]$MLP.fin, weights= data[fundsRec==0, ]$weight) + 
 wtd.mean(data[fundsRec==1, ]$MLP.fin, weights= data[fundsRec==1, ]$weight), 
 - wtd.mean(data[fundsRec==0, ]$EI.fin, weights= data[fundsRec==0, ]$weight) + 
 wtd.mean(data[fundsRec==1, ]$EI.fin, weights= data[fundsRec==1, ]$weight), 
 - wtd.mean(data[fundsRec==0, ]$SNA.fin, weights= data[fundsRec==0, ]$weight) + 
 wtd.mean(data[fundsRec==1, ]$SNA.fin, weights= data[fundsRec==1, ]$weight), 
 - wtd.mean(data[fundsRec==0, ]$TNI.fin, weights= data[fundsRec==0, ]$weight) + 
 wtd.mean(data[fundsRec==1, ]$TNI.fin, weights= data[fundsRec==1, ]$weight), 
 - wtd.mean(data[fundsRec==0, ]$TNOuse.fin, weights= data[fundsRec==0, ]$weight) + 
 wtd.mean(data[fundsRec==1, ]$TNOuse.fin, weights= data[fundsRec==1, ]$weight), 
 
 - wtd.mean(data[fundsImp==0, ]$MLP.fin, weights= data[fundsImp==0, ]$weight) + 
 wtd.mean(data[fundsImp==1, ]$MLP.fin, weights= data[fundsImp==1, ]$weight), 
 - wtd.mean(data[fundsImp==0, ]$EI.fin, weights= data[fundsImp==0, ]$weight) + 
 wtd.mean(data[fundsImp==1, ]$EI.fin, weights= data[fundsImp==1, ]$weight), 
 - wtd.mean(data[fundsImp==0, ]$SNA.fin, weights= data[fundsImp==0, ]$weight) + 
 wtd.mean(data[fundsImp==1, ]$SNA.fin, weights= data[fundsImp==1, ]$weight), 
 - wtd.mean(data[fundsImp==0, ]$TNI.fin, weights= data[fundsImp==0, ]$weight) + 
 wtd.mean(data[fundsImp==1, ]$TNI.fin, weights= data[fundsImp==1, ]$weight), 
 - wtd.mean(data[fundsImp==0, ]$TNOuse.fin, weights= data[fundsImp==0, ]$weight) + 
 wtd.mean(data[fundsImp==1, ]$TNOuse.fin, weights= data[fundsImp==1, ]$weight), 
 
 - wtd.mean(data[effective.intorg==0, ]$MLP.fin, weights= data[effective.intorg==0, ]$weight) + 
 wtd.mean(data[effective.intorg==1, ]$MLP.fin, weights= data[effective.intorg==1, ]$weight), 
 - wtd.mean(data[effective.intorg==0, ]$EI.fin, weights= data[effective.intorg==0, ]$weight) + 
 wtd.mean(data[effective.intorg==1, ]$EI.fin, weights= data[effective.intorg==1, ]$weight), 
 - wtd.mean(data[effective.intorg==0, ]$SNA.fin, weights= data[effective.intorg==0, ]$weight) + 
 wtd.mean(data[effective.intorg==1, ]$SNA.fin, weights= data[effective.intorg==1, ]$weight), 
 - wtd.mean(data[effective.intorg==0, ]$TNI.fin, weights= data[effective.intorg==0, ]$weight) + 
 wtd.mean(data[effective.intorg==1, ]$TNI.fin, weights= data[effective.intorg==1, ]$weight), 
 - wtd.mean(data[effective.intorg==0, ]$TNOuse.fin, weights= data[effective.intorg==0, ]$weight) + 
 wtd.mean(data[effective.intorg==1, ]$TNOuse.fin, weights= data[effective.intorg==1, ]$weight), 
 
 - wtd.mean(data[effective.directrel==0, ]$MLP.fin, weights= data[effective.directrel==0, ]$weight) + 
 wtd.mean(data[effective.directrel==1, ]$MLP.fin, weights= data[effective.directrel==1, ]$weight), 
 - wtd.mean(data[effective.directrel==0, ]$EI.fin, weights= data[effective.directrel==0, ]$weight) + 
 wtd.mean(data[effective.directrel==1, ]$EI.fin, weights= data[effective.directrel==1, ]$weight), 
 - wtd.mean(data[effective.directrel==0, ]$SNA.fin, weights= data[effective.directrel==0, ]$weight) + 
 wtd.mean(data[effective.directrel==1, ]$SNA.fin, weights= data[effective.directrel==1, ]$weight), 
 - wtd.mean(data[effective.directrel==0, ]$TNI.fin, weights= data[effective.directrel==0, ]$weight) + 
 wtd.mean(data[effective.directrel==1, ]$TNI.fin, weights= data[effective.directrel==1, ]$weight), 
 - wtd.mean(data[effective.directrel==0, ]$TNOuse.fin, weights= data[effective.directrel==0, ]$weight) + 
 wtd.mean(data[effective.directrel==1, ]$TNOuse.fin, weights= data[effective.directrel==1, ]$weight), 
 
 - wtd.mean(data[effective.natdel==0, ]$MLP.fin, weights= data[effective.natdel==0, ]$weight) + 
 wtd.mean(data[effective.natdel==1, ]$MLP.fin, weights= data[effective.natdel==1, ]$weight), 
 - wtd.mean(data[effective.natdel==0, ]$EI.fin, weights= data[effective.natdel==0, ]$weight) + 
 wtd.mean(data[effective.natdel==1, ]$EI.fin, weights= data[effective.natdel==1, ]$weight), 
 - wtd.mean(data[effective.natdel==0, ]$SNA.fin, weights= data[effective.natdel==0, ]$weight) + 
 wtd.mean(data[effective.natdel==1, ]$SNA.fin, weights= data[effective.natdel==1, ]$weight), 
 - wtd.mean(data[effective.natdel==0, ]$TNI.fin, weights= data[effective.natdel==0, ]$weight) + 
 wtd.mean(data[effective.natdel==1, ]$TNI.fin, weights= data[effective.natdel==1, ]$weight), 
 - wtd.mean(data[effective.natdel==0, ]$TNOuse.fin, weights= data[effective.natdel==0, ]$weight) + 
 wtd.mean(data[effective.natdel==1, ]$TNOuse.fin, weights= data[effective.natdel==1, ]$weight), 
 
 - wtd.mean(data[PolId.local==0, ]$MLP.fin, weights= data[PolId.local==0, ]$weight) + 
 wtd.mean(data[PolId.local==1, ]$MLP.fin, weights= data[PolId.local==1, ]$weight), 
 - wtd.mean(data[PolId.local==0, ]$EI.fin, weights= data[PolId.local==0, ]$weight) + 
 wtd.mean(data[PolId.local==1, ]$EI.fin, weights= data[PolId.local==1, ]$weight), 
 - wtd.mean(data[PolId.local==0, ]$SNA.fin, weights= data[PolId.local==0, ]$weight) + 
 wtd.mean(data[PolId.local==1, ]$SNA.fin, weights= data[PolId.local==1, ]$weight), 
 - wtd.mean(data[PolId.local==0, ]$TNI.fin, weights= data[PolId.local==0, ]$weight) + 
 wtd.mean(data[PolId.local==1, ]$TNI.fin, weights= data[PolId.local==1, ]$weight), 
 - wtd.mean(data[PolId.local==0, ]$TNOuse.fin, weights= data[PolId.local==0, ]$weight) + 
 wtd.mean(data[PolId.local==1, ]$TNOuse.fin, weights= data[PolId.local==1, ]$weight), 
 
 - wtd.mean(data[PolId.national==0, ]$MLP.fin, weights= data[PolId.national==0, ]$weight) + 
 wtd.mean(data[PolId.national==1, ]$MLP.fin, weights= data[PolId.national==1, ]$weight), 
 - wtd.mean(data[PolId.national==0, ]$EI.fin, weights= data[PolId.national==0, ]$weight) + 
 wtd.mean(data[PolId.national==1, ]$EI.fin, weights= data[PolId.national==1, ]$weight), 
 - wtd.mean(data[PolId.national==0, ]$SNA.fin, weights= data[PolId.national==0, ]$weight) + 
 wtd.mean(data[PolId.national==1, ]$SNA.fin, weights= data[PolId.national==1, ]$weight), 
 - wtd.mean(data[PolId.national==0, ]$TNI.fin, weights= data[PolId.national==0, ]$weight) + 
 wtd.mean(data[PolId.national==1, ]$TNI.fin, weights= data[PolId.national==1, ]$weight), 
 - wtd.mean(data[PolId.national==0, ]$TNOuse.fin, weights= data[PolId.national==0, ]$weight) + 
 wtd.mean(data[PolId.national==1, ]$TNOuse.fin, weights= data[PolId.national==1, ]$weight), 
 
 - wtd.mean(data[PolId.european==0, ]$MLP.fin, weights= data[PolId.european==0, ]$weight) + 
 wtd.mean(data[PolId.european==1, ]$MLP.fin, weights= data[PolId.european==1, ]$weight), 
 - wtd.mean(data[PolId.european==0, ]$EI.fin, weights= data[PolId.european==0, ]$weight) + 
 wtd.mean(data[PolId.european==1, ]$EI.fin, weights= data[PolId.european==1, ]$weight), 
 - wtd.mean(data[PolId.european==0, ]$SNA.fin, weights= data[PolId.european==0, ]$weight) + 
 wtd.mean(data[PolId.european==1, ]$SNA.fin, weights= data[PolId.european==1, ]$weight), 
 - wtd.mean(data[PolId.european==0, ]$TNI.fin, weights= data[PolId.european==0, ]$weight) + 
 wtd.mean(data[PolId.european==1, ]$TNI.fin, weights= data[PolId.european==1, ]$weight), 
 - wtd.mean(data[PolId.european==0, ]$TNOuse.fin, weights= data[PolId.european==0, ]$weight) + 
 wtd.mean(data[PolId.european==1, ]$TNOuse.fin, weights= data[PolId.european==1, ]$weight), 
 
 - wtd.mean(data[PolId.cultural==0, ]$MLP.fin, weights= data[PolId.cultural==0, ]$weight) + 
 wtd.mean(data[PolId.cultural==1, ]$MLP.fin, weights= data[PolId.cultural==1, ]$weight), 
 - wtd.mean(data[PolId.cultural==0, ]$EI.fin, weights= data[PolId.cultural==0, ]$weight) + 
 wtd.mean(data[PolId.cultural==1, ]$EI.fin, weights= data[PolId.cultural==1, ]$weight), 
 - wtd.mean(data[PolId.cultural==0, ]$SNA.fin, weights= data[PolId.cultural==0, ]$weight) + 
 wtd.mean(data[PolId.cultural==1, ]$SNA.fin, weights= data[PolId.cultural==1, ]$weight), 
 - wtd.mean(data[PolId.cultural==0, ]$TNI.fin, weights= data[PolId.cultural==0, ]$weight) + 
 wtd.mean(data[PolId.cultural==1, ]$TNI.fin, weights= data[PolId.cultural==1, ]$weight), 
 - wtd.mean(data[PolId.cultural==0, ]$TNOuse.fin, weights= data[PolId.cultural==0, ]$weight) + 
 wtd.mean(data[PolId.cultural==1, ]$TNOuse.fin, weights= data[PolId.cultural==1, ]$weight), 
 
 - wtd.mean(data[PolId.ideology==0, ]$MLP.fin, weights= data[PolId.ideology==0, ]$weight) + 
 wtd.mean(data[PolId.ideology==1, ]$MLP.fin, weights= data[PolId.ideology==1, ]$weight), 
 - wtd.mean(data[PolId.ideology==0, ]$EI.fin, weights= data[PolId.ideology==0, ]$weight) + 
 wtd.mean(data[PolId.ideology==1, ]$EI.fin, weights= data[PolId.ideology==1, ]$weight), 
 - wtd.mean(data[PolId.ideology==0, ]$SNA.fin, weights= data[PolId.ideology==0, ]$weight) + 
 wtd.mean(data[PolId.ideology==1, ]$SNA.fin, weights= data[PolId.ideology==1, ]$weight), 
 - wtd.mean(data[PolId.ideology==0, ]$TNI.fin, weights= data[PolId.ideology==0, ]$weight) + 
 wtd.mean(data[PolId.ideology==1, ]$TNI.fin, weights= data[PolId.ideology==1, ]$weight), 
 - wtd.mean(data[PolId.ideology==0, ]$TNOuse.fin, weights= data[PolId.ideology==0, ]$weight) + 
 wtd.mean(data[PolId.ideology==1, ]$TNOuse.fin, weights= data[PolId.ideology==1, ]$weight)), 
 
 10, 5, T, list(c("fundsrec", "fundsimp", "effectIO", "effectDR", "effectND", 
 "PID.locl", "PID.natl", "PID.eurp", "PID.cult", "PID.ideo"), 
 c("MLP", "EI", "SNA", "TNI", "TNOuse")))

matrix.dic.long <- melt(matrix.dic)

matrix.dic.heatmap <- 
 ggplot(matrix.dic.long, aes(x=Var2, y=Var1, fill=value)) + 
 geom_tile() + 
 scale_fill_gradient2(low="red", high="blue", mid="white",
 midpoint=0, limit=c(-0.6,1.4), name="Mean\ndifference") + 
 geom_text(aes(x=Var2, y=Var1, label=round(value, 2)), size=4) + 
 labs(title="Differences in the means of continuous variables
 \n between values of dichotomous variables") + 
 labs(x="Continuous variables", y="Dichotomous variables") + 
 scale_x_discrete(limits=c("EI", "SNA", "TNI", "TNOuse", "MLP"), 
 labels=c("Strength of European \ninstitutions", 
 "Sub-national competences", 
 "Effect of transnational \ninstitutions", 
 "Perceived usefulness of \ntransnational organizations", 
 "Multi-level politics")) + 
 scale_y_discrete(labels=c("Receiving funds", "Importance of funds", 
 "Effectiveness of \ntransnational organizations", 
 "Effectiveness of \ndirect relations", 
 "Effectiveness of \nnanational mediation", 
 "Local political \nidentification", 
 "National political \nidentification", 
 "European political \nidentification", 
 "Cultural political \nidentification", 
 "Ideological political \nidentification"))