Without a reprex
(see the FAQ), the best I can do is to relay a chat, which I haven't tested.
To calculate power or sample size for multiple comparison experiments (ANOVA or Kruskal-Wallis non-parametric test) when using the Bonferroni-adjusted p-value method, you can use the MultNonParam
package in R for the Kruskal-Wallis test[1]. For ANOVA, you can use the pwr
package in R.
For the Kruskal-Wallis test, you can use the kwpower
function from the MultNonParam
package[3]:
# Install the package if not already installed
if (!requireNamespace("MultNonParam", quietly = TRUE)) {
install.packages("MultNonParam")
}
# Load the package
library(MultNonParam)
# Calculate power for Kruskal-Wallis test
kwpower(nreps, shifts, distname = c("normal", "logistic"), level = 0.05, ...)
For ANOVA, you can use the pwr.anova.test
function from the pwr
package:
# Install the package if not already installed
if (!requireNamespace("pwr", quietly = TRUE)) {
install.packages("pwr")
}
# Load the package
library(pwr)
# Calculate power for ANOVA
pwr.anova.test(k, n, f, sig.level = 0.05, power = NULL)
For a more user-friendly tool, you can use GPower to calculate the required sample size for the Kruskal-Wallis test[2]. GPower is a free software that can be downloaded from the following website: http://www.gpower.hhu.de/
Please note that the Bonferroni-adjusted p-value method is used for multiple comparisons after the initial ANOVA or Kruskal-Wallis test. The power or sample size calculations mentioned above are for the initial tests, and the Bonferroni adjustment is applied afterward to control the family-wise error rate.
Citations:
[1] nonparametric - Power analysis for Kruskal-Wallis or Mann-Whitney U test using R? - Cross Validated
[2] Kruskal-Wallis-Test - calculate required sample size with G*Power - YouTube
[3] kwpower: Power for the Kruskal-Wallis test. in MultNonParam: Multivariate Nonparametric Methods
[4] https://www.datanovia.com/en/lessons/kruskal-wallis-test-in-r/
[5] https://med.und.edu/research/daccota/_files/pdfs/berdc_resource_pdfs/sample_size_r_module.pdf
[6] https://med.und.edu/research/daccota/_files/pdfs/berdc_resource_pdfs/sample_size_