| ctSweepS | R Documentation |
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.
ctSweepS(
dat,
outcome = NULL,
conditions = NULL,
sweep_var,
sweep_range,
thrY,
thrX_default = 7,
pre_calibrated = NULL,
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
)
dat |
Data frame containing the outcome and condition variables. |
outcome |
Character. Outcome variable name. Supports negation with
tilde prefix (e.g., |
conditions |
Character vector. Names of condition variables. |
sweep_var |
Character. Name of the condition to be swept.
Must be one of |
sweep_range |
Numeric vector. Candidate thresholds for |
thrY |
Numeric. Threshold for Y (fixed). |
thrX_default |
Numeric. Default threshold for non-swept X variables.
Variables listed in |
pre_calibrated |
Character vector or |
dir.exp |
Directional expectations for |
include |
Inclusion rule for |
incl.cut |
Consistency cutoff for |
n.cut |
Frequency cutoff for |
pri.cut |
PRI cutoff for |
extract_mode |
Character. How to handle multiple solutions:
|
return_details |
Logical. If |
Yvar |
Deprecated. Use |
Xvars |
Deprecated. Use |
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
# Load sample data
data(sample_data)
# === Three Types of QCA Solutions ===
# 1. Complex Solution (default, QCA compatible)
result_comp <- ctSweepS(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2", "X3"),
sweep_var = "X3",
sweep_range = 7,
thrY = 7,
thrX_default = 7
# include = "" (default), dir.exp = NULL (default)
)
head(result_comp$summary)
# 2. Parsimonious Solution (include = "?")
result_pars <- ctSweepS(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2", "X3"),
sweep_var = "X3",
sweep_range = 7,
thrY = 7,
thrX_default = 7,
include = "?" # Include logical remainders
)
head(result_pars$summary)
# 3. Intermediate Solution (include = "?" + dir.exp)
result_int <- ctSweepS(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2", "X3"),
sweep_var = "X3",
sweep_range = 7,
thrY = 7,
thrX_default = 7,
include = "?",
dir.exp = c(1, 1, 1) # All conditions expected positive
)
head(result_int$summary)
# === Threshold Sweep Example ===
# Run single condition threshold sweep on X3 (complex solutions by default)
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.