condTbl {cna}  R Documentation 
Extract conditions and solutions from an object of class “cna”
Description
Given a solution object x
produced by cna
, msc(x)
extracts all minimally sufficient conditions, asf(x)
all atomic solution formulas, and csf(x, n.init)
builds approximately n.init
complex solution formulas. All solution attributes (details
) that are saved in x
are recovered as well. The three functions return a data frame with the additional class attribute condTbl
.
as.condTbl
reshapes the output produced by condition
in such a way as to make it identical to the output returned by msc
, asf
, and csf
.
condTbl
executes condition
and returns a concise summary table featuring consistencies and coverages.
Usage
msc(x, details = x$details, cases = FALSE)
asf(x, details = x$details, warn_details = TRUE)
csf(x, n.init = 1000, details = x$details,
asfx = asf(x, details, warn_details = FALSE),
inus.only = x$inus.only, minimalizeCsf = inus.only,
acyclic.only = x$acyclic.only, cycle.type = x$cycle.type,
verbose = FALSE)
## S3 method for class 'condTbl'
print(x, n = 20, digits = 3, quote = FALSE, row.names = TRUE, ...)
## S3 method for class 'condTbl'
as.data.frame(x, ...)
condTbl(...)
as.condTbl(x, ...)
Arguments
x 
Object of class “cna”. In 
details 
Either 
cases 
Logical; if 
warn_details 
Logical; if 
n.init 
Integer capping the amount of initial asf combinations. Default at 1000. Serves to control the computational complexity of the csf building process. 
asfx 
Object of class “condTbl” produced by the 
inus.only 
Either 
minimalizeCsf 
Logical; if 
acyclic.only 
Logical; if 
cycle.type 
Character string specifying what type of cycles to be detected: 
verbose 
Logical; if 
n 
Maximal number of msc, asf, or csf to be printed. 
digits 
Number of digits to print in consistency, coverage, exhaustiveness, faithfulness, and coherence scores. 
quote , row.names 
As in 
... 
All arguments in 
Details
Depending on the processed data, the solutions (models) output by cna
are often ambiguous, to the effect that many atomic and complex solutions fit the data equally well. To facilitate the inspection of the cna
output, however, the latter standardly returns only 5 minimally sufficient conditions (msc), 5 atomic solution formulas (asf), and 5 complex solution formulas (csf) for each outcome. msc
can be used to extract all msc from an object x
of class “cna”, asf
to extract all asf, and csf
to build approximately n.init
csf from the asf stored in x
. All solution attributes (details
) that are saved in x
are recovered as well.
The outputs of msc
, asf
, and csf
can be further processed by the condition
function.
While msc
and asf
merely extract information stored in x
, csf
builds csf from the inventory of asf recovered at the end of the third stage of the cna
algorithm. That is, the csf
function implements the fourth stage of that algorithm. It proceeds in a stepwise manner as follows.

n.init
possible conjunctions featuring one asf of every outcome are built. If
inus.only = TRUE
orminimalizeCsf = TRUE
, the solutions resulting from step 1 are freed of structural redundancies (cf. Baumgartner and Falk 2023).If
inus.only = TRUE
, tautologous and contradictory solutions as well as solutions with partial structural redundancies and constant factors are eliminated. [Ifinus.only = FALSE
andminimalizeCsf = TRUE
, only structural redundancies are eliminated, meaning only step 2, but not step 3, is executed.]If
acyclic.only = TRUE
, solutions with cyclic substructures are eliminated.For those solutions that were modified in the previous steps, consistency and coverage are recalculated and solutions that no longer reach
con
orcov
are eliminated.The remaining solutions are returned as csf, ordered by complexity and the product of consistency and coverage.
The argument digits
applies to the print
method. It determines how many digits of consistency, coverage, exhaustiveness, faithfulness, and coherence scores are printed. The default value is 3.
The function as.condTbl
takes a list of objects of class “cond” that are returned by the condition
function as input, and reshapes these objects in such a way as to make them identical to the output returned by msc
, asf
, and csf
.
condTbl(...)
is identical with as.condTbl(condition(...))
.
Value
msc
, asf
, csf
, and as.condTbl
return objects of class “condTbl”, a data.frame
which features the following components:
outcome :  the outcomes 
condition :  the relevant conditions or solutions 
consistency :  the consistency scores 
coverage :  the coverage scores 
complexity :  the complexity scores 
inus :  whether the solutions have INUS form 
exhaustiveness :  the exhaustiveness scores 
faithfulness :  the faithfulness scores 
coherence :  the coherence scores 
redundant :  whether the csf contain redundant proper parts 
cyclic :  whether the csf contain cyclic substructures 
The latter five measures are optional and will be appended to the table according to the setting of the argument details
.
Contributors
Falk, Christoph: development, testing
References
Baumgartner, Michael and Christoph Falk. 2023. “Boolean DifferenceMaking: A Modern Regularity Theory of Causation”. The British Journal for the Philosophy of Science, 74(1), 171197.
Lam, Wai Fung, and Elinor Ostrom. 2010. “Analyzing the Dynamic Complexity of Development Interventions: Lessons from an Irrigation Experiment in Nepal.” Policy Sciences 43 (2):125.
See Also
cna
, configTable
, condition
, minimalizeCsf
, d.irrigate
Examples
# Crispset data from Lam and Ostrom (2010) on the impact of development interventions
# 
# CNA with causal ordering that corresponds to the ordering in Lam & Ostrom (2010); coverage
# cutoff at 0.9 (consistency cutoff at 1).
cna.irrigate < cna(d.irrigate, ordering = "A, R, F, L, C < W", cov = .9,
maxstep = c(4, 4, 12), details = TRUE)
cna.irrigate
# The previous function call yields a total of 12 complex solution formulas, only
# 5 of which are returned in the default output.
# Here is how to extract all 12 complex solution formulas along with all
# solution attributes.
csf(cna.irrigate)
# With only the standard attributes plus exhaustiveness and faithfulness.
csf(cna.irrigate, details = c("e", "f"))
# Extract all atomic solution formulas.
asf(cna.irrigate)
# Extract all minimally sufficient conditions.
msc(cna.irrigate) # capped at 20 rows
print(msc(cna.irrigate), n = Inf) # prints all rows
# Add cases featuring the minimally sufficient conditions combined
# with the outcome.
(msc.table < msc(cna.irrigate, cases = TRUE))
# Render as data frame.
as.data.frame(msc.table)
# Extract only the conditions (solutions).
csf(cna.irrigate)$condition
asf(cna.irrigate)$condition
msc(cna.irrigate)$condition
# A CNA of d.irrigate without outcome specification and ordering is even more
# ambiguous.
cna2.irrigate < cna(d.irrigate, cov = .9, maxstep = c(4,4,12), details = TRUE)
# To speed up the construction of complex solution formulas, first extract asf
# and then pass these asf to csf.
cna2.irrigate.asf < asf(cna2.irrigate)
csf(cna2.irrigate, asfx = cna2.irrigate.asf, details = FALSE)
# Reduce the initial asf combinations.
csf(cna2.irrigate, asfx = cna2.irrigate.asf, n.init = 50)
# Print the first 20 csf.
csf(cna2.irrigate, asfx = cna2.irrigate.asf, n.init = 50)[1:20, ]
# Also extract exhaustiveness scores.
csf(cna2.irrigate, asfx = cna2.irrigate.asf, n.init = 50,
details = "e")[1:20, ]
# Print details about the csf building process.
csf(cna.irrigate, verbose = TRUE)
# Return solution attributes with 5 digits.
print(cna2.irrigate.asf, digits = 5)
# Further examples
# 
# An example generating structural redundancies.
target < "(A*B + C <> D)*(c + a <> E)"
dat1 < selectCases(target)
ana1 < cna(dat1, maxstep = c(3, 4, 10))
# Run csf with elimination of structural redundancies.
csf(ana1, verbose = TRUE)
# Run csf without elimination of structural redundancies.
csf(ana1, verbose = TRUE, inus.only = FALSE)
# An example generating partial structural redundancies.
dat2 < data.frame(A=c(0,0,0,0,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,0,
1),B=c(0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1),C=c(1,
1,0,0,0,1,0,0,1,1,0,1,1,0,1,1,0,1,1,1,0,1,0,1,0,1,0),D=c(0,1,1,1,
0,1,1,1,0,0,0,1,0,1,0,0,0,1,0,0,0,1,1,0,0,1,0),E=c(1,0,0,0,0,1,1,
1,1,1,1,0,0,1,0,0,0,1,1,1,1,0,0,0,0,1,1),F=c(1,1,1,1,1,0,0,0,0,0,
0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0),G=c(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,1,1))
ana2 < cna(dat2, con = .8, cov = .8, maxstep = c(3, 3, 10))
# Run csf without elimination of partial structural redundancies.
csf(ana2, inus.only = FALSE, verbose = TRUE)
# Run csf with elimination of partial structural redundancies.
csf(ana2, verbose = TRUE)
# Prior to version 3.6.0, the "equivalence" definition of partial structural
# redandancy was used by default (see ?is.inus() for details). Now, the
# "implication" definition is used. To replicate old behavior
# set inus.only to "equivalence".
csf(ana2, verbose = TRUE, inus.only = "equivalence")
# The two definitions only come apart in case of cyclic structures.
# Build only acyclic models.
csf(ana2, verbose = TRUE, acyclic.only = TRUE)
# Feed the outputs of msc, asf, and csf into the condition function to further inspect the
# properties of minimally sufficient conditions and atomic and complex solution formulas.
head(condition(msc(ana2)$condition, dat2), 3) # (showing output for first 3 only)
head(condition(asf(ana2)$condition, dat2), 3)
head(condition(csf(ana2)$condition, dat2), 3)
# Reshape the output of the condition function in such a way as to make it identical to the
# output returned by msc, asf, and csf.
head(condition(msc(ana2)$condition, dat2), 3)
head(condition(asf(ana2)$condition, dat2), 3)
head(condition(csf(ana2)$condition, dat2), 3)
head(condTbl(csf(ana2)$condition, dat2), 3) # Same as preceding line