| Title: | Sample Size Calculation Using Cochran's Formula |
|---|---|
| Description: | Provides functions to calculate the minimum required sample size for surveys and studies using Cochran's formula, including the finite population correction. Cochran's formula is a standard method in survey methodology for determining sample size based on a desired margin of error, confidence level, and (optionally) known population size. All parameters (margin of error, confidence level, and expected proportion) are fully adjustable by the user rather than fixed to any convention. |
| Authors: | Yosley Carrero [aut, cre] |
| Maintainer: | Yosley Carrero <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.0 |
| Built: | 2026-10-08 10:07:01 UTC |
| Source: | https://github.com/yosleycarrero2025/cochransize |
Calculates the minimum sample size required for a large (effectively infinite) population using Cochran's formula:
cochran_n(p = 0.5, e = 0.05, conf.level = 0.95)cochran_n(p = 0.5, e = 0.05, conf.level = 0.95)
p |
Estimated proportion of the population expected to have the
attribute of interest. Defaults to |
e |
Desired margin of error (as a decimal, e.g. |
conf.level |
Confidence level for the estimate. Defaults to
|
A single numeric value: the unadjusted sample size n0
(not rounded, and without any finite population correction).
cochran_n() cochran_n(p = 0.3, e = 0.03, conf.level = 0.99) cochran_n(e = 0.02, conf.level = 0.90)cochran_n() cochran_n(p = 0.3, e = 0.03, conf.level = 0.99) cochran_n(e = 0.02, conf.level = 0.90)
Adjusts an unadjusted Cochran sample size (n0) for a finite,
known population size N, using:
cochran_n_adj(n0, N)cochran_n_adj(n0, N)
n0 |
The unadjusted sample size, typically the output of
|
N |
The known size of the population being sampled from. |
A single numeric value: the finite-population-corrected sample
size (not rounded). A warning is issued if n0 exceeds N,
since that indicates the unadjusted sample size already exceeds the
entire population.
n0 <- cochran_n(p = 0.5, e = 0.05, conf.level = 0.95) cochran_n_adj(n0, N = 1000)n0 <- cochran_n(p = 0.5, e = 0.05, conf.level = 0.95) cochran_n_adj(n0, N = 1000)
Computes the sample size required for a survey or study using Cochran's
formula, optionally applying the finite population correction when a
known population size N is supplied. Wraps cochran_n
and cochran_n_adj into a single call with readable output.
cochran_sample_size(N = NULL, p = 0.5, e = 0.05, conf.level = 0.95)cochran_sample_size(N = NULL, p = 0.5, e = 0.05, conf.level = 0.95)
N |
Optional known population size. If supplied, the finite population correction is applied. If omitted, the population is treated as effectively infinite and only the unadjusted sample size is returned. |
p |
Estimated proportion of the population expected to have the
attribute of interest. Defaults to |
e |
Desired margin of error (as a decimal, e.g. |
conf.level |
Confidence level. Defaults to |
An object of class "cochran_size" (a list) containing:
Unadjusted sample size, rounded up to the nearest integer.
Finite-population-corrected sample size, rounded up
to the nearest integer, or NA if N was not supplied.
The input parameters used.
# Large / unknown population, 95% confidence, 5% margin of error cochran_sample_size(e = 0.05, conf.level = 0.95) # Known finite population of 2,000 cochran_sample_size(N = 2000, e = 0.05, conf.level = 0.95) # Custom expected proportion, 99% confidence, 3% margin of error cochran_sample_size(N = 500, p = 0.3, e = 0.03, conf.level = 0.99)# Large / unknown population, 95% confidence, 5% margin of error cochran_sample_size(e = 0.05, conf.level = 0.95) # Known finite population of 2,000 cochran_sample_size(N = 2000, e = 0.05, conf.level = 0.95) # Custom expected proportion, 99% confidence, 3% margin of error cochran_sample_size(N = 500, p = 0.3, e = 0.03, conf.level = 0.99)
Print Method for cochran_size Objects
## S3 method for class 'cochran_size' print(x, ...)## S3 method for class 'cochran_size' print(x, ...)
x |
An object of class |
... |
Additional arguments (unused). |
Invisibly returns x.