nPP: Estimation of Sample Size via Power and Proportion

View source: R/nPP.R

nPPR Documentation

Estimation of Sample Size via Power and Proportion

Description

A formula to estimate the sample size using Power and Proportion; preferred when there exist literatures that provide the needed statistics for its computation.

Usage

nPP(alpha, power, proportion, delta)

Arguments

alpha

value set for Type I error

power

preferred power; indicated as 1 minus Type II error

proportion

estimated proportion of individuals meeting the inclusion criteria

delta

difference between proportions

Details

Computes for the sample size using the confidence level, delta, proportion and preferred power.

Value

Returns a character vector which presents the number of required samples for each group in the study.

Note

Unlike other formulas included in the package like Cochran and Smean, set alpha and power is converted to z-score by the nPP function

Author(s)

Paolo G. Hilado

Examples

nPP(.05, .8, 50, 12)
[1] "273 each group"

## The function is currently defined as
nPP <- function(alpha,power,proportion,delta){
  a <- qnorm(1-(alpha/2))
  p <- qnorm(power)
  x <- a + p
  x <- x*x
  b <- proportion*(100-proportion)
  c <- 2*x*b
  n <- c / (delta*delta)
  n <- ceiling(n)
  ans <- paste(n, "each group")
  print(ans)
}


Dcroix/RSamplingz documentation built on April 30, 2022, 8:33 a.m.