Type: | Package |
Title: | Wilcoxon-Mann-Whitney Sample Size Planning |
Version: | 0.5.3 |
Date: | 2025-02-18 |
Maintainer: | Martin Happ <statistics@happ.co.at> |
Description: | Calculates the minimal sample size for the Wilcoxon-Mann-Whitney test that is needed for a given power and two sided type I error rate. The method works for metric data with and without ties, count data, ordered categorical data, and even dichotomous data. But data is needed for the reference group to generate synthetic data for the treatment group based on a relevant effect. See Happ et al. (2019, <doi:10.1002/sim.7983>) for details. |
Depends: | R (≥ 3.4.0) |
License: | GPL-3 |
URL: | https://github.com/happma/WMWssp |
BugReports: | https://github.com/happma/WMWssp/issues |
RoxygenNote: | 6.1.1 |
Suggests: | testthat |
NeedsCompilation: | no |
Packaged: | 2025-02-18 16:36:45 UTC; happma |
Author: | Arne C. Bathke [aut],
Edgar Brunner [aut],
Martin Happ |
Repository: | CRAN |
Date/Publication: | 2025-02-18 23:40:05 UTC |
Sample size calculation for the Wilcoxon-Mann-Whitney test.
Description
This function calculates the sample size for a given power, type-I error rate and allocation rate t = n_1/N. Additionally, the actual achieved power can be simulated.
Usage
WMWssp(x, y, alpha = 0.05, power = 0.8, t = 1/2,
simulation = FALSE, nsim = 10^4)
Arguments
x |
prior information for the first group |
y |
prior information for the second group |
alpha |
two sided type I error rate |
power |
power |
t |
proportion of subjects in the first group; or use t = "min" to use optimal proportion rate |
simulation |
TRUE if a power simulation should be carried out |
nsim |
number of simulations for the power simulation |
Value
Returns an object from class WMWssp containing
result |
A dataframe with the results. |
t |
The allocation rate which was used. |
alpha |
The type-I error rate which was used. |
simulation |
The achieved power in a simulation. |
power |
The power which was used. |
N |
The sample size needed. |
References
Brunner, E., Bathke A. C. and Konietschke, F. Rank- and Pseudo-Rank Procedures in Factorial Designs - Using R and SAS. Springer Verlag. to appear.
Happ, M., Bathke, A. C., & Brunner, E. (2019). Optimal Sample Size Planning for the Wilcoxon-Mann-Whitney-Test. Statistics in medicine, 38(3), 363-375.
Examples
# Prior information for the reference group
x <- c(315,375,356,374,412,418,445,403,431,410,391,475,379)
# generate data for treatment group based on a shift effect
y <- x - 20
# calculate sample size
ssp <- WMWssp(x, y, alpha = 0.05, power = 0.8, t = 1/2)
summary(ssp)
Maximizing power for a given Type I error rate and prior information x and y
Description
This function maximizes the power of the Wilcoxon-Mann-Whitney test for a given total sample size N and type-I error rate with respect to the allocation rate t = n_1/N.
Usage
WMWssp_maximize(x, y, alpha = 0.05, N)
Arguments
x |
a vector of prior information for the first group |
y |
a vector of prior information for the second group |
alpha |
Type I error rate |
N |
total sample size |
Value
Returns an object from class WMWssp containing
result |
A dataframe with the results. |
t |
The optimal allocation rate. |
alpha |
The type-I error rate which was used. |
power |
The maximized power. |
N |
The total sample size which was used. |
References
Brunner, E., Bathke A. C. and Konietschke, F. Rank- and Pseudo-Rank Procedures in Factorial Designs - Using R and SAS. Springer Verlag. to appear.
Happ, M., Bathke, A. C., & Brunner, E. (2019). Optimal Sample Size Planning for the Wilcoxon-Mann-Whitney-Test. Statistics in medicine, 38(3), 363-375.
Examples
# Prior information for the reference group
x <- c(315,375,356,374,412,418,445,403,431,410,391,475,379)
# generate data for treatment group based on a shift effect
y <- x - 20
#
N <- 112
# calculate optimal t
ssp <- WMWssp_maximize(x, y, alpha = 0.05, N)
summary(ssp)
Minimizing samplesize for a given Type I and II error rate and prior information x and y
Description
This function minimizes the sample size for a given power and type-I error rate with respect to the allocation rate t = n_1/N.
Usage
WMWssp_minimize(x, y, alpha = 0.05, power = 0.8, simulation = FALSE,
nsim = 10^4)
Arguments
x |
a vector of prior information for the first group |
y |
a vector of prior information for the second group |
alpha |
Type I error rate |
power |
Power to detect a relative effect based on the prior information |
simulation |
TRUE if a power simulation should be carried out |
nsim |
number of simulations for the power simulation |
Value
Returns an object from class WMWssp containing
result |
A dataframe with the results. |
t |
The optimal allocation rate for minimizing the sample size. |
alpha |
The type-I error rate which was used. |
power |
The power which was used. |
N |
The minimized sample size. |
References
Brunner, E., Bathke A. C. and Konietschke, F. Rank- and Pseudo-Rank Procedures in Factorial Designs - Using R and SAS. Springer Verlag. to appear.
Happ, M., Bathke, A. C., & Brunner, E. (2019). Optimal Sample Size Planning for the Wilcoxon-Mann-Whitney-Test. Statistics in medicine, 38(3), 363-375.
Examples
# Prior information for the reference group
x <- c(315,375,356,374,412,418,445,403,431,410,391,475,379)
# generate data for treatment group based on a shift effect
y <- x - 20
# calculate optimal t
ssp <- WMWssp_minimize(x, y, alpha = 0.05, power = 0.8)
summary(ssp)
Sample size calculation for the Wilcoxon-Mann-Whitney test using the Noether formula
Description
This function calculates the sample size for given type-I and type-II error probabilities using Noether's formula. If ties are present then prior information is needen.
Usage
WMWssp_noether(alpha, power, t, p, x = c(0), ties = FALSE)
Arguments
alpha |
two sided type I error rate |
power |
power: detect a relative effect p at least with the specified power |
t |
proportion of subjects in the first group (between 0 and 1) |
p |
relative effect |
x |
prior information is only needed in case of ties |
ties |
TRUE if ties are possible (non continuous distribution), otherwise FALSE |
Value
Returns an object from class WMWssp containing
result |
A dataframe with the results. |
t |
The allocation rate which was used. |
alpha |
The type-I error rate which was used. |
power |
The power which was used. |
N |
The sample size needed. |
References
Noether, G. E. (1987). Sample Size Determination for Some Common Nonparametric Tests. Journal of the American Statistical Association 85, 645.647.
Examples
# Prior information for the reference group
x <- c(315,375,356,374,412,418,445,403,431,410,391,475,379)
# generate data for treatment group based on a shift effect
y <- x - 20
# this data leads to a relative effect of p = 0.349
# calculate sampe size for a balanced design
ssp <- WMWssp_noether(alpha = 0.05, power = 0.8, t =1/2, p = 0.349)
summary(ssp)