R: Calculate power or sample size for any 2x2 test.

uncondPower2x2 {exact2x2} | R Documentation

## Calculate power or sample size for any 2x2 test.

### Description

The function `Power2x2` and `SS2x2` calculates the power or sample size for any 2x2 test, while the function `uncondPower2x2` calculates power for only tests supported by `uncondExact2x2Pvals`.

### Usage

    Power2x2(n1, n2, theta1, theta2, alpha, pvalFunc, ...)

    uncondPower2x2(n1,n2, theta1, theta2, alpha, ...)

    SS2x2(theta1, theta2, alpha, pvalFunc, power=0.90,
      n1start=10, increaseby=1, n2.over.n1=1,
      maxiter=50, printSteps=TRUE, ...)

### Arguments

`n1` | sample size in group 1
`n2` | sample size in group 2
`theta1` | probability of success in group 1
`theta2` | probability of success in group 2
`alpha` | significance level
`pvalFunc` | function that inputs x1,n1,x2,n2 and outputs a p-value.
`power` | target power
`n1start` | value of n1 for first iteration
`increaseby` | positive integer, how much to increase n1 by for each iteration
`n2.over.n1` | ratio of n2/n1
`maxiter` | maximum number of iterations
`printSteps` | logical, should the power and sample size be printed after each iteration?
`...` | arguments passed to `uncondExact2x2Pvals` (for `uncondPower2x2`), or to `Power2x2` (for `SS2x2`). Not used and saved for future use for `Power2x2`.

### Details

The function `Power2x2` is a very simple function to calculate power. It calculates power where rejection is when the p-value from `pvalFunc` is less than or equal to `alpha`. The function `SS2x2` repeatedly calls `Power2x2` as it increases the sample size, stopping when the power is greater than `'power'`.

The function `uncondPower2x2` is similar except the p-values are calculated by `uncondExact2x2Pvals`.

### Value

the power functions return only the power. The sample size function returns a list of class 'htest.power'.

### See Also

For power and sample size for conditional exact tests (e.g., Fisher's exact tests) see `power2x2` and `ss2x2`.

### Examples

    library(exact2x2)
    Power2x2(3,4,.1,.9,0.025, pvalFunc=
      function(x1,n1,x2,n2){
          boschloo(x1,n1,x2,n2, alternative="greater",
            or=1,tsmethod="central", midp=TRUE)$p.value
      }
    )
    ##
    ## Not run:
    SS2x2(.1,.9,0.025, n1start=5, pvalFunc=
               function(x1,n1,x2,n2){
                 boschloo(x1,n1,x2,n2, alternative="greater",
                          or=1,tsmethod="central", midp=TRUE)$p.value
               }
    )

    ## End(Not run)

[Package exact2x2 version 1.6.3 Index]