Giter VIP home page Giter VIP logo

wmwssp's Introduction

WMWssp 0.4.0

CRANstatus Travis-CI Build Status Build status codecov DOI

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 for example [1] or [2].

To install the current development version:

## install devtools package if it's not already
if (!requireNamespace("devtools", quietly = TRUE)) {
  install.packages("devtools")
}
# install package
devtools::install_github("happma/WMWssp")
library(WMWssp)

To calculate the sample size we need prior information from one group. Let us call this group reference group. Based on this reference group, we can create artifical data according to an interpretable effect. Note that we have to specify, how many subjects should be assigned to the first and how many to the second group.

# 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)

It is also possible to vary the allocation rate to even further reduce the sample size. But for almost all situations, a balanced design will be optimal or close to optimal, see [2] or [3].

# calculate optimal allocation rate t
ssp <- WMWssp_minimize(x, y, alpha = 0.05, power = 0.8)
summary(ssp)

References

[1] Brunner, E., Bathke A. C. and Konietschke, F: Rank- and Pseudo-Rank Procedures in Factorial Designs - Using R and SAS, Springer Verlag, to appear,

[2] 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.

[3] Bürkner, P‐C, Doebler, P, Holling, H. Optimal design of the Wilcoxon–Mann–Whitney‐test. Biom J. 2017; 59( 1): 25‐ 40.

wmwssp's People

Contributors

happma avatar

Stargazers

 avatar  avatar

Watchers

 avatar

wmwssp's Issues

Summary prints results with wrong labels

Dear Martin Happ,

when using summary to display the results of function WMWssp(), the numbers are displayed with the wrong labels. The error seems to be already in the results vector. I can guess which number means what, but it would be nice if you could correct this. Probably the number 0.8035714 has to be excluded from the vector, then everything moves in place.

Best regards
Irene Schmidtmann

My example code:

library(WMWssp)
control <- c(1.5, 2.5, 3.0, 2.0, 2.0, 3.0, 3.0, 2.5)
acitretin <- c(2.5, 3.0, 2.5, 3.0, 4.0, 3.5, 3.5)
summary(WMWssp(control, acitretin, alpha = 0.025, power = 0.9, t = 1/2,
simulation = TRUE, nsim = 10000))

Output produced:

Simulation:
1000 / 10000
2000 / 10000
3000 / 10000
4000 / 10000
5000 / 10000
6000 / 10000
7000 / 10000
8000 / 10000
9000 / 10000
10000 / 10000

Wilcoxon-Mann-Whitney Sample Size Calculation

Summary
Call: WMWssp
Type-I error (two-sided): 0.025
Power: 0.9

                            Results

alpha (2-sided) 0.0250000
Power 0.9000000
Simulated Power 0.9458000
N (total sample size needed) 0.8035714
t=n1/N 33.6454152
n1 in Group 1 0.5000000
n2 in Group 2 16.8227076
N rounded 16.8227076
n1 rounded 34.0000000
n2 rounded 17.0000000
11 17.0000000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.