Proportional sampling data in r

The function Sprop estimates the proportion out of samples either with or without consideration of finite population correction. Different methods for calculating confidence intervals for example based on binomial distribution (Agresti and Coull or Clopper-Pearson) or based on hypergeometric distribution are used.

Usage

Sprop(y, m, n = length(y), N = Inf, level = 0.95) 

Arguments

vector of sample data containing values 0 and 1

an optional non-negative integer for number of positive events

an optional positive integer for sample size. Default is n=length(y) .

positive integer for population size. Default is N=Inf , which means calculations are carried out without finite population correction.

coverage probability for confidence intervals. Default is level=0.95 .

Details

Sprop can be called by usage of a data vector y with the observations 1 for event and 0 for failure. Moreover, it can be called by specifying the number of events m and trials n .

Value

The function Sprop returns a value, which is a list consisting of the components

is a list of call components: y sample data, m number of positive events in the sample, n sample size, N population size, level coverage probability for confidence intervals

standard error of the proportion estimate

is a list of confidence interval boundaries for proportion.
In case of a finite population of size N , it is given approx , the hypergeometric confidence interval with normal distribution approximation, and exact , the exact hypergeometric confidence interval.
If the population is very large N=Inf , it is calculated bin , the binomial confidence interval, which is asymptotic, cp the exact confidence interval based on binomial distribution (Clopper-Pearson), and ac , the asymptotic confidence interval based on binomial distribution by Wilson (Agresti and Coull (1998)).

In case of finite population of size N , it is given a list of confidence interval boundaries for number in population with approx , the hypergeometric confidence interval with normal distribution approximation, and exact , the exact hypergeometric confidence interval.

Author(s)

References

Kauermann, Goeran/Kuechenhoff, Helmut (2010): Stichproben. Methoden und praktische Umsetzung mit R. Springer.

Agresti, Alan/Coull, Brent A. (1998): Approximate Is Better than 'Exact' for Interval Estimation of Binomial Proportions. The American Statistician, Vol. 52, No. 2 , pp. 119-126.

See Also

Examples

# 1) Survey in company to upgrade office climate Sprop(m=45, n=100, N=300) Sprop(m=2, n=100, N=300) # 2) German opinion poll for 03/07/09 with # (http://www.wahlrecht.de/umfragen/politbarometer.htm) # a) 302 of 1206 respondents who would elect SPD. # b) 133 of 1206 respondents who would elect the Greens. Sprop(m=302, n=1206, N=Inf) Sprop(m=133, n=1206, N=Inf) # 3) Rare disease of animals (sample size n=500 of N=10.000 animals, one infection) # for 95% one sided confidence level use level=0.9 Sprop(m=1, n=500, N=10000, level=0.9) # 4) call with data vector y y