Learn R Programming

automatedtests (version 0.1.2)

automatical_test: 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)

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.

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 \(1/k\), where \(k\) is the number of categories, assuming a uniform distribution. If numeric, the default will be 0.

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.

Author

Wouter Zeevat

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:

IDTest
1One-proportion test
2Chi-square goodness-of-fit test
3One-sample Student's t-test
4One-sample Wilcoxon test
5Multiple linear regression
6Binary logistic regression
7Multinomial logistic regression
8Pearson correlation
9Spearman's rank correlation
10Cochran's Q test
11McNemar's test
12Fisher's exact test
13Chi-square test of independence
14Student's t-test for independent samples
15Welch's t-test for independent samples
16Mann-Whitney U test
17Student's t-test for paired samples
18Wilcoxon signed-rank test
19One-way ANOVA
20Welch's ANOVA
21Repeated measures ANOVA
22Kruskal-Wallis test
23Friedman test

See Also

AutomatedTest for the class used by this function.

Examples

Run this code
  # 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()

Run the code above in your browser using DataLab