-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Martin Happ
committed
Apr 20, 2018
0 parents
commit dea196d
Showing
15 changed files
with
762 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
^.*\.Rproj$ | ||
^\.Rproj\.user$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.Rproj.user | ||
.Rhistory | ||
.RData | ||
.Ruserdata | ||
SampleWMW.Rproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Package: WMWssp | ||
Type: Package | ||
Title: Wilcoxon-Mann-Whitney Sample Size Planning | ||
Version: 0.3.2 | ||
Date: 2018-02-16 | ||
Authors@R: c( | ||
person("Arne C. Bathke", role = "aut"), | ||
person("Edgar Brunner", role = "aut"), | ||
person("Martin Happ", role = c("aut", "cre"), email = "[email protected]"), | ||
person("Frank Konietschke", role = "aut") | ||
) | ||
Author: Arne C. Bathke [aut], Edgar Brunner [aut], Martin Happ [aut, cre], Frank Konietschke [aut] | ||
Maintainer: Martin Happ <[email protected]> | ||
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. | ||
Imports: rankFD | ||
Depends: R (>= 3.4.0) | ||
License: GPL-3 | ||
LazyData: TRUE | ||
RoxygenNote: 6.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export(WMWssp, WMWssp_minimize, WMWssp_noether, WMWssp_maximize) | ||
importFrom("stats", "qnorm", "optimize", "pnorm") | ||
importFrom("rankFD", "rank.two.samples") | ||
S3method(print, WMWssp) | ||
S3method(summary, WMWssp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#################################################################################################################################### | ||
### Filename: S3methods.R | ||
### Description: S3 methods for class 'WMWssp' returned from functions from file samplesize.R | ||
### | ||
### | ||
### | ||
### | ||
#################################################################################################################################### | ||
|
||
print.WMWssp <- function(x, ...){ | ||
|
||
cat("Wilcoxon-Mann-Whitney Sample Size Calculation\n \n") | ||
cat("Total sample size needed: ") | ||
cat(x$N, paste("(n_1 = ", ceiling(x$N*x$t), ", n_2 = ", ceiling(x$N*(1-x$t)), ")", sep = "")) | ||
cat("\n") | ||
|
||
if(as.character(x$call) %in% c("WMWssp_minimize", "WMWssp_maximize") ) { | ||
cat("Optimal allocation rate to the first group: ") | ||
cat(x$t) | ||
cat("\n") | ||
} else { | ||
cat("Allocation rate to the first group: ") | ||
cat(x$t) | ||
cat("\n") | ||
} | ||
|
||
if(x$simulation >= 0){ | ||
cat("Simulated Power: ") | ||
cat(x$simulation) | ||
cat("\n") | ||
} | ||
|
||
if(as.character(x$call) %in% c("WMWssp_maximize")){ | ||
cat("Maximal Power: ") | ||
cat(x$power) | ||
cat("\n") | ||
} | ||
|
||
cat("\nUse 'summary' for more details.") | ||
|
||
} | ||
|
||
|
||
summary.WMWssp <- function(object, ...){ | ||
cat("Wilcoxon-Mann-Whitney Sample Size Calculation\n \n") | ||
cat("Summary\n") | ||
cat("Call: ") | ||
cat(as.character(object$call)) | ||
cat("\n") | ||
cat("Type-I error (two-sided): ") | ||
cat(object$alpha) | ||
cat("\n") | ||
if(as.character(object$call) != "WMWssp_maximize"){ | ||
cat("Power: ") | ||
cat(object$power) | ||
cat("\n") | ||
} | ||
if(as.character(object$call) == "WMWssp_maximize"){ | ||
cat("Sample size: ") | ||
cat(object$N) | ||
cat("\n") | ||
} | ||
cat("\n") | ||
|
||
print(object$result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# 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) |
Oops, something went wrong.