Learn R Programming

TSQCA (version 1.0.0)

ctSweepS: CTS–QCA: Single-condition threshold sweep

Description

Performs a threshold sweep for one focal condition X. For each threshold in sweep_range, the outcome Y and all X variables are binarized using user-specified thresholds, and a crisp-set QCA is executed.

Usage

ctSweepS(
  dat,
  outcome = NULL,
  conditions = NULL,
  sweep_var,
  sweep_range,
  thrY,
  thrX_default = 7,
  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:

  • threshold — swept threshold for sweep_var

  • 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-threshold list of threshold, 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_var

Character. Name of the condition to be swept. Must be one of conditions.

sweep_range

Numeric vector. Candidate thresholds for sweep_var.

thrY

Numeric. Threshold for Y (fixed).

thrX_default

Numeric. Default threshold for non-swept X variables.

dir.exp

Optional named numeric vector of directional expectations for minimize. If NULL, all set to 1.

include

Inclusion rule for minimize (e.g., "?").

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)

# Run single condition threshold sweep on X3 (standard)
result <- ctSweepS(
  dat = sample_data,
  outcome = "Y",
  conditions = c("X1", "X2", "X3"),
  sweep_var = "X3",
  sweep_range = 6:8,
  thrY = 7,
  thrX_default = 7
)
head(result$summary)

# Run with negated outcome (~Y)
result_neg <- ctSweepS(
  dat = sample_data,
  outcome = "~Y",
  conditions = c("X1", "X2", "X3"),
  sweep_var = "X3",
  sweep_range = 6:8,
  thrY = 7,
  thrX_default = 7
)
head(result_neg$summary)

Run the code above in your browser using DataLab