View source: R/tsqca_ots_dts.R
| dtSweep | R Documentation |
Sweeps thresholds for multiple X variables and the outcome Y jointly. For each combination of X thresholds and each candidate Y threshold, the data are binarized and a crisp-set QCA is executed.
dtSweep(
dat,
outcome = NULL,
conditions = NULL,
sweep_list_X,
sweep_range_Y,
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_list_X |
Named list. Each element is a numeric vector of
candidate thresholds for the corresponding X. Variables listed in
|
sweep_range_Y |
Numeric vector. Candidate thresholds for Y. |
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:
combo_id — index of threshold combination
thrY — threshold for Y
thrX — character summary of X thresholds
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 — list of runs with
combo_id, thrY, thrX_vec,
truth_table, solution
# Load sample data
data(sample_data)
# === Three Types of QCA Solutions ===
# Quick demonstration with 2 conditions
sweep_list_X <- list(X1 = 7, X2 = 7)
sweep_range_Y <- 7
# 1. Complex Solution (default, QCA compatible)
result_comp <- dtSweep(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2"),
sweep_list_X = sweep_list_X,
sweep_range_Y = sweep_range_Y
# include = "" (default), dir.exp = NULL (default)
)
head(result_comp$summary)
# 2. Parsimonious Solution (include = "?")
result_pars <- dtSweep(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2"),
sweep_list_X = sweep_list_X,
sweep_range_Y = sweep_range_Y,
include = "?" # Include logical remainders
)
head(result_pars$summary)
# 3. Intermediate Solution (include = "?" + dir.exp)
result_int <- dtSweep(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2"),
sweep_list_X = sweep_list_X,
sweep_range_Y = sweep_range_Y,
include = "?",
dir.exp = c(1, 1) # Positive expectations
)
head(result_int$summary)
# === Threshold Sweep Example ===
# Using 2 conditions and 2 threshold levels
sweep_list_X <- list(
X1 = 6:7,
X2 = 6:7
)
sweep_range_Y <- 6:7
# Run dual threshold sweep (complex solutions by default)
result_quick <- dtSweep(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2"),
sweep_list_X = sweep_list_X,
sweep_range_Y = sweep_range_Y
)
head(result_quick$summary)
# Full analysis with 3 conditions (81 combinations)
sweep_list_X_full <- list(
X1 = 6:8,
X2 = 6:8,
X3 = 6:8
)
sweep_range_Y_full <- 6:8
result_full <- dtSweep(
dat = sample_data,
outcome = "Y",
conditions = c("X1", "X2", "X3"),
sweep_list_X = sweep_list_X_full,
sweep_range_Y = sweep_range_Y_full
)
head(result_full$summary)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.