Title: | Fully Parameterizable ANOVA Tests |
Version: | 0.1.2 |
Description: | Allows the user to perform ANOVA tests (in a strict sense: continuous and normally-distributed Y variable and 1 or more factorial/categorical X variable(s)), with the possibility to specify the type of sum of squares (1, 2 or 3), the types of variables (Fixed or Random) and their relationships (crossed or nested) with the sole function of the package (FullyParamANOVA()). The resulting outputs are the same as in 'SAS' software. A dataset (Butterfly) to test the function is also joined. |
License: | MIT + file LICENSE |
Encoding: | UTF-8 |
RoxygenNote: | 7.2.3 |
Imports: | dplyr (≥ 1.1.2), magrittr (≥ 2.0.3), mlr3misc (≥ 0.16.0), rlang (≥ 1.1.1), rstatix (≥ 0.7.2), stats (≥ 4.2.1), tibble (≥ 3.2.1) |
Depends: | R (≥ 3.5) |
LazyData: | true |
NeedsCompilation: | no |
Packaged: | 2025-03-05 15:12:48 UTC; vbrans |
Author: | Victor Brans |
Maintainer: | Victor Brans <vicbrans003@gmail.com> |
Repository: | CRAN |
Date/Publication: | 2025-03-07 11:30:15 UTC |
ParamANOVA: Fully Parameterizable ANOVA Tests
Description
Allows the user to perform ANOVA tests (in a strict sense: continuous and normally-distributed Y variable and 1 or more factorial/categorical X variable(s)), with the possibility to specify the type of sum of squares (1, 2 or 3), the types of variables (Fixed or Random) and their relationships (crossed or nested) with the sole function of the package (FullyParamANOVA()). The resulting outputs are the same as in 'SAS' software. A dataset (Butterfly) to test the function is also joined.
Author(s)
Maintainer: Victor Brans vicbrans003@gmail.com (ORCID)
Wingspans of butterflies in different sites
Description
Imaginary data set of wingspans (in cm) of butterflies in different patches of different sites
Usage
data("Butterfly")
Format
A data frame with 300 observations of the following 4 variables.
Sex
a character vector: M=males; F=Females
Site
a numeric vector: 3 different sites
Patch
a numeric vector: 5 patches per site
Wingspan
a numeric vector
Source
Data created by Estelle Laurent
References
Data created by Estelle Laurent
Fully Parameterizable ANOVA test
Description
Function allowing the user to perform ANOVA tests (in a strict sense: one continuous and normally-distributed response variable and one or more factorial/categorical explaining variable(s)), with the possibility to specify the type of sum of squares (1, 2 or 3), the types of variables (Fixed or Random) and their relationships (crossed or nested). This function is built on the '?rstatix::anova_test()'.The resulting ouptuts are the same as in 'SAS' software.
Usage
FullyParamANOVA(
InputData,
form,
variables_type = NULL,
variables_relationships = c(NA),
sig_threshold = 0.05,
sum_of_squares = 3,
print_ges = FALSE,
output_table_only = FALSE
)
Arguments
InputData |
The name of the input dataset. |
form |
To be written as Response variable ~ Explaining variable(s). If there are multiple Explaining variables, they should be separated by a *. |
variables_type |
Type of variables in a vector. One argument per Explaining variable, in the same order as in the formula: 'Fxd' for Fixed variables, or 'Rndm' for Random variables. |
variables_relationships |
Relationships between variables in a vector. One argument per Explaining variable, in the same order as in the formula: NA if the variable is not nested in any other variable, or the name of the variable it is nested into. |
sig_threshold |
The threshold below which a p-value is considered significant. By default, it is set to the usual value of 0.05. |
sum_of_squares |
Type of sum of squares used in the test: 1, 2 or 3. These numbers correspond to those in 'SAS' software. By default, the type 3 is used as it is the most often recommended one. |
print_ges |
If TRUE, prints effect sizes (ges = generalized eta squared) in the result table. See '?rstatix::anova_test()' for more details. It is FALSE by default. |
output_table_only |
If TRUE, reports only the result table and not the text below specifying the parameters used for the test, allowing for the output table to be directly usable or stored in an object for example. It is FALSE by default. |
Value
ANOVA result table.
There is one row per effect tested and a last row for the residuals.
The first column ("Effect") specifies the effects tested.
The second column ("SS") gives the Sum of Squares associated with the effects tested.
The third column ("DF") gives the Degrees of Freedom associated with the effects tested.
The fourth column ("MSS") gives the Mean Sum of Squares (=SS/DF) associated with the effects tested.
The fifth column ("Fval") gives the F statistic value associated with the effects tested.
The sixth column ("pval") gives the p-value associated with the effects tested.
The seventh column ("Sig") shows a star if the associated p-value is below the statistical threshold of 0.05 by default or the one indicated during the call of the function for each effects tested.
The optional eighth column ("ges") gives the effect sizes (ges = generalized eta squared) associated with the effects tested.
If the argument output_table_only is FALSE (which is the case by default), the function also specifies below this result table which types of Sum of Squares were used, and if there are at least two factors, it specifies which factors were fixed or random and finally the relationships between these factors.
You will find warnings below if the setup is not appropriate.
Examples
data("Butterfly")
# Example of ANOVA I
FullyParamANOVA(InputData=Butterfly, form=Wingspan~Site, variables_type = c('Fxd'))
# Example of ANOVA II
FullyParamANOVA(InputData=Butterfly, form=Wingspan~Patch*Site,
variables_type = c('Rndm','Fxd'), variables_relationships = c("Site",NA))
# Example of ANOVA III
FullyParamANOVA(InputData=Butterfly, form=Wingspan~Sex*Patch*Site,
variables_type = c('Fxd','Rndm','Fxd'), variables_relationships = c(NA,"Site",NA))
# Example of ANOVA III, using arguments different than those by default
# (changing the threshold below which a p-value is considered significant to 0.1,
# the types of sum of squares to 2, adding the effect sizes (ges = generalized eta squared)
# in the output table, and outputting only the table to be able to use the information within
# or store it in an object)
FullyParamANOVA(InputData=Butterfly, form=Wingspan~Sex*Patch*Site, sig_threshold=0.1,
sum_of_squares = 2, variables_type = c('Fxd','Rndm','Fxd'),
variables_relationships = c(NA,"Site",NA), print_ges = TRUE, output_table_only = TRUE)