Skip to content

Instantly share code, notes, and snippets.

@felixlindemann
Created January 9, 2014 12:45
Show Gist options
  • Save felixlindemann/8333576 to your computer and use it in GitHub Desktop.
Save felixlindemann/8333576 to your computer and use it in GitHub Desktop.
Ermittlung von Stichprobengrößen
# Based on formula by
# Cochran, W. G. 1963. Sampling Techniques, 2nd Ed., New York: John Wiley and Sons, Inc.
# see also http://statistikberatung.blogspot.de/2008/03/samplesizer-kostenloses-tool-zur.html
get.SampleSize <- function(N, Z, p, e){
n <- (
Z^2 * p * (1-p) / e^2
) /
(
1 + (
Z^2 * p * (1-p) / e^2 -1
) / N
)
return(n)
}
N<- 14500 # Elemente in Grundgesamtheit
e<- 0.04 # Konfidenzniveau
p<- 0.5 # Fehlerwahrscheinlichkeit
Z <- 1.96 # Z-Wert d. Normalverteilung
get.SampleSize(N,Z,p,e)
# 576
e<- 0.05 # Konfidenzniveau
get.SampleSize(N,Z,p,e)
e<- 0.01 # Konfidenzniveau
get.SampleSize(N,Z,p,e)
N<- 15024
e<- 0.0378 # Konfidenzniveau
get.SampleSize(N,Z,p,e)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment