Package 'WMWssp'

Title: Wilcoxon-Mann-Whitney Sample Size Planning
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. For details, see Brunner, E., Bathke A. C. and Konietschke, F: Rank- and Pseudo-Rank Procedures in Factorial Designs - Using R and SAS, Springer Verlag, to appear.
Authors: Arne C. Bathke [aut], Edgar Brunner [aut], Martin Happ [aut, cre] , Frank Konietschke [aut]
Maintainer: Martin Happ <[email protected]>
License: GPL-3
Version: 0.4.0
Built: 2024-11-01 11:31:14 UTC
Source: https://github.com/happma/wmwssp

Help Index


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)