sampSize: Sample size calculations

View source: R/sampSize.R

sampSizeR Documentation

Sample size calculations

Description

Sample size calculations

Usage

sampSize(
  graph,
  esf,
  effSize,
  powerReqFunc,
  target,
  corr.sim,
  alpha,
  corr.test = NULL,
  type = c("quasirandom", "pseudorandom"),
  upscale = FALSE,
  n.sim = 10000,
  verbose = FALSE,
  ...
)

Arguments

graph

A graph of class graphMCP.

esf

...

effSize

...

powerReqFunc

One power requirement function or a list of these. If one is interested in the power to reject hypotheses 1 and 3 one could specify:
f=function(x) {x[1] && x[3]}.
If the power of rejecting hypotheses 1 and 2 is also of interest one would use a (optionally named) list:
f=list(power1and3=function(x) {x[1] && x[3]},
power1and2=function(x) {x[1] && x[2]}). If the list has no names, the functions will be referenced to as "func1", "func2", etc. in the output.

target

Target power that should be at least achieved. Either a numeric scalar between 0 and 1 or if parameter powerReqFunc is a list a numeric vector of the same length as powerReqFunc.

corr.sim

Covariance matrix under the alternative.

alpha

...

corr.test

Correlation matrix that should be used for the parametric test. If corr.test==NULL the Bonferroni based test procedure is used. Can contain NAs.

type

What type of random numbers to use. quasirandom uses a randomized Lattice rule, and should be more efficient than pseudorandom that uses ordinary (pseudo) random numbers.

upscale

Logical. If upscale=FALSE then for each intersection of hypotheses (i.e. each subgraph) a weighted test is performed at the possibly reduced level alpha of sum(w)*alpha, where sum(w) is the sum of all node weights in this subset. If upscale=TRUE all weights are upscaled, so that sum(w)=1.

n.sim

...

verbose

Logical, whether verbose output should be printed.

...

...

test

In the parametric case there is more than one way to handle subgraphs with less than the full alpha. If the parameter test is missing, the tests are performed as described by Bretz et al. (2011), i.e. tests of intersection null hypotheses always exhaust the full alpha level even if the sum of weights is strictly smaller than one. If test="simple-parametric" the tests are performed as defined in Equation (3) of Bretz et al. (2011).

Value

...

Examples


## Not run: 
graph <- BonferroniHolm(4)
powerReqFunc <- function(x) { (x[1] && x[2]) || x[3] }
#TODO Still causing errors / loops.
#sampSize(graph, alpha=0.05, powerReqFunc, target=0.8, mean=c(6,4,2) )
#sampSize(graph, alpha=0.05, powerReqFunc, target=0.8, mean=c(-1,-1,-1), nsim=100)
sampSize(graph, esf=c(1,1,1,1), effSize=c(1,1,1,1), 
         corr.sim=diag(4), powerReqFunc=powerReqFunc, target=0.8, alpha=0.05)
powerReqFunc=list('all(x[c(1,2)])'=function(x) {all(x[c(1,2)])},
                  'any(x[c(0,1)])'=function(x) {any(x[c(0,1)])})
sampSize(graph=graph, 
         effSize=list("Scenario 1"=c(2, 0.2, 0.2, 0.2), 
                      "Scenario 2"=c(0.2, 4, 0.2, 0.2)), 
         esf=c(0.5, 0.7071067811865476, 0.5, 0.7071067811865476),
         powerReqFunc=powerReqFunc, 
         corr.sim=diag(4), target=c(0.8, 0.8), alpha=0.025)

## End(Not run)

gMCP documentation built on May 29, 2024, 9:37 a.m.