Skip to content

Instantly share code, notes, and snippets.

@abikoushi
Created December 24, 2014 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abikoushi/10fd8bc0e408191d80cf to your computer and use it in GitHub Desktop.
Save abikoushi/10fd8bc0e408191d80cf to your computer and use it in GitHub Desktop.
sample size calculator from width of approximate confidence interval of mother ratio.
size_calc <-function(L,p,alpha=0.05){
ceiling(((qnorm(alpha/2) ^ 2) *p*(1-p))/L^2)
}
@abikoushi
Copy link
Author

Example

size_calc(L=0.01,p=0.2)

[1] 6147

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment