Type: Package
Title: Sample Size Calculator under Complex Survey Design
Version: 0.1.0
Depends: R(≥ 2.10)
Suggests: roxygen2, knitr, rmarkdown, testthat (≥ 3.0.0)
Description: It helps in determination of sample size for estimating population mean or proportion under simple random sampling with or without replacement and stratified random sampling without replacement. When prior information on the population coefficient of variation (CV) is unavailable, then a preliminary sample is drawn to estimate the CV which is used to compute the final sample size. If the final size exceeds the preliminary sample size, then additional units are drawn; otherwise, the preliminary sample size is considered as final sample size. For stratified random sampling without replacement design, it also calculates the sample size in each stratum under different allocation methods for estimation of population mean and proportion based upon the availability of prior information on sizes of the strata, standard deviations of the strata and costs of drawing a sampling unit in the strata.For details on sampling methodology, see, Cochran (1977) "Sampling Techniques" https://archive.org/details/samplingtechniqu0000coch_t4x6.
License: GPL-2 | GPL-3 [expanded from: GPL (≥ 2.0)]
Encoding: UTF-8
Imports: stats, shiny, shinythemes, DT, bslib
RoxygenNote: 7.3.2
NeedsCompilation: no
Packaged: 2025-08-22 09:34:14 UTC; Asus
Author: Nobin Chandra Paul [aut, cre, cph], Pradip Basak [aut, cph]
Maintainer: Nobin Chandra Paul <ncp375@gmail.com>
Repository: CRAN
Date/Publication: 2025-08-27 16:40:08 UTC

Sample size calculator for estimation of population mean under SRS

Description

The SscSrsMean function calculates the sample size required for estimation of population mean based upon the availability of prior information on coefficient of variation (CV) of the population under Simple Random Sampling (SRS) with or without replacement sampling design for a given confidence level and relative error. Further, the function provides the required sample size when population CV is known whereas it provides both required sample size and additional sample units to be surveyed when population CV is unknown under both SRS with or without replacement.

Usage

SscSrsMean(CV_known, replace, alpha, re, N, preliminary_sample, cv_value = NA)

Arguments

CV_known

Logical. TRUE if CV of the population is known; FALSE otherwise.

replace

Logical. TRUE for SRSWR; FALSE for SRSWOR.

alpha

Level of significance (e.g., 0.05 for 5% level).

re

Relative error in the estimate (e.g., 0.1 for 10%).

N

Population size. Use NA for SRSWR.

preliminary_sample

Numeric vector. Preliminary sample data; NA if CV is known.

cv_value

Numeric. Known CV when CV_known = TRUE; ignored if CV_known = FALSE.

Details

Returns the sample size for estimation of the population mean under SRS with or without replacement. For unknown CV, also returns the number of extra units needed beyond the preliminary sample.

Value

A list with the following components:

Required sample size

The required sample size for the given inputs.

Additional sample units to be surveyed

Only for unknown CV: additional units beyond preliminary sample size.

References

Cochran, W. G. (1977). Sampling Techniques, 3rd Edition. New York: John Wiley & Sons.

Singh, D. and Chaudhary, F.S. (1986). Theory and Analysis of Sample Survey Designs. New York: John Wiley & Sons, Inc.

Sukhatme, P.V., Sukhatme, B.V., Sukhatme, S. and Asok, C. (1984). Sampling Theory of Surveys with Applications. Iowa State University Press, Ames and Indian Society of Agricultural Statistics, New Delhi.

Examples

# Known CV, SRSWOR
SscSrsMean(TRUE, FALSE, 0.05, 0.2, 100, NA, cv_value = 0.3)

# Unknown CV, SRSWOR
prelim <- c(12, 14, 8, 5, 36, 24, 18, 17, 6, 9)
SscSrsMean(FALSE, FALSE, 0.05, 0.2, 100, prelim)

# Known CV, SRSWR
SscSrsMean(TRUE, TRUE, 0.05, 0.2, NA, NA, cv_value = 0.3)


Sample size calculator for estimation of population proportion under SRS

Description

The SscSrsProp function calculates the sample size required for estimation of population proportion under Simple Random Sampling (SRS) with or without replacement sampling design for a given confidence level and relative error under the assumption than population CV is unknown. Further, the function provides the number of additional sample units to be surveyed over the preliminary sample under both SRS with or without replacement.

Usage

SscSrsProp(replace, alpha, re, N, preliminary_sample)

Arguments

replace

