Description Usage Arguments Value Examples
This function returns the number of elements to be sampled in a stratified based survey. If the method choosen is 'prop' or 'optimum', the function return the allocation too.
| 1 2 | 
| data | The data.frame containing the variable denoted as the cluster. | 
| stratanames | The variable name of the considered strata. Can be a vector of variable names. | 
| alpha | (1 - confidence level). | 
| moe | Margin of error. | 
| S2 | The variance, as σ^2. Not necessary if  | 
| pq | The variance, as P(1-P). Not necessary if  | 
| V | The variance, as (d/t)^2. Not necessary if  | 
| N | Population size. | 
| method | A string with  | 
The value (integer) of the number of elements to sample in stratified sampling. If prop or optimum
where used, the function returns a list with the elements per strata.
Total number of elements in the sample.
The allocation in each strata.
| 1 2 3 4 5 6 7 8 9 10 | library(survey)
data("api")
nStrata(apipop,stratanames = "stype", alpha = 0.05, moe = 0.05,
        pq = 0.25, N = nrow(apipop), method = "prop")
nStrata(apipop,stratanames = "stype", alpha = 0.05, moe = 0.05,
        pq = 0.25, N = nrow(apipop), method = "optimum")
### Cochran's example (Cochran, W. G. (2007). Sampling techniques. John Wiley & Sons. p. 106-107)
data_cochran=data.frame(stratum=rep(c(1:6),c(13,18,26,42,73,24)))
nStrata(data_cochran,stratanames = "stratum", N=196, method = "optimum",
        S2=c(325^2,190^2,189^2,82^2,86^2,190^2),V=7974976/196^2)
 | 
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.