automatical_test {automatedtests} | R Documentation |
Automatically Run a Statistical Test
Description
Automatically choose the best fitting statistical test for your data, and returns an easily readable AutomatedTest
object from either a data frame or individual vectors. This object contains the executed test together with all statistics and properties.
Usage
automatical_test(..., compare_to = NULL, identifiers = FALSE, paired = FALSE)
Arguments
... |
Either a single data frame or multiple equal-length vectors representing columns of data. |
compare_to |
A numeric value to compare against during a one-sample test.
If the data is categorical, the value will default to |
identifiers |
Logical; if TRUE, the first column/vector is treated as identifiers and excluded from testing. |
paired |
Logical; if TRUE, the test will be performed as paired if applicable, regardless of whether identifiers are provided. This applies to paired tests like McNemar's or the Cochran Q test. |
Details
The automatical_test
function automatically selects and runs the most fitting statistical test based on the data provided.
It can accept data as either a single data frame or multiple individual vectors, provided the vectors are of equal length.
If identifiers
is set to TRUE, the first column will be treated as identifiers and excluded from the test, supporting TIDY data.
When a multiple group test is selected (i.e., more than two groups, columns, or variables are used), the first non-identifier column will be used as the grouping or target variable, meaning all other variables will be tested against it.
The paired
parameter can be used to force paired testing for supported tests (such as McNemar's test or Cochran's Q),
even if identifiers are not explicitly included in the input.
If you want to override the defaults, you can change the compare_to
value to specify one-sample tests.
Once the test has been executed, you can use the method $get_result()
on the resulting object to get more detailed information about the test's execution, including a summary of the test used and all statistics.
Supported tests:
ID | Test |
1 | One-proportion test |
2 | Chi-square goodness-of-fit test |
3 | One-sample Student's t-test |
4 | One-sample Wilcoxon test |
5 | Multiple linear regression |
6 | Binary logistic regression |
7 | Multinomial logistic regression |
8 | Pearson correlation |
9 | Spearman's rank correlation |
10 | Cochran's Q test |
11 | McNemar's test |
12 | Fisher's exact test |
13 | Chi-square test of independence |
14 | Student's t-test for independent samples |
15 | Welch's t-test for independent samples |
16 | Mann-Whitney U test |
17 | Student's t-test for paired samples |
18 | Wilcoxon signed-rank test |
19 | One-way ANOVA |
20 | Welch's ANOVA |
21 | Repeated measures ANOVA |
22 | Kruskal-Wallis test |
23 | Friedman test |
Value
An object of class AutomatedTest
.
The object contains the results of the statistical test performed on the data.
You can use the method $get_result()
to obtain more detailed information about the execution of the test.
Author(s)
Wouter Zeevat
See Also
AutomatedTest
for the class used by this function.
Examples
# Example 1: Using individual vectors
test1 <- automatical_test(iris$Species, iris$Sepal.Length, identifiers = FALSE)
# Example 2: Forcing a paired test
before <- c(200, 220, 215, 205, 210)
after <- c(202, 225, 220, 210, 215)
paired_data <- data.frame(before, after)
test2 <- automatical_test(before, after, paired = TRUE)
# Retrieve more detailed information about the test
# test1$get_result()