replace=TRUE, if sampling design is SRSWR and replace=FALSE, if sampling design is SRSWOR.

alpha

Level of significance value, alpha=0.01 at 1 percent level of significance and alpha=0.05 at 5 percent level of significance.

re

Relative error in the estimation of population proportion (e.g. 0.1, 0.5).

N

Population size. When sampling design is SRSWR, then write NA.

preliminary_sample

Values of the study variable (in 0 or 1) for the preliminary sample.

Details

This function returns the required sample size as well as additional sample units to be surveyed over the preliminary sample for both SRS with or without replacement sampling design.

Value

A list with the following components:

Required sample size

Sample size required for estimation of population proportion.

Additional sample units to be surveyed

Additional sample units to be surveyed over the preliminary sample for estimation of population proportion. If the value of additional sample units to be surveyed is negative, then preliminary sample is considered as the final sample.

References

Cochran, W. G. (1977). Sampling Techniques, 3rd Edition. New York: John Wiley & Sons, Inc.

Singh, D. and Chaudhary, F.S. (1986). Theory and Analysis of Sample Survey Designs. New York: John Wiley & Sons, Inc.

Sukhatme, P.V., Sukhatme, B.V., Sukhatme, S. and Asok, C. (1984). Sampling Theory of Surveys with Applications. Iowa State University Press, Ames and Indian Society of Agricultural Statistics, New Delhi.

Examples

# Calculate sample size for SRSWOR design for estimation of population proportion
preliminary_sample=c(1,0,1,1,1,0,0,0,1,1)
SscSrsProp(FALSE, 0.05, 0.2, 500, preliminary_sample)
# Calculate sample size for SRSWR design for estimation of population proportion
preliminary_sample=c(1,0,1,1,0,1,1,1,0,0,0,1,1,1,1)
SscSrsProp(TRUE, 0.05, 0.2, NA, preliminary_sample)

Sample size calculator in each stratum under Stratified Random Sampling

Description

The SscStr function calculates sample size in each stratum under different allocation methods in Stratified Random Sampling without replacement design which is required for estimation of population mean and proportion based upon the availability of prior information on sizes of the strata, standard deviations of the strata and costs of drawing a sampling unit in the strata.

Usage

SscStr(Allocation, n, Strata_Size, Strata_Standard_deviation, Strata_Cost)

Arguments

Allocation

The method of allocation of sample sizes in the strata. It can be Equal, Proportional, Neyman and Optimum. For Equal and Proportional allocation, n and Strata_Size are to be provided whereas for Neyman allocation, n, Strata_Size and Strata_Standard_deviation are required. For, Optimum allocation, n, Strata_Size, Strata_Standard_deviation and Strata_Cost are to be provided.

n

Total sample size that is to be allocated.

Strata_Size

Sizes of the strata in the population.

Strata_Standard_deviation

Standard deviations of the strata in the population.

Strata_Cost

Costs of drawing a sampling unit in the strata.

Details

This function returns the allocated sample size in each stratum under Stratified Random Sampling without replacement design which is required for estimation of population mean and proportion.

Value

A list with the following components:

Strata wise allocated sample size

Allocated sample size in each strata.

References

Cochran, W. G. (1977). Sampling Techniques, 3rd Edition. New York: John Wiley & Sons, Inc.

Singh, D. and Chaudhary, F.S. (1986). Theory and Analysis of Sample Survey Designs. New York: John Wiley & Sons, Inc.

Sukhatme, P.V., Sukhatme, B.V., Sukhatme, S. and Asok, C. (1984). Sampling Theory of Surveys with Applications. Iowa State University Press, Ames and Indian Society of Agricultural Statistics, New Delhi.

Examples

# Calculates sample size in each stratum under Equal allocation
SscStr("Equal", 100, c(500,300,200), NA, NA)
# Calculates sample size in each stratum under Proportional allocation
SscStr("Proportional", 100, c(500,300,200), NA, NA)
# Calculates sample size in each stratum under Neyman's allocation
SscStr("Neyman", 100, c(500,300,200), c(10,20,30), NA)
# Calculates sample size in each stratum under Optimum allocation
SscStr("Optimum", 100, c(500,300,200), c(10,20,30), c(5,10,15))

Run Sample Size Calculator 'Shiny' App

Description

Launches the 'Shiny' app for Sample Size Calculation.

Usage

run_SampleSizeCalc_app()

Value

Launches a 'Shiny' application.

Examples

if (interactive()) {
  run_SampleSizeCalc_app()
}