| f_stat_wizard | R Documentation |
Analyzes your data structure based on a formula and recommends the appropriate statistical test. Checks variable types, normality of residuals, homogeneity of variance, and checks if f_boxcox transformation can fix non-normality. Recommends rfriend functions as primary code, with base R alternatives shown as fallback.
Supports standard formulas including y ~ ., y ~ as.factor(x), and interaction
terms. Formulas with random effects (e.g. (1|ID)) are detected and handled separately.
Multivariate responses (e.g. cbind(y1, y2) ~ x) and transformed responses
(e.g. log(y) ~ x) are not supported.
f_stat_wizard(x, ...)
## S3 method for class 'formula'
f_stat_wizard(
formula,
data,
id_col = NULL,
run = FALSE,
plots = FALSE,
output_type = "word",
interactive = FALSE,
data_name = NULL,
...
)
## S3 method for class 'data.frame'
f_stat_wizard(
x,
formula,
id_col = NULL,
run = FALSE,
plots = FALSE,
output_type = "word",
interactive = FALSE,
data_name = NULL,
...
)
x |
A formula (e.g., |
... |
Additional arguments (currently unused). |
formula |
A formula specifying the relationship (used with the data.frame method). |
data |
A data frame containing the variables referenced in the formula. |
id_col |
Character string. Name of the column identifying subjects/blocks
for paired or repeated-measures designs. When supplied, the wizard (a) verifies
the pairing structure (each subject should appear in every group exactly once),
(b) treats the design as paired/repeated measures, and (c) embeds the real column
name into the generated code. Omit for independent-samples designs. Default |
run |
Logical. If |
plots |
Logical. If |
output_type |
Character string specifying the output format of the
recommended rfriend function (when |
interactive |
Logical. If |
data_name |
Character string to name the data base used. Default |
An object of class "f_stat_wizard": a list containing:
The formula used.
Character string of the formula.
Name of the data object as passed by the user.
Effective sample size (after NA removal).
Number of rows removed due to missing values.
Logical. Whether a paired/repeated-measures design was detected (via id_col).
Character. Name of the subject/block column supplied, or NULL.
Name of the response variable.
Detected type of the response: "binary", "count",
"multinomial", "ratio_normal", "ratio_non_normal",
"ratio_unknown", or "unsupported".
Character vector of explanatory variable names.
Character vector of detected types ("nominal",
"ordinal", "ratio").
Number of groups (for single categorical X), or NULL.
Table of per-group sample sizes, or NULL.
Logical. TRUE if the model mixes nominal and ratio predictors.
Logical. TRUE if interaction terms were detected.
A list with p_value (Shapiro-Wilk) and is_normal (logical or NA).
A list with test_used ("Levene" or "Bartlett"),
p_value, and is_equal (logical).
A list with attempted (logical), can_fix (logical),
and p_value_after (numeric or NA).
A list with is_overdispersed (logical, from
DHARMa dispersion test) and p_value. Only meaningful for count data.
A language object representing the rfriend function call,
or NULL if no single function could be determined.
The result of executing the recommended test (when run=TRUE),
or NULL.
A recordedplot from f_hist() (when plots=TRUE),
or NULL.
A recordedplot from f_qqnorm() of model residuals
(when plots=TRUE and Y is continuous), or NULL.
Character vector of the human-readable report lines (used by
print.f_stat_wizard).
# Formula interface (recommended)
f_stat_wizard(Sepal.Length ~ Species, data = iris)
# Data-first interface (backward compatible)
f_stat_wizard(iris, Sepal.Length ~ Species)
# Paired design -- supply the id_col that identifies matched subjects
f_stat_wizard(extra ~ group, data = sleep, id_col = "ID")
# With diagnostic plots
f_stat_wizard(Sepal.Length ~ Species, data = iris, plots = TRUE)
# Run the recommended test directly
result <- f_stat_wizard(Sepal.Length ~ Species, data = iris, run = TRUE)
result$run_result
# Inspect metadata
result <- f_stat_wizard(Sepal.Length ~ Species, data = iris)
result$y_type
result$normality
result$group_sizes
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.