# NOT RUN {
# Manual input of cs data
# -----------------------
dat1 <- data.frame(
A = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0),
B = c(1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0),
C = c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0),
D = c(1,1,1,1,0,0,0,0,1,1,1,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0,0,0),
E = c(1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,0,0,0)
)
# Default return of the truthTab function.
truthTab(dat1)
# Recovering the cases featuring each configuration by means of the print function.
print(truthTab(dat1), show.cases = TRUE)
# The same truth table as before can be generated by using the frequency argument while
# listing each configuration only once.
dat1 <- data.frame(
A = c(1,1,1,1,1,1,0,0,0,0,0),
B = c(1,1,1,0,0,0,1,1,1,0,0),
C = c(1,1,1,1,1,1,1,1,1,0,0),
D = c(1,0,0,1,0,0,1,1,0,1,0),
E = c(1,1,0,1,1,0,1,0,1,1,0)
)
truthTab(dat1, frequency = c(4,3,1,3,4,1,10,1,3,3,3))
# Set (random) case labels.
print(truthTab(dat1, .cases = sample(letters, nrow(dat1), replace = FALSE)),
show.cases = TRUE)
# Truth tables generated by truthTab can be input into the cna function.
dat1.tt <- truthTab(dat1, frequency = c(4,3,1,3,4,1,4,1,3,3,3))
# }
# NOT RUN {
cna(dat1.tt, con = .85, details = TRUE)
# }
# NOT RUN {
# By means of the case.cutoff argument configurations with less than 2 cases can
# be excluded (which yields perfect consistency and coverage scores for dat1).
dat1.tt <- truthTab(dat1, frequency = c(4,3,1,3,4,1,4,1,3,3,3), case.cutoff = 2)
# }
# NOT RUN {
cna(dat1.tt, details = TRUE)
# }
# NOT RUN {
# Simulating multi-value data with biased samples (exponential distribution)
# --------------------------------------------------------------------------
dat1 <- allCombs(c(3,3,3,3,3))
set.seed(32)
m <- nrow(dat1)
wei <- rexp(m)
dat2 <- dat1[sample(nrow(dat1), 100, replace = TRUE, prob = wei),]
truthTab(dat2, type = "mv") # 100 cases with 46 configurations instantiated only once.
mvtt(dat2, case.cutoff = 2) # removing the single instances.
# Duplicated factors are not eliminated, constant factors are not eliminated.
dat3 <- selectCases("(A=1+A=2+A=3 <-> C=2)*(B=3<->D=3)*(B=2<->D=2)*(A=2 + B=1 <-> E=2)",
dat1, type = "mv")
# }
# NOT RUN {
mvtt(dat3, rm.dup.factors = FALSE, rm.const.factors = FALSE)
# }
# NOT RUN {
# truthTab with fuzzy-set data from Aleman (2009)
# -----------------------------------------------
# Include all cases.
tt.pacts <- fstt(d.pacts)
# }
# NOT RUN {
fscna(tt.pacts, con = .93, cov = .86, details = TRUE)
# }
# NOT RUN {
# Only include configurations with at least 3 cases.
tt.pacts2 <- fstt(d.pacts, case.cutoff = 3)
# }
# NOT RUN {
fscna(tt.pacts2, con = .93, cov = .86, details = TRUE)
# }
# NOT RUN {
# Large-N data with crisp sets from Greckhamer et al. (2008)
#-----------------------------------------------------------
truthTab(d.performance[1:8], frequency = d.performance$frequency)
# Eliminate configurations with less than 5 cases.
truthTab(d.performance[1:8], frequency = d.performance$frequency, case.cutoff = 5)
# Various large-N CNAs of d.performance with varying case cut-offs.
# }
# NOT RUN {
cna(truthTab(d.performance[1:8], frequency = d.performance$frequency, case.cutoff = 4),
ordering = list("SP"), con = .75, cov = .6)
cna(truthTab(d.performance[1:8], frequency = d.performance$frequency, case.cutoff = 5),
ordering = list("SP"), con = .75, cov = .6)
cna(truthTab(d.performance[1:8], frequency = d.performance$frequency, case.cutoff = 10),
ordering = list("SP"), con = .75, cov = .6)
print(cna(truthTab(d.performance[1:8], frequency = d.performance$frequency, case.cutoff = 15),
ordering = list("SP"), con = .75, cov = .6, what = "a"), nsolutions = "all")
# }
Run the code above in your browser using DataLab