#Loading QCA R Package; Reading and Organizing the Data:

library('QCA')
## Loading required package: admisc
## 
## To cite package QCA in publications, please use:
##   Dusa, Adrian (2019) QCA with R. A Comprehensive Resource.
##   Springer International Publishing.
## 
## To run the graphical user interface, use: runGUI()
data<-read.csv("QCA_grand_data - updated.csv")

#Renaming Variables:

colnames(data)[colnames(data) == "ï..Country"] <- "cases"
colnames(data)[colnames(data) == "Sailency"] <- "S"
colnames(data)[colnames(data) == "Sailency.Pattern"] <- "SP"
colnames(data)[colnames(data) == "Total.Staff"] <- "TS"
colnames(data)[colnames(data) == "Technical.Staff"] <- "TechS"
colnames(data)[colnames(data) == "Technical.Percentage.from.Total"] <- "TechP"
colnames(data)[colnames(data) == "Self.Reporting.on.Resources"] <- "R"
colnames(data)[colnames(data) == "Budget.Based.on.Fines"] <- "BBOF"
colnames(data)[colnames(data) == "Supervision_Breadth"] <- "SUP"
colnames(data)[colnames(data) == "Coercion"] <- "COE"
colnames(data)[colnames(data) == "Tendency.to.Investigate"] <- "INV"
colnames(data)[colnames(data) == "Tendency.to.Fine"] <- "FINE"

#Calibration of Dependent and Explanatory Variables:

#Calibrate to fuzzy-set issue saliency:
data$S <- calibrate(data$S, thresholds = "e=10, c=52, i=200")
#Calibrate to fuzzy-set TechStaff number:
data$TechS <- calibrate(data$TechS, thresholds = "e=2, c=6, i=12")
#Calibrate to fuzzy-set the ordinal variable - supervision:
data$SUP <- calibrate(data$SUP, thresholds = "e=0, c=2, i=4")
#Calibrate to fuzzy-set the ordinal variable - coercion:
data$COE <- calibrate(data$COE, thresholds = "e=0, c=2, i=4")

Investigating configurations for Breadth_of_Supervision:

#Exploring ‘wide-supervision’ strategy -

SUP_TT <- truthTable(data, outcome = "SUP", conditions = "TechS,R,BBOF", show.cases = TRUE, complete = TRUE, incl.cut = c(0.8,0.6))
minimize(SUP_TT, details = TRUE)
## 
## M1: ~TechS*~R + TechS*R*~BBOF -> SUP
## 
##                   inclS   PRI   covS   covU   cases 
## ----------------------------------------------------------- 
## 1      ~TechS*~R  0.901  0.859  0.355  0.355  2,5,12,14; 15 
## 2  TechS*R*~BBOF  0.902  0.862  0.249  0.249  7,13,18 
## ----------------------------------------------------------- 
##               M1  0.902  0.860  0.604

#Exploring ‘narrow-supervision’ strategy -

SUP_TT <- truthTable(data, outcome = "~SUP", conditions = "TechS,R,BBOF", show.cases = TRUE, complete = TRUE, incl.cut = c(0.8,0.6))
minimize(SUP_TT, details = TRUE)
## 
## M1: TechS*~R*BBOF -> ~SUP
## 
##                   inclS   PRI   covS   covU   cases 
## --------------------------------------------------- 
## 1  TechS*~R*BBOF  0.907  0.783  0.220    -    3,8 
## --------------------------------------------------- 
##               M1  0.907  0.783  0.220

Investigating configurations for Level_of_Coercion:

#Exploring ‘high-coercion’ strategy -

COE_TT <- truthTable(data, outcome = "COE", conditions = "S,TechS,R,BBOF", show.cases = TRUE, complete = TRUE, incl.cut = c(0.8,0.6))
minimize(COE_TT, details = TRUE)
## 
## M1: S*~TechS*R*~BBOF + ~S*~TechS*~R*BBOF -> COE
## 
##                       inclS   PRI   covS   covU   cases 
## ------------------------------------------------------- 
## 1   S*~TechS*R*~BBOF  0.817  0.497  0.186  0.186  1,6 
## 2  ~S*~TechS*~R*BBOF  0.942  0.878  0.106  0.106  15 
## ------------------------------------------------------- 
##                   M1  0.859  0.647  0.292

#Exploring ‘low-coercion’ strategy -

COE_TT <- truthTable(data, outcome = "~COE", conditions = "S,TechS,R,BBOF", show.cases = TRUE, complete = TRUE, incl.cut = c(0.8,0.6))
minimize(COE_TT, details = TRUE)
## 
## M1: TechS*~R*BBOF + ~S*TechS*R*~BBOF -> ~COE
## 
##                      inclS   PRI   covS   covU   cases 
## ------------------------------------------------------ 
## 1     TechS*~R*BBOF  1.000  1.000  0.137  0.137  3; 8 
## 2  ~S*TechS*R*~BBOF  1.000  1.000  0.117  0.117  13 
## ------------------------------------------------------ 
##                  M1  1.000  1.000  0.254

Preparing data frame for analyzing divergence between enforcement strategy and outputs:

data_wout_NAs <- data[-c(9, 10, 18),]
#Make all three last columns numeric:
data_wout_NAs$INV <- as.numeric(data_wout_NAs$INV)
data_wout_NAs$FINE <- as.numeric(data_wout_NAs$FINE)
#Calibrate tendency to investige and tendency to fine:
data_wout_NAs$INV <- calibrate(data_wout_NAs$INV, thresholds = "e=10, c=50, i=75")
data_wout_NAs$FINE <- calibrate(data_wout_NAs$FINE, thresholds = "e=10, c=50, i=75")
#Preparing the "Divergency" Column:
data_wout_NAs$DVG_calibrated <- abs(data_wout_NAs$SUP - data_wout_NAs$INV) + abs(data_wout_NAs$COE - data_wout_NAs$FINE)
data_wout_NAs$DVG_calibrated <- calibrate(data_wout_NAs$DVG_calibrated, type = "crisp", thresholds = 1)

#Exploring divergence between enforcement strategy and output -

DVG_TT <- truthTable(data_wout_NAs, outcome = "DVG_calibrated", conditions = "S,TechS,R,BBOF", show.cases = TRUE, complete = TRUE, incl.cut = c(0.8,0.6))
minimize(DVG_TT, details = TRUE)
## 
## M1: ~TechS*~R*~BBOF + ~S*TechS*~R*BBOF -> DVG_calibrated
## 
##                      inclS   PRI   covS   covU   cases 
## ----------------------------------------------------------- 
## 1   ~TechS*~R*~BBOF  1.000  1.000  0.546  0.546  2,14; 5,12 
## 2  ~S*TechS*~R*BBOF  0.925  0.925  0.103  0.103  3 
## ----------------------------------------------------------- 
##                  M1  0.987  0.987  0.650