condTbl: Extract conditions and solutions from an object of class...

View source: R/condTbl.r

condTblR Documentation

Extract conditions and solutions from an object of class “cna”


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.


msc(x, details = x$details)
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, ...)

as.condTbl(x, ...)



Object of class “cna”. In as.condTbl, x is a list of evaluated conditions as returned by condition. In print, x is an object returned by msc, asf, or csf.


Either TRUE/FALSE or a character vector specifying which solution attributes to print (see cna). Note that msc and asf can only display attributes that are saved in x, i.e. those that have been requested in the details argument within the call of cna.


Logical; if TRUE, a warning is issued when some attribute requested in details is not available in x (parameter for internal use).


Integer capping the amount of initial asf combinations. Default at 1000. Serves to control the computational complexity of the csf building process.


Object of class “condTbl” produced by the asf function.


Logical; if TRUE, csf are freed of structural redundancies and only csf not featuring partial structural redundancies are retained (see the fourth stage of cna's search algorithm). Defaults to x$inus.only.


Logical; if TRUE, csf are freed of structural redundancies.


Logical; if TRUE, csf featuring a cyclic substructure are not returned. FALSE by default.


Character string specifying what type of cycles to be detected: "factor" (the default) or "value" (cf. cyclic).


Logical; if TRUE, some details on the csf building process are printed. FALSE by default.


Maximal number of msc, asf, or csf to be printed.


Number of digits to print in consistency, coverage, exhaustiveness, faithfulness, and coherence scores.

quote, row.names

As in


All arguments in condTbl are passed on to condition.


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.

  1. n.init possible conjunctions featuring one asf of every outcome are built.

  2. If inus.only = TRUE or minimalizeCsf = TRUE, the solutions resulting from step 1 are freed of structural redundancies (cf. Baumgartner and Falk 2019).

  3. If inus.only = TRUE, tautologous and contradictory solutions as well as solutions with partial structural redundancies and constant factors are eliminated. [If inus.only = FALSE and minimalizeCsf = TRUE, only structural redundancies are eliminated, meaning only step 2, but not step 3, is executed.]

  4. If acyclic.only = TRUE, solutions with cyclic substructures are eliminated.

  5. For those solutions that were modified in the previous steps, consistency and coverage are re-calculated and solutions that no longer reach con or cov are eliminated.

  6. 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(...)).


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.


Falk, Christoph: development, testing


Baumgartner, Michael and Christoph Falk. 2019. “Boolean Difference-Making: A Modern Regularity Theory of Causation”. The British Journal for the Philosophy of Science.

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):1-25.

See Also

cna, configTable, condition, minimalizeCsf, d.irrigate


# Crisp-set 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 
# cut-off at 0.9 (consistency cut-off at 1).
cna.irrigate <- cna(d.irrigate, ordering = "A, R, F, L, C < W", cov = .9,
                    maxstep = c(4, 4, 12), details = TRUE)

# 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.
# With only the standard attributes plus exhaustiveness and faithfulness.
csf(cna.irrigate, details = c("e", "f"))

# Extract all atomic solution formulas.

# Extract all minimally sufficient conditions.
msc(cna.irrigate) # capped at 20 rows
print(msc(cna.irrigate), n = Inf) # prints all rows

# Extract only the conditions (solutions).

# 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(1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1),
                   B = c(1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 1, 0, 0, 1, 0, 1),
                   C = c(1, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 0),
                   D = c(1, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0),
                   E = c(0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0),
                   F = c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0))
ana2 <- cna(dat2, con = .8, cov = .8, maxstep = c(3, 4, 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)
# 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.
condition(msc(ana2)$condition, dat2)
condition(asf(ana2)$condition, dat2)
condition(csf(ana2)$condition, dat2)

# 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.
as.condTbl(condition(msc(ana2)$condition, dat2))
as.condTbl(condition(asf(ana2)$condition, dat2))
as.condTbl(condition(csf(ana2)$condition, dat2))

condTbl(csf(ana2)$condition, dat2) # Same as preceding line

cna documentation built on Aug. 11, 2023, 1:09 a.m.