# csQCA using Krook (2010)
#-------------------------
data(d.Kro)
head(d.Kro)
# conservative solution
eqmcc(d.Kro, outcome = "WNP")
# negated outcome, conservative solution
eqmcc(d.Kro, outcome = "WNP", neg.out = TRUE)
# parsimonious solution with details and case names
Kro.sp <- eqmcc(d.Kro, outcome = "WNP", include = "?",
details = TRUE, show.cases = TRUE)
Kro.sp
# check PI chart
Kro.sp$PIchart
# simplifying assumptions (SAs)
Kro.sp$SA
# minimized expressions for SAs using fake outcome
for(i in 1:2){
print(eqmcc(cbind(Kro.sp$SA[[i]], O = 1), outcome = "O"))
}
# conservative solution with truth table object
Kro.tt <- truthTable(d.Kro, outcome = "WNP")
Kro.sc <- eqmcc(Kro.tt)
Kro.sc
# fsQCA using Emmenegger (2011)
#------------------------------
data(d.Emm)
head(d.Emm)
# parsimonious solution with details
eqmcc(d.Emm, outcome = "JSR", incl.cut1 = 0.9, include = "?",
details = TRUE)
# intermediate solution
Emm.si <- eqmcc(d.Emm, outcome = "JSR", incl.cut1 = 0.9,
include = "?", dir.exp = c(1,1,1,1,1,0), details = TRUE)
Emm.si
# are the prime implicants also sufficient for the negation of the outcome?
pof(Emm.si$i.sol$C1P1$pims, outcome = "JSR", d.Emm, neg.out = TRUE,
relation = "suf")
# check PI chart for intermediate solution;
# C1P1: first conservative and first parsimonious solution
Emm.si$i.sol$C1P1$PIchart
# same intermediate solution, but not same SAs
identical(rownames(Emm.si$SA$S1), rownames(Emm.si$SA$S2))
# check easy counterfactuals; same
(EC1 <- Emm.si$i.sol$C1P1$EC)
(EC2 <- Emm.si$i.sol$C1P2$EC)
identical(rownames(EC1), rownames(EC2))
# minimized expressions for ECs using fake outcome
eqmcc(cbind(Emm.si$i.sol$C1P1$EC, O = 1), outcome = "O")
# plot all four prime implicants of the intermediate solution
PIsc <- Emm.si$i.sol$C1P1$pims
par(mfrow = c(2, 2))
for(i in 1:4){
plot(PIsc[, i], d.Emm$JSR, pch = 19, ylab = "JSR",
xlab = names(PIsc)[i], xlim = c(0, 1), ylim = c(0, 1),
main = paste("Prime Implicant", print(i)))
mtext(paste(
"Inclusion = ", round(Emm.si$i.sol$C1P1$IC$incl.cov$incl[i], 3),
"; Coverage = ", round(Emm.si$i.sol$C1P1$IC$incl.cov$cov.r[i], 3)),
cex = 0.7, line = 0.4)
abline(h = 0.5, lty = 2, col = gray(0.5))
abline(v = 0.5, lty = 2, col = gray(0.5))
abline(0, 1)
}
# mvQCA using Hartmann and Kemmerzell (2010)
#-------------------------------------------
data(d.HK)
head(d.HK)
# create vector of condition variables
conds <- c("C", "F", "T", "V")
# parsimonious solution, with contradictions included
HK.sp <- eqmcc(d.HK, outcome = "PB", conditions = conds,
incl.cut0 = 0.4, include = c("?", "C"), details = TRUE)
HK.sp
# Venn diagram of solution S1;
# first extract PI membership scores
PIms <- HK.sp$pims
require(VennDiagram)
vennHK.suf <- venn.diagram(
x = list(
"PB{1}" = which(d.HK$PB == 1),
"C{0,1}" = which(PIms[, 1] == 1 | PIms[, 2] == 1),
"T{2}" = which(PIms[, 4] == 1),
"T{1}*V{0}" = which(PIms[, 5] == 1)),
filename = NULL,
cex = 2.5, cat.cex = 2, cat.pos = c(180, 180, 0, 0),
cat.dist = c(0.4, 0.4, 0.12, 0.12),
fill = gray(c(0.3, 0.5, 0.7, 0.9))
)
grid.draw(vennHK.suf)
# which are the two countries in T{2} but not PB{1}?
rownames(d.HK[d.HK$T == 2 & d.HK$PB != 1, ])
# minimize contradictions (only one contradiction)
eqmcc(d.HK, outcome = "PB", conditions = conds, incl.cut0 = 0.4,
explain = "C")
# intermediate solution with directional expectations:
# C{1}, F{1,2}, T{2}, V contribute to OUT = 1
HK.si <- eqmcc(d.HK, outcome = "PB", conditions = conds,
include = "?", dir.exp = c(1, "1;2", 2, 1), details = TRUE)
HK.si
# mvQCA using Sager and Andereggen (2012)
#----------------------------------------
data(d.SA)
head(d.SA)
# directional expectation of FED{0} leads to non-simplifying
# easy counterfactual
SA.si <- eqmcc(d.SA, outcome = "ACC", conditions = names(d.SA)[1:5],
include = "?", dir.exp = c(0,1,0,1,1), details = TRUE)
SA.si
SA.si$i.sol$C1P1$NSEC
# tQCA using Ragin and Strand (2008)
#-----------------------------------
data(d.RS)
head(d.RS)
# conservative solution with details and case names;
# auxiliary temporal order condition "EBA" automatically excluded
# from parameters of fit
eqmcc(d.RS, outcome = "REC", details = TRUE, show.cases = TRUE)
# QCA path model ("causal chain" in CNA); data from Baumgartner (2009);
# note that CNA chains and QCA path models are not always equal
#--------------------------------------------------------------
d.Bau <- data.frame(U = c(1,1,1,1,0,0,0,0), D = c(1,1,0,0,1,1,0,0),
L = c(rep(1,6),0,0), G = rep(c(1,0), 4), E = c(rep(1,7),0),
row.names = letters[1:8])
head(d.Bau)
# with multiple outcomes, no solution details are printed
Bau.cna <- eqmcc(d.Bau, outcome = names(d.Bau), relation = "sufnec",
include = "?", all.sol = TRUE)
Bau.cna
# get the truth table, solution details and case names for outcome "E"
print(Bau.cna$E, details = TRUE, show.cases = TRUE)
# QCA with multiple multivalent outcome variables
#------------------------------------------------
d.mmv <- data.frame(A = c(2,0,0,1,1,1,2,2), B = c(2,2,2,2,1,1,0,0),
C = c(0,1,0,0,0,2,1,0), D = c(2,1,2,2,3,1,3,0),
E = c(3,2,3,3,0,1,3,2),
row.names = letters[1:8])
head(d.mmv)
mmv.s <- eqmcc(d.mmv, outcome = c("D{2}", "E{3}"))
mmv.s
# use quotes with curly-brackets notation
print(mmv.s$"E{3}", details = TRUE, show.cases = TRUE)
# negation of outcome from multivalent variable is union of all other values;
# many ambiguities (10 solutions)
mmv.s <- eqmcc(d.mmv, outcome = "E{3}", neg.out = TRUE, include = "?")
mmv.s
Run the code above in your browser using DataLab