Type: Package
Title: One-Way Tests in Independent Groups Designs
Version: 3.1
Date: 2025-07-22
Depends: R (≥ 3.2.0)
Imports: stats, moments, car, ggplot2, nortest, graphics, utils, wesanderson
Suggests: AID, tibble, testthat
Author: Osman Dag [aut, cre], Merve Kasikci [aut], Anil Dolgun [aut], N. Meric Konar [aut], Sam Weerahandi [aut], Malwane Ananda [aut], H. Erkin Sulekli [aut]
Maintainer: Osman Dag <osman.dag@outlook.com>
Description: Performs one-way tests in independent groups designs including homoscedastic and heteroscedastic tests. These are one-way analysis of variance (ANOVA), Welch's heteroscedastic F test, Welch's heteroscedastic F test with trimmed means and Winsorized variances, Brown-Forsythe test, Alexander-Govern test, James second order test, Kruskal-Wallis test, Scott-Smith test, Box F test, Johansen F test, Generalized tests equivalent to Parametric Bootstrap and Fiducial tests, Alvandi's F test, Alvandi's generalized p-value, approximate F test, B square test, Cochran test, Weerahandi's generalized F test, modified Brown-Forsythe test, adjusted Welch's heteroscedastic F test, Welch-Aspin test, Permutation F test. The package performs pairwise comparisons and graphical approaches. Also, the package includes Student's t test, Welch's t test and Mann-Whitney U test for two samples. Moreover, it assesses variance homogeneity and normality of data in each group via tests and plots (Dag et al., 2018, https://journal.r-project.org/archive/2018/RJ-2018-022/RJ-2018-022.pdf).
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2)]
NeedsCompilation: no
Packaged: 2025-07-22 14:00:55 UTC; USER
Repository: CRAN
Date/Publication: 2025-07-22 14:32:05 UTC

Alvandi's F Test

Description

af.test performs Alvandi's F test. This test assumes that the data within each group are normally distributed and offers a robust alternative to one-way ANOVA when heteroscedasticity is present. The test statistic follows an F distribution.

Usage

af.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Alvandi's F test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Alvandi's F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Merve Kasikci

References

Sadooghi-Alvandi, S.M., Jafari, A.A., Mardani-Fard, H.A. (2012). One-Way ANOVA with Unequal Variances. Communications in Statistics-Theory and Methods, 41:22, 4200-4221.

Examples


library(onewaytests)

af.test(Sepal.Length ~ Species, data = iris)

out <- af.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Alexander-Govern Test

Description

ag.test performs Alexander-Govern test. This test is an alternative to one-way ANOVA when group variances are not homogeneous. The test statistic follows a chi-square distribution.

Usage

ag.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Alexander-Govern test statistic.

parameter

the parameter(s) of the approximate chi-squared distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Alexander-Govern Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Schneider, P. J., Penfield, D. A. (1997). Alexander and Govern's Approximation: Providing an Alternative to ANOVA Under Variance Heterogeneity. The Journal of Experimental Education, 65:3, 271-286.

Examples


######

library(onewaytests)

ag.test(Sepal.Length ~ Species, data = iris)

out <- ag.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)

######

library(onewaytests)
library(tibble)

iris <- as_tibble(iris)
ag.test(Sepal.Length ~ Species, data = iris)

out <- ag.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)

######

Alvandi's Generalized P-Value

Description

agp.test performs Alvandi's generalized p-value. This test assumes normality within each group and provides an alternative to one-way ANOVA when variances are unequal. The p-value is obtained by comparing the observed Cochran's test statistic with the reference distribution calculated using Monte Carlo simulation.

Usage

agp.test(formula, data, N = 10^5, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

N

the number of bootstrap samples. Default is set to 10^5.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

p.value

the Alvandi's generalized p-value.

alpha

the level of significance to assess the statistical difference.

method

the character string "Alvandi's Generalized P-Value".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

N

the number of bootstrap samples.

Author(s)

Merve Kasikci

References

Sadooghi-Alvandi, S.M., Jafari, A.A., Mardani-Fard, H.A. (2012). One-Way ANOVA with Unequal Variances. Communications in Statistics-Theory and Methods, 41:22, 4200-4221.

Examples


library(onewaytests)


agp.test(Sepal.Length ~ Species, data = iris)

out <- agp.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



One-Way Analysis of Variance

Description

aov.test performs one-way analysis of variance (ANOVA). This test requires that the assumptions of normal distribution and homogeneity of variance be met. The test statistic follows an F distribution.

Usage

aov.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the analysis of variance test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "One-Way Analysis of Variance".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Sheskin, D. J. (2004). Handbook of Parametric and Nonparametric Statistical Procedures. 3rd Edition. Chapman and Hall CRC. Florida: Boca Raton.

Examples


library(onewaytests)

aov.test(Sepal.Length ~ Species, data = iris)

out <- aov.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)


Approximate F Test

Description

ap.test performs approximate F test. This test assumes that the data within each group are normally distributed and offers a robust alternative to one-way ANOVA when heteroscedasticity is present. The test statistic follows an approximate F-distribution. Especially for small samples, this test provide better control of the type I error rate.

Usage

ap.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the approximate F test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Approximate F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Merve Kasikci

References

Asiribo, O., Gurland, J. (1990). Coping with Variance Heterogeneity. Communications in Statistics-Theory and Methods, 19:11, 4029-4048.

Examples


library(onewaytests)

ap.test(Sepal.Length ~ Species, data = iris)

out <- ap.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Adjusted Welch's Heteroscedastic F Test

Description

aw.test performs adjusted Welch's heteroscedastic F test. This test is a heteroscedastic alternative to one-way ANOVA that is robust to the violation of variance homogeneity assumption. The test statistic follows an F distribution.

Usage

aw.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the adjusted Welch's heteroscedastic F test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Adjusted Welch's Heteroscedastic F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Hartung, J., Argac, D., Makambi, K.H. (2002). Small Sample Properties of Tests on Homogeneity in One-Way ANOVA and Meta-Analysis. Statistial Papers, 43:2, 197-235.

Examples


library(onewaytests)

aw.test(Sepal.Length ~ Species, data = iris)

out <- aw.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



B Square Test

Description

b2.test performs B square test. This test is an alternative to one-way ANOVA when variances are homogeneous and uses Bailey's normality transformation. The test statistic follows a chi-squared distribution.

Usage

b2.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the B square test statistic.

parameter

the parameter(s) of the approximate chi-squared distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "B Square Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Merve Kasikci

References

Ozdemir, A.F., Kurt, S. (2006). One Way Fixed Effect Analysis of Variance under Variance Heterogeneity and a Solution Proposal. Selcuk Journal of Applied Mathematics, 7:2, 81-90.

Examples


library(onewaytests)

b2.test(Sepal.Length ~ Species, data = iris)

out <- b2.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)


Brown-Forsythe Test

Description

bf.test performs Brown-Forsythe test. This test is a modification of one-way ANOVA for cases with heterogeneous variances. The test statistic follows an F distribution.

Usage

bf.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Brown-Forsythe test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Brown-Forsythe Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Brown, M. B., Forsythe. A. B. (1974a). The small sample behavior of some statistics which test the equality of several means. Technometrics, 16, 129-132.

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Examples


library(onewaytests)

bf.test(Sepal.Length ~ Species, data = iris)

out <- bf.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Box F Test

Description

box.test performs Box F test. This test is an alternative to one-way ANOVA when variances are homogeneous. The test statistic follows an F distribution.

Usage

box.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Box F test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Box F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Box, G.E.P. (1954). Some Theorems on Quadratic Forms Applied in the Study of Analysis of Variance Problems, Annals of Mathematical Statistics, 25, 290-302.

Examples


library(onewaytests)

box.test(Sepal.Length ~ Species, data = iris)

out <- box.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Cochran Test

Description

cochran.test performs Cochran test. This test is a heteroscedastic alternative to one-way ANOVA. The test statistic follows a chi-squared distribution.

Usage

cochran.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Cochran test statistic.

parameter

the parameter(s) of the approximate chi-squared distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Cochran Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Merve Kasikci

References

Cochran, W.G. (1937). Problems Arising in the Analysis of a Series of Similar Experiments. Supplement to Journal of the Royal Statistical Society, 4:1, 102-118.

Examples


library(onewaytests)

cochran.test(Sepal.Length ~ Species, data = iris)

out <- cochran.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)


Descriptive Statistics

Description

describe produces basic descriptive statistics including sample size, mean, standard deviation, median, minimum value, maximum value, 25th quantile, 75th quantile, skewness, kurtosis, the number of missing value.

Usage

describe(formula, data)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

Value

Returns a data.frame of output.

Author(s)

Osman Dag

Examples


library(onewaytests)

describe(Sepal.Length ~ Species, data = iris)


Test for Equal Means in a One-Way Layout under Unequal Variances

Description

gp.test tests whether two or more samples from normal distributions have the same means when the variances are not necessarily equal.

Usage

gp.test(formula, data, method = c("gtb","gtf"), alpha = 0.05, 
  na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

method

a character string to select the method. "gtb": Generalized Test Equivalent to Parametric Bootstrap Test (size close to intended), "gtf": Generalized Test Equivalent to Fiducial Test (size assured).

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

p.value

the p-value of the corresponding test.

alpha

the level of significance to assess the statistical difference.

method

the selected method used in generalized test.

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Note

The methods underlying Generalized Tests are summarized in Weerahandi and Krishnamoorthy (2019), which shows that both the Fiducial and the Parametric Bootstrap tests are generalized tests based on an exact probability statement on alternative test variables. Greater details of them can be found in Krishnamoorthy et al. (2007) and Li et al. (2011). For greater details about Generalized Inference, the reader is referred to Weerahandi (2004), which can be freely read at Generalized Inference.

For additional information about the methods and the code, the reader can contact the authors of this code, Sam Weerahandi or Malwane Ananda.

Author(s)

Sam Weerahandi, Malwane Ananda

References

Daniel, W.W., Cross, C.L. (2013). Biostatistics: A Foundation for Analysis in the Health Sciences. (10th ed.). John Wiley and Sons, Inc.

Krishnamoorthy, K., Lu, F., Mathew, T. (2007). A parametric bootstrap approach for ANOVA with unequal variances: fixed and random models. Computational Statistics and Data Analysis, 51:12, 5731-5742.

Li, X., Wang J., Liang H. (2011). Comparison of several means: a fiducial based approach. Computational Statistics and Data Analysis, 55:5, 1993-2002.

Weerahandi, S. (2004). Generalized Inference in Repeated Measures: Exact Methods in MANOVA and Mixed Models, Series in Probability and Statistics. John Wiley and Sons, Inc.

Weerahandi, S., Krishnamoorthy, K. (2019). A note reconciling ANOVA tests under unequal error variances. Communications in Statistics-Theory and Methods, 48:3, 689-693.

Examples


library(onewaytests)

gp.test(Sepal.Length ~ Species, data = iris, method = "gtb")
out <- gp.test(Sepal.Length ~ Species, data = iris, method = "gtb", verbose = FALSE)
summary(out)
paircomp(out)

gp.test(Sepal.Length ~ Species, data = iris, method = "gtf")
out <- gp.test(Sepal.Length ~ Species, data = iris, method = "gtf", verbose = FALSE)
summary(out)
paircomp(out)




Box-and-Whisker, Violin Plots and Error Bars

Description

gplot produce box-and-whisker plots, violin plots, and error bars of the given grouped values.

Usage

gplot(formula, data, type = c("boxplot-violin", "boxplot", "violin", "errorbar"), 
  width = c(0.3, 1.0, 0.2), dots = TRUE, binwidth = 0.05, color_manual = NULL, 
  theme = theme_bw(), xlab = NULL, ylab = NULL, title = NULL, 
  option = c("sd", "se"), bar = FALSE, na.rm = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

type

a character string to select one of the plots. "boxplot-violin": box-and-whisker plot with violin lines, "boxplot": box-and-whisker plot, "violin": violin plot, "errorbar": error bar.

width

a vector including three numeric values. First numeric represents the width of the boxes for box-and-whisker plots (defaults to 0.3). Second numeric belongs to the width of violin plot (defaults to 1.0). Third numeric represents the width of the little lines at the tops and bottoms of the error bars (defaults to 0.20).

dots

a logical to draw the dots corresponding the data values.

binwidth

a numeric to specify bin width of dot(s), defaults to 0.05.

color_manual

a vector of colors. A palette can also be defined with wes_palette. Default is set to "FantasticFox1" available in wes_palette.

theme

a theme (see ggtheme). Default is set to theme_bw().

xlab

a label for the x axis, defaults to a description of x.

ylab

a label for the y axis, defaults to a description of y.

title

a main title for the plot.

option

a character string to select one of the options to draw error bars with standard error or standard deviation. "se": standard error, "sd": standard deviation. Defaults to "sd".

bar

a logical to add bar to errorbars. Default is fixed to bar = FALSE.

na.rm

a logical indicating whether NA values should be stripped before the computation proceeds.

Details

The upper whisker of box-and-whisker plots extends from the hinge to the highest value that is within 1.5 * IQR of the hinge, where IQR is the inter-quartile range. The lower whisker extends from the hinge to the lowest value within 1.5 * IQR of the hinge. Data out of the ends of the whiskers are outliers and plotted as points.

Author(s)

Osman Dag

See Also

geom_boxplot geom_violin

Examples


library(onewaytests)

# box-and-whisker with dots
gplot(Sepal.Length~Species, data = iris, type = "boxplot") 

# box-and-whisker without dots
gplot(Sepal.Length~Species, data = iris, type = "boxplot", dots = FALSE) 

# to change the width of the boxes for box-and-whisker plots
gplot(Sepal.Length~Species, data = iris, type = "boxplot", width = c(0.4, NA, NA)) 

# violin plot with dots
gplot(Sepal.Length~Species, data = iris, type = "violin") 

# to change the width of violin plots
gplot(Sepal.Length~Species, data = iris, type = "violin", width = c(NA, 0.8, NA)) 

# box-and-whisker plot with violin lines and dots
gplot(Sepal.Length~Species, data = iris, type = "boxplot-violin") 

# to change the width of the boxes for box-and-whisker plots and the width of violin plots
gplot(Sepal.Length~Species, data = iris, type = "boxplot-violin", width = c(0.25, 0.95, NA)) 

# to change the theme
library(ggplot2)
gplot(Sepal.Length~Species, data = iris, type = "boxplot-violin", width = c(0.25, 0.95, NA), 
theme = theme_minimal()) 

# to specify the colors 
gplot(Sepal.Length~Species, data = iris, type = "boxplot-violin", width = c(0.25, 0.95, NA), 
color_manual=c("#999999","#E69F00","#56B4E9")) 

# to specify the colors as white
gplot(Sepal.Length~Species, data = iris, type = "boxplot-violin", width = c(0.25, 0.95, NA), 
color_manual=c("white","white","white"))

#to change color palette 
library(wesanderson) 
gplot(Sepal.Length~Species, data = iris, type = "boxplot-violin", width = c(0.25, 0.95, NA), 
color_manual=wes_palette(name="GrandBudapest1",n=3))

# error bars (mean +- standard deviation) without bars
gplot(Sepal.Length~Species, data = iris, type = "errorbar", option = "sd", bar = FALSE) 

# error bars (mean +- standard deviation) with bars
gplot(Sepal.Length~Species, data = iris, type = "errorbar", option = "sd", bar = TRUE) 

# to change the width of the little lines at the tops and bottoms of the error bars
gplot(Sepal.Length~Species, data = iris, type = "errorbar", width = c(NA, NA, 0.25)) 

# error bars (mean +- standard error) without bars
gplot(Sepal.Length~Species, data = iris, type = "errorbar", option = "se", bar = FALSE) 



Variance Homogeneity Tests

Description

homog.test performs variance homogeneity tests including Levene, Bartlett, Fligner-Killeen tests.

Usage

homog.test(formula, data, method = c("Levene", "Bartlett", "Fligner"), 
  alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

method

a character string to select one of the variance homogeneity tests. "Levene": Levene's test, "Bartlett": Bartlett's test, "Fligner": Fligner-Killeen test.

alpha

the level of significance to assess variance homogeneity. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list containing the following components:

statistic

the corresponding test statistic.

parameter

the parameter(s) of the approximate corresponding distribution of the test statistic. The corresponding distribution is F distribution for Levene's test, Chi-square distribution for Bartlett's test and Fligner-Killeen test.

p.value

the p-value of the test.

Author(s)

Osman Dag

See Also

leveneTest bartlett.test fligner.test

Examples


library(onewaytests)

homog.test(Sepal.Length ~ Species, data = iris)
homog.test(Sepal.Length ~ Species, data = iris, method = "Bartlett")


James Second Order Test

Description

james.test performs James second order test. This test is a heteroscedastic alternative to one-way ANOVA. The test statistic is formulated as a sum of squared standardized differences and compared to a critical value.

Usage

james.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

a significance level. Defaults alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "jt" containing the following components:

statistic

the James second order test statistic.

criticalValue

the critical value of the James second order test statistic.

alpha

the level of significance to assess the statistical difference.

method

the character string "James Second Order Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Anil Dolgun

References

Cribbie, R. A., Fiksenbaum, L., Keselman, H. J., Wilcox, R. R. (2012). Effect of Non-Normality on Test Statistics for One-Way Independent Groups Designs. British Journal of Mathematical and Statistical Psychology, 65, 56-73.

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Examples


library(onewaytests)

james.test(Sepal.Length ~ Species, data = iris, alpha = 0.05)

out <- james.test(Sepal.Length ~ Species, data = iris, alpha = 0.05, verbose = FALSE)
summary(out)
paircomp(out)


Johansen F Test

Description

johansen.test performs Johansen F test. This test is an alternative to one-way ANOVA when variances are homogeneous. The test statistic follows an F distribution.

Usage

johansen.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Johansen F test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Johansen F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Johansen, S. (1980). The Welch-James Approximation to the Distribution of the Residual Sum of Squares in a Weighted Linear Regression, Biometrika, 67:1, 58-92.

Examples


library(onewaytests)

johansen.test(Sepal.Length ~ Species, data = iris)

out <- johansen.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Kruskal-Wallis Test

Description

kw.test performs Kruskal-Wallis test. This test serves as a nonparametric alternative to ANOVA when the normality assumption is not met. The test statistic follows a chi-squared distribution.

Usage

kw.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Kruskal-Wallis test statistic.

parameter

the parameter(s) of the approximate chi-squared distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Kruskal-Wallis Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Anil Dolgun

References

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Sheskin, D. J. (2004). Handbook of Parametric and Nonparametric Statistical Procedures. 3rd Edition. Chapman and Hall CRC. Florida: Boca Raton.

Examples


library(onewaytests)

kw.test(Sepal.Length ~ Species, data = iris)

out <- kw.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)


Modified Brown-Forsythe Test

Description

mbf.test performs modified Brown-Forsythe test. This test is a modification of Brown-Forsythe test to overcome the problem of higher than acceptable rate of false positives. The test statistic follows an F distribution.

Usage

mbf.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the modified Brown-Forsythe test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Modified Brown-Forsythe Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Merve Kasikci

References

Mehrotra, D.V. (1997). Improving the Brown-Forsythe Solution to the Generalized Behrens-Fisher Problem. Communications in Statistics-Simulation and Computation, 26:3, 1139-1145.

Examples


library(onewaytests)

mbf.test(Sepal.Length ~ Species, data = iris)

out <- mbf.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)


Mann-Whitney U Test

Description

mw.test performs Mann-Whitney U test for two samples. This test is the nonparametric alternative to Student's t-test. The test statistic is calculated based on the U value derived from the ranks of the groups.

Usage

mw.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Details

Approximation to normal distribution is used to obtain the p-value.

Value

A list with class "owt" containing the following components:

statistic

the Z statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

See Also

wilcox.test st.test wt.test

Examples



library(AID)
data(AADT)

library(onewaytests)
describe(aadt ~ control, data = AADT)

mw.test(aadt ~ control, data = AADT)

out <- mw.test(aadt ~ control, data = AADT, verbose = FALSE)
summary(out)


Normality Tests

Description

nor.test performs normality tests including Shapiro-Wilk, Shapiro-Francia, Kolmogorov-Smirnov, Anderson-Darling, Cramer-von Mises, Pearson Chi-square tests, and also assess the normality of each group through plots.

Usage

nor.test(formula, data, method = c("SW", "SF", "LT", "AD", "CVM", "PT"), 
  plot = c("qqplot-histogram", "qqplot", "histogram"), mfrow = NULL, 
  alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

method

a character string to select one of the normality tests. "SW": Shapiro-Wilk test, "SF": Shapiro-Francia test, "LT": Lilliefors (Kolmogorov-Smirnov) test, "AD": Anderson-Darling test, "CVM": Cramer-von Mises test, "PT": Pearson Chi-square test.

plot

a character string to select one of the plots including qqplot-histogram, qqplot, histogram. The red line is the density line of normal distribution.

mfrow

a two element vector to draw subsequent figures.

alpha

the level of significance to assess normality. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A data frame gives the test results for the normality of groups via corresponding normality.

Author(s)

Osman Dag

See Also

homog.test gplot shapiro.test

Examples


library(onewaytests)

nor.test(Sepal.Length ~ Species, data = iris, method = "SW", plot = "qqplot-histogram")
nor.test(Sepal.Length ~ Species, data = iris, method = "SF", plot = "qqplot", mfrow = c(1,3))


One-Way Tests for Independent Groups Designs

Description

onewaytests is a function covering 22 one-way tests for independent groups designs.

Usage

onewaytests(formula, data, method = c("aov", "af", "ag", "agp", "ap", "aw", "b2", 
  "bf", "box", "cochran", "gtb", "gtf", "james", "johansen", "kw", "mbf", "pf", 
  "ss", "wa", "welch", "welch_tw", "wgf"), N = 10^5, rate = 0.1, alpha = 0.05, 
  na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

method

the one-way test. There are 22 tests available: one-way analysis of variance ("aov"), Welch's heteroscedastic F test ("welch"), Welch's heteroscedastic F test with trimmed means and Winsorized variances ("welch_tw"), Brown-Forsythe test ("bf"), Alexander-Govern test ("ag"), James second order test ("james"), Kruskal-Wallis test ("kw"), Scott-Smith test ("ss"), Box F test ("bf"), Generalized tests equivalent to Parametric Bootstrap ("gtb") and Fiducial ("gtf") tests, Johansen F test ("johansen"), Alvandi's F test ("af"), Alvandi's generalized p-value ("agp"), approximate F test ("af"), B square test ("b2"), Cochran test ("cochran"), Weerahandi's generalized F test ("wgf"), modified Brown-Forsythe test ("mbf"), adjusted Welch's heteroscedastic F test ("aw"), Welch-Aspin test ("wa"), Permutation F test ("pf"). Default is set to "aov".

N

the number of bootstrap samples for Weerahandi's generalized F test, Alvandi's generalized p-value, and permutation F test. Default is set to 10^5.

rate

the rate of observations trimmed and winsorized from each tail of the distribution for Welch's heteroscedastic F test with trimmed means and Winsorized variances. Default is set to rate = 0.1.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

See the corresponding one-way test function.

Author(s)

Merve Kasikci, Osman Dag

References

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Examples


library(onewaytests)

# One-Way Analysis of Variance
onewaytests(Sepal.Length ~ Species, data = iris, method = "aov")

out <- onewaytests(Sepal.Length ~ Species, data = iris, method = "aov", verbose = FALSE)
summary(out)
paircomp(out)

# Alexander-Govern test
onewaytests(Sepal.Length ~ Species, data = iris, method = "ag")

# Johansen F test
onewaytests(Sepal.Length ~ Species, data = iris, method = "johansen")


Pairwise Comparisons

Description

paircomp is a generic function for pairwise comparisons by adjusting p-values.

Usage

## S3 method for class 'owt'
paircomp(x, adjust.method = c("bonferroni", "holm", "hochberg", "hommel", "BH", 
  "BY", "fdr", "none"), verbose = TRUE, ...)

Arguments

x

a owt object.

adjust.method

Method for adjusting p values (see p.adjust). Default is set to "bonferroni".

verbose

a logical for printing output to R console.

...

Additional arguments affecting multiple comparisons of groups in one-way independent designs.

Value

Returns a data.frame of output.

Author(s)

Osman Dag

Examples


library(onewaytests)

out <- aov.test(Sepal.Length ~ Species, data = iris)
summary(out)
paircomp(out)
paircomp(out, adjust.method = "hochberg")

out2 <- kw.test(Sepal.Length ~ Species, data = iris)
summary(out2)
paircomp(out2)
paircomp(out2, adjust.method = "hommel")
paircomp(out2, adjust.method = "holm")



Pairwise Comparisons for James Second Order Test

Description

paircomp.jt performs multiple comparisons by adjusting the level of significance for James second order test.

Usage

## S3 method for class 'jt'
paircomp(x, adjust.method = c("bonferroni", "none"), verbose = TRUE, ...)

Arguments

x

a jt object.

adjust.method

Method for adjusting the significance level. "bonferroni": Bonferroni correction, "none": No correction.

verbose

a logical for printing output to R console.

...

Additional arguments affecting multiple comparisons of groups in one-way independent designs.

Value

Returns a data.frame of output.

Author(s)

Osman Dag

Examples


library(onewaytests)

out <- james.test(Sepal.Length ~ Species, data = iris, alpha = 0.05)
summary(out)
paircomp(out, adjust.method = "bonferroni")


Permutation F Test

Description

pf.test performs Permutation F test. This test evaluates mean differences without depending on the theoretical F distribution. Rather, it relies on an empirical F distribution produced using permutations. This test is robust to violations of normality and variance homogeneity.

Usage

pf.test(formula, data, N = 10^5, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

N

the number of bootstrap samples. Default is set to 10^5.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

p.value

the Permutation F test p-value.

alpha

the level of significance to assess the statistical difference.

method

the character string "Permutation F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

N

the number of bootstrap samples.

Author(s)

Osman Dag

References

Berry, K.J., Mielke Jr, P.W., Mielke, H.W. (2002). The Fisher-Pitman Permutation Test: an Attractive Alternative to the F Test. Psychological Reports, 90:2, 495-502.

Examples


library(onewaytests)


pf.test(Sepal.Length ~ Species, data = iris)

out <- pf.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Print Method for Summary of James Second Order Test Results

Description

Prints the formatted summary of an jt object to the console.

Usage

## S3 method for class 'summary.jt'
print(x, ...)

Arguments

x

An object returned by summary.jt().

...

Additional arguments.

Author(s)

Merve Kasikci, Osman Dag

See Also

summary.jt

Examples

out <- james.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)

Print Method for Summary of One-Way Test Results

Description

Prints the formatted summary of an owt object to the console.

Usage

## S3 method for class 'summary.owt'
print(x, ...)

Arguments

x

An object returned by summary.owt().

...

Additional arguments.

Author(s)

Osman Dag

See Also

summary.owt

Examples

out <- onewaytests(Sepal.Length ~ Species, data = iris, method = "aov", verbose = FALSE)
summary(out)
paircomp(out)

out <- aov.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)

Scott-Smith Test

Description

ss.test performs Scott-Smith test. This test compares group means when group variances are not homogenous. The test statistic follows a chi-squared distribution.

Usage

ss.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Scott-Smith test statistic.

parameter

the parameter(s) of the approximate chi-squared distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Scott-Smith Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Scott, A., Smith, T. (1971). Interval Estimates for Linear Combinations of Means. Journal of the Royal Statistical Society: Series C (Applied Statistics), 20:3, 276-285.

Examples


library(onewaytests)

ss.test(Sepal.Length ~ Species, data = iris)

out <- ss.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)
paircomp(out)



Student's t-Test

Description

st.test performs Student's t-test for two samples. This test requires that the assumptions of normal distribution and homogeneity of variance be met. The test statistic follows a t-distribution.

Usage

st.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Student's t-test statistic.

parameter

the parameter(s) of the approximate t distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

See Also

t.test wt.test

Examples


library(AID)
data(AADT)

library(onewaytests)
describe(aadt ~ control, data = AADT)

st.test(aadt ~ control, data = AADT)

out <- st.test(aadt ~ control, data = AADT, verbose = FALSE)
summary(out)


Summary Method for James Second Order Test Results

Description

Provides a concise summary of the results from an one-way test in the package.

Usage

## S3 method for class 'jt'
summary(object, detail = TRUE, ...)

Arguments

object

An object of class jt, typically returned by james.test.

detail

a logical for printing detail of the james.test.

...

Additional arguments.

Details

This method is specifically designed for objects of class jt. It prints test method, dependent variable, grouping variable, test statistic, critical value, and any relevant notes.

Value

Prints a summary to the console.

Author(s)

Merve Kasikci, Osman Dag

Examples

out <- james.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)

