sample.size.prop.Rd
The function sample.size.prop
returns the sample size needed for proportion estimation either with or without consideration of finite population correction.
sample.size.prop(e, P = 0.5, N = Inf, level = 0.95)
e | positive number specifying the precision which is half width of confidence interval |
---|---|
P | expected proportion of events with domain between values 0 and 1. Default is |
N | positive integer for population size. Default is |
level | coverage probability for confidence intervals. Default is |
For meaningful calculation, precision e
should be chosen smaller than 0.5, because the domain of P
is between values 0 and 1. Furthermore, precision e
should be smaller than proportion P
, respectively (1-P)
.
The function sample.size.prop
returns a value, which is a list consisting of the components
is a list of call components e
precision, P
expected proportion, N
population size, and level
coverage probability for confidence intervals
estimate of sample size
Kauermann, Goeran/Kuechenhoff, Helmut (2010): Stichproben. Methoden und praktische Umsetzung mit R. Springer.
Juliane Manitz
## 1) examples with different precisions # precision 1% for election forecast of SPD in 2005 sample.size.prop(e=0.01, P=0.5, N=Inf)#> #> sample.size.prop object: Sample size for proportion estimate #> Without finite population correction: N=Inf, precision e=0.01 and expected proportion P=0.5 #> #> Sample size needed: 9604 #>#> #> sample.size.prop object: Sample size for proportion estimate #> Without finite population correction: N=Inf, precision e=0.01 and expected proportion P=0.3861 #> #> Sample size needed: 9106 #># precision 5% for questionnaire sample.size.prop(e=0.05, P=0.5, N=300)#> #> sample.size.prop object: Sample size for proportion estimate #> With finite population correction: N=300, precision e=0.05 and expected proportion P=0.5 #> #> Sample size needed: 169 #>sample.size.prop(e=0.05, P=0.5, N=Inf)#> #> sample.size.prop object: Sample size for proportion estimate #> Without finite population correction: N=Inf, precision e=0.05 and expected proportion P=0.5 #> #> Sample size needed: 385 #># precision 10% sample.size.prop(e=0.1, P=0.5, N=300)#> #> sample.size.prop object: Sample size for proportion estimate #> With finite population correction: N=300, precision e=0.1 and expected proportion P=0.5 #> #> Sample size needed: 73 #>sample.size.prop(e=0.1, P=0.5, N=1000)#> #> sample.size.prop object: Sample size for proportion estimate #> With finite population correction: N=1000, precision e=0.1 and expected proportion P=0.5 #> #> Sample size needed: 88 #>## 2) tables in the book # table 2.2 P_vector <- c(0.2, 0.3, 0.4, 0.5) N_vector <- c(10, 100, 1000, 10000) results <- matrix(NA, ncol=4, nrow=4) for (i in 1:length(P_vector)){ for (j in 1:length(N_vector)){ x <- try(sample.size.prop(e=0.1, P=P_vector[i], N=N_vector[j])) if (class(x)=='try-error') {results[i,j] <- NA} else {results[i,j] <- x$n} } } dimnames(results) <- list(paste('P=',P_vector, sep=''), paste('N=',N_vector, sep='')) results#> N=10 N=100 N=1000 N=10000 #> P=0.2 9 39 58 62 #> P=0.3 9 45 75 81 #> P=0.4 10 48 85 92 #> P=0.5 10 49 88 96# table 2.3 P_vector <- c(0.5, 0.1) e_vector <- c(0.1, 0.05, 0.03, 0.02, 0.01) results <- matrix(NA, ncol=2, nrow=5) for (i in 1:length(e_vector)){ for (j in 1:length(P_vector)){ x <- try(sample.size.prop(e=e_vector[i], P=P_vector[j], N=Inf)) if (class(x)=='try-error') {results[i,j] <- NA} else {results[i,j] <- x$n} } } dimnames(results) <- list(paste('e=',e_vector, sep=''), paste('P=',P_vector, sep='')) results#> P=0.5 P=0.1 #> e=0.1 97 35 #> e=0.05 385 139 #> e=0.03 1068 385 #> e=0.02 2401 865 #> e=0.01 9604 3458