Learn R Programming

TSQCA (version 1.0.0)

ctSweepM: MCTS–QCA: Multi-condition threshold sweep

Description

Performs a grid search over thresholds of multiple X variables. For each combination of thresholds in sweep_list, the outcome Y and all X variables are binarized, and a crisp-set QCA is executed.

Usage

ctSweepM(
  dat,
  outcome = NULL,
  conditions = NULL,
  sweep_list,
  thrY,
  dir.exp = NULL,
  include = "?",
  incl.cut = 0.8,
  n.cut = 1,
  pri.cut = 0,
  extract_mode = c("first", "all", "essential"),
  return_details = TRUE,
  Yvar = NULL,
  Xvars = NULL
)

Value

If return_details = FALSE, a data frame with columns:

  • combo_id — index of the threshold combination

  • threshold — character string summarizing thresholds, e.g. "X1=6, X2=7, X3=7"

  • expression — minimized solution expression

  • inclS — solution consistency

  • covS — solution coverage

  • (additional columns depending on extract_mode)

If return_details = TRUE, a list with:

  • summary — the data frame above

  • details — per-combination list of combo_id, thrX_vec, truth_table, solution

Arguments

dat

Data frame containing the outcome and condition variables.

outcome

Character. Outcome variable name. Supports negation with tilde prefix (e.g., "~Y") following QCA package conventions.

conditions

Character vector. Names of condition variables.

sweep_list

Named list. Each element is a numeric vector of candidate thresholds for the corresponding X. Names must match conditions.

thrY

Numeric. Threshold for Y (fixed).

dir.exp

Directional expectations for minimize. If NULL, all set to 1.

include

Inclusion rule for minimize.

incl.cut

Consistency cutoff for truthTable.

n.cut

Frequency cutoff for truthTable.

pri.cut

PRI cutoff for minimize.

extract_mode

Character. How to handle multiple solutions: "first" (default), "all", or "essential". See qca_extract for details.

return_details

Logical. If TRUE (default), returns both summary and detailed objects for use with generate_report().

Yvar

Deprecated. Use outcome instead.

Xvars

Deprecated. Use conditions instead.

Examples

Run this code
# Load sample data
data(sample_data)

# Quick demonstration with 2 conditions (< 5 seconds)
# This explores 2^2 = 4 threshold combinations
sweep_list <- list(
  X1 = 6:7,  # Reduced from 6:8 to 6:7
  X2 = 6:7   # Reduced from 6:8 to 6:7
)

# Run multiple condition threshold sweep with reduced parameters (standard)
result_quick <- ctSweepM(
  dat = sample_data,
  outcome = "Y",
  conditions = c("X1", "X2"),  # Reduced from 3 to 2 conditions
  sweep_list = sweep_list,
  thrY = 7
)
head(result_quick$summary)

# Run with negated outcome (~Y)
result_neg <- ctSweepM(
  dat = sample_data,
  outcome = "~Y",
  conditions = c("X1", "X2"),
  sweep_list = sweep_list,
  thrY = 7
)
head(result_neg$summary)

# \donttest{
# Full multi-condition analysis with 3 conditions
# This explores 3^3 = 27 threshold combinations (takes ~5-8 seconds)
sweep_list_full <- list(
  X1 = 6:8,
  X2 = 6:8,
  X3 = 6:8
)

result_full <- ctSweepM(
  dat = sample_data,
  outcome = "Y",
  conditions = c("X1", "X2", "X3"),
  sweep_list = sweep_list_full,
  thrY = 7
)

# Visualize threshold-dependent solution paths
head(result_full$summary)
# }

Run the code above in your browser using DataLab