Package 'WAnova'

Title: Welch's Anova from Summary Statistics
Description: Provides the functions to perform a Welch's one-way Anova with fixed effects based on summary statistics (sample size, means, standard deviation) and the Games-Howell post hoc test for multiple comparisons and provides the effect size estimator adjusted omega squared. In addition sample size estimation can be computed based on Levy's method, and a Monte Carlo simulation is included to bootstrap residual normality and homoscedasticity Welch, B. L. (1951) <doi:10.1093/biomet/38.3-4.330> Kirk, R. E. (1996) <doi:10.1177/0013164496056005002> Carroll, R. M., & Nordholm, L. A. (1975) <doi:10.1177/001316447503500304> Albers, C., & Lakens, D. (2018) <doi:10.1016/j.jesp.2017.09.004> Games, P. A., & Howell, J. F. (1976) <doi:10.2307/1164979> Levy, K. J. (1978a) <doi:10.1080/00949657808810246> Show-Li, J., & Gwowen, S. (2014) <doi:10.1111/bmsp.12006>.
Authors: Niklas Burgard [aut, cre]
Maintainer: Niklas Burgard <[email protected]>
License: GPL (>= 3)
Version: 0.4.0
Built: 2024-11-17 06:28:35 UTC
Source: CRAN

Help Index


fmax.test

Description

Performs Hartley's Fmax test for homogeneity of variances. This test assesses whether the variances of multiple groups are equal, given that the sample sizes are the same. It calculates the ratio of the maximum to the minimum variance and compares it to a critical value from the Fmax distribution to determine if there is significant deviation from homogeneity.

Usage

fmax_test(levels, n, sd)

Arguments

levels

a vector of group labels or identifiers.

n

A numeric vector of sample sizes for each group.

sd

A numeric vector of standard deviations for each group.

Value

A list with the following components:

fmax

The ratio of the maximum to minimum variance.

df

Degrees of freedom associated with the test.

k

Number of groups.

pval

The p-value of the test.

The levels parameter is used determine the number of groups. The variances are computed as the squares of sd. Note: Applicable results assume normally distributed data with equal sample sizes

Null Hypothesis: Assumes homogeneity of variances, which means all groups have the same variance. Alternative Hypothesis: Assumes that not all group variances are equal. This hypothesis is supported if the p-value is below the significance level.

Examples

probe_data <- data.frame(
  group = c("probe_a", "probe_b", "probe_c"),
  size = c(10, 10, 10),  # Equal sample sizes
  mean = c(43.00000, 33.44444, 35.75000),
  sd = c(4.027682, 9.302031, 16.298554)
)

# Perform Hartley's Fmax test
result <- fmax_test(
  levels = probe_data$group,
  n = probe_data$size,
  sd = probe_data$sd
)

games_howell.test

Description

Games-Howell post hoc test for multiple comparisons after Welch's ANOVA.

Usage

games_howell.test(levels, n, means, sd, conf.level = 0.95)

Arguments

levels

A vector containing the level names of the independent variable.

n

A vector containing the sample sizes for each level.

means

A vector containing the sample means for each level.

sd

A vector containing the sample standard deviations for each level.

conf.level

The confidence level for the interval. Defaults to 0.95.

Value

A data frame of class "wAnova_gh" containing the pairwise comparisons with mean differences, standard errors, confidence intervals, t-values, degrees of freedom, and p-values. Significance codes are also included.

Examples

probe_data <- data.frame(
  group = c("probe_a", "probe_b", "probe_c"),
  size = c(10, 9, 8),
  mean = c(43.00000, 33.44444, 35.75000),
  sd = c(4.027682, 9.302031, 16.298554)
)
result <- games_howell.test(probe_data$group, probe_data$size, probe_data$mean, probe_data$sd)
print(result)

Print Method for 'wsize' Objects

Description

Custom print method for objects of class 'wsize'. Displays the results of the sample size determination in a user-friendly format.

Usage

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

Arguments

x

An object of class wsize.

...

Additional arguments passed to or from other methods.

Value

Prints the sample size determination results to the console.

Examples

# Print the results from the wsize function
n <- c(10, 10, 10, 10)
means <- c(1, 0, 0, -1)
sd <- c(1, 1, 1, 1)
result <- wanova_pwr.test(n, means, sd, power = 0.90, alpha = 0.05)
print(result)

wanova_pwr.test

Description

This function computes the approximate sample size required to achieve a desired power level for Welch's F-test in a one-way heteroscedastic ANOVA. The function takes the initial sample size, group means, and standard deviations, and iteratively determines the necessary sample size to meet the specified power and significance level.

Usage

wanova_pwr.test(n, means, sd, power = 0.9, alpha = 0.05)

Arguments

n

A numeric vector of initial sample sizes for each group.

means

A numeric vector of the means for each group.

sd

A numeric vector of the standard deviations for each group.

power

Desired power of the test. Default is 0.90.

alpha

Significance level for the test. Default is 0.05.

Details

The function adjusts the sample sizes iteratively until the desired power level is achieved. It uses the F-distribution to determine critical values and compute the power of the test. The output includes the sample size required for each group to achieve the specified power.

Reference: Levy, K. J. (1978a). Some empirical power results associated with Welch's robust analysis of variance technique. Journal of Statistical Computation and Simulation, 8, 43-48.

Value

A list containing:

n

The adjusted sample sizes for each group. If all adjusted sizes are the same, it returns a single value.

alpha

The significance level used in the computation.

power

The calculated power of the test, rounded to two decimal places.

See Also

print.wsize

Examples

# Example usage of the wsize function
n <- c(10, 10, 10, 10)
means <- c(1, 0, 0, -1)
sd <- c(1, 1, 1, 1)
result <- wanova_pwr.test(n, means, sd, power = 0.90, alpha = 0.05)
print(result)

welch_anova.mc

Description

Monte Carlo simulation to assess residual normality and homoscedasticity across multiple groups by generating simulated data based on provided means, standard deviations, and sample sizes.

Usage

welch_anova.mc(
  means,
  sd,
  n,
  n_sim = 1000,
  sim_func = NULL,
  alpha = 0.05,
  adj = TRUE
)

Arguments

means

Vector of means for each group.

sd

Vector of standard deviations for each group.

n

Vector of sample sizes for each group.

n_sim

Number of simulations to perform. Defaults to 1000.

sim_func

Function used for generating random samples. Defaults to rnorm().

alpha

Significance level for normality and homoscedasticity tests. Defaults to 0.05.

adj

Logical, if TRUE applies continuity correction for proportions. Defaults to TRUE.

Value

A list of class "simres" containing the proportion of simulations where residuals are normally distributed and homoscedastic.

Examples

means <- c(50, 55, 60)
sds <- c(10, 12, 15)
n <- c(30, 35, 40)
result <- welch_anova.mc(means = means, sd = sds, n = n, n_sim = 1000, alpha = 0.05)
print(result)

welch_anova.test

Description

Welch's one-way ANOVA with fixed effects (between subjects analysis) from summary statistics with unequal (unknown) variances.

Usage

welch_anova.test(levels, n, means, sd, effsize = "AnL")

Arguments

levels

Vector with level names of the independent variable

n

Vector with sample size for each level

means

Vector with sample mean for each level

sd

Vector with sample standard deviation for each level

effsize

Options "AnL" (standard), "Kirk", "CaN" (see below)

Value

A list of class "wAnova" that contains the F-value, df-between, df-within, p-value and effect size omega-squared that can later be converted to a table-styled summary using summary()

The adjusted omega squared estimator of the effect size is either calculated by the formula of of Albers and Lakens, Kirk or Caroll and Nordholm (Further notes see README file)

Albers, C., & Lakens, D. (2018). When power analyses based on pilot data are biased: Inaccurate effect size estimators and follow-up bias. Journal of Experimental Social Psychology, 74, 187–195. Kirk, R. E. (1996). Practical significance: A concept whose time has come. Educational and Psychological Measurement, 56(5), 746-759. Carroll, R. M., & Nordholm, L. A. (1975). Sampling characteristics of Kelley's epsilon and Hays' omega Educational and Psychological Measurement, 35(3), 541-554.

Examples

probe_data <- data.frame(
  group = c("probe_a", "probe_b", "probe_c"),
  size = c(10, 9, 8),
  mean = c(43.00000, 33.44444, 35.75000),
  sd = c(4.027682, 9.302031, 16.298554)
)
result <- welch_anova.test(
  levels = probe_data$group,
  n = probe_data$size,
  means = probe_data$mean,
  sd = probe_data$sd,
  effsize = "Kirk"
)
summary(result)