Summary Method for One-Way Test Results

Description

Provides a concise summary of the results from an one-way test in the package.

Usage

## S3 method for class 'owt'
summary(object, detail = TRUE, ...)

Arguments

object

An object of class owt, typically returned by one-way tests.

detail

a logical for printing detail of the one-way tests.

...

Additional arguments.

Details

This method is specifically designed for objects of class owt. It prints test method, dependent variable, grouping variable, test statistic, degrees of freedom, p-value, and any relevant notes.

Value

Prints a summary to the console.

Author(s)

Merve Kasikci, Osman Dag

Examples

out <- onewaytests(Sepal.Length ~ Species, data = iris, method = "aov", verbose = FALSE)
summary(out)
paircomp(out)

out <- aov.test(Sepal.Length ~ Species, data = iris, verbose = FALSE)
summary(out)

Welch-Aspin Test

Description

wa.test performs Welch-Aspin test. This test is a modification of Welch test. The test statistic follows an F distribution.

Usage

wa.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Welch-Aspin test statistic.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Welch-Aspin Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Aspin, A.A. (1948). An Examination and Further Development of a Formula Arising in the Problem of Comparing Two Mean Values. Biometrika, 35:1/2, 88-96.

Examples


library(onewaytests)

wa.test(Sepal.Length ~ Species, data = iris)

out <- wa.test(Sepal.Length ~ Species, data = iris)
summary(out)
paircomp(out)


Welch's Heteroscedastic F Test and Welch's Heteroscedastic F Test with Trimmed Means and Winsorized Variances

Description

welch.test performs Welch's heteroscedastic F test and Welch's heteroscedastic F test with trimmed means and Winsorized variances. This test is a robust test that can be used when homogeneity of variance is not met. The test statistic follows an F distribution.

Usage

welch.test(formula, data, rate = 0, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

rate

the rate of observations trimmed and winsorized from each tail of the distribution. If rate = 0, it performs Welch's heteroscedastic F test. Otherwise, Welch's heteroscedastic F test with trimmed means and Winsorized variances is performed. Default is set to rate = 0.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the value of the test statistic with a name describing it.

parameter

the parameter(s) of the approximate F distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Welch's Heteroscedastic F Test" or "Welch's Heteroscedastic F Test with Trimmed Means and Winsorized Variances" depending on the choice.

rate

the rate of observations trimmed and winsorized from each tail of the distribution.

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

References

Dag, O., Dolgun, A., Konar, N.M. (2018). onewaytests: An R Package for One-Way Tests in Independent Groups Designs. The R Journal, 10:1, 175-199.

Welch, B. L.(1951). On the Comparison of Several Mean Values: An Alternative Approach. Biometrika, 38, 330-336.

Examples


library(onewaytests)

welch.test(Sepal.Length ~ Species, data = iris)
welch.test(Sepal.Length ~ Species, data = iris, rate = 0.1)

out <- welch.test(Sepal.Length ~ Species, data = iris)
summary(out)
paircomp(out)


Weerahandi's Generalized F Test

Description

wgf.test performs Weerahandi's generalized F test. This test provides a robust procedure for independent groups design by replacing the usual means and variances with trimmed means and Winsorized variances. The p-value of this test is obtained using Monte Carlo simulation.

Usage

wgf.test(formula, data, N = 10^5, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

N

the number of bootstrap samples. Default is set to 10^5.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

p.value

the p-value of Weerahandi's generalized F test.

alpha

the level of significance to assess the statistical difference.

method

the character string "Weerahandi's Generalized F Test".

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

N

the number of bootstrap samples.

Note

The user can contact the author of this code, Sam Weerahandi, for additional information about the method and the code.

Author(s)

Sam Weerahandi

References

Weerahandi, S. (1995). ANOVA under Unequal Error Variances. Biometrics, 589-599.

Examples


library(onewaytests)


wgf.test(Sepal.Length ~ Species, data = iris)

out <- wgf.test(Sepal.Length ~ Species, data = iris)
summary(out)
paircomp(out)



Welch's t-Test

Description

wt.test performs Welch's t-test for two samples. This test is an alternative to Student's t-test when variances are homogeneous. The test statistic follows a t-distribution.

Usage

wt.test(formula, data, alpha = 0.05, na.rm = TRUE, verbose = TRUE)

Arguments

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

data

a tibble or data frame containing the variables in formula.

alpha

the level of significance to assess the statistical difference. Default is set to alpha = 0.05.

na.rm

a logical value indicating whether NA values should be stripped before the computation proceeds.

verbose

a logical for printing output to R console.

Value

A list with class "owt" containing the following components:

statistic

the Welch's t-test statistic.

parameter

the parameter(s) of the approximate t distribution of the test statistic.

p.value

the p-value of the test.

alpha

the level of significance to assess the statistical difference.

data

a data frame containing the variables in which NA values (if exist) are removed.

formula

a formula of the form lhs ~ rhs where lhs gives the sample values and rhs the corresponding groups.

Author(s)

Osman Dag

See Also

t.test st.test

Examples


library(AID)
data(AADT)

library(onewaytests)
describe(aadt ~ control, data = AADT)

wt.test(aadt ~ control, data = AADT)

out <- wt.test(aadt ~ control, data = AADT)
summary(out)