sampler (version 0.2.4)

cpro: Calculate proportion and margin of error (unequal-sized cluster sample)

Description

Calculate proportion and margin of error (unequal-sized cluster sample)

Usage

cpro(df, numerator, denominator, ci = 95, na = "", N = 0)

Arguments

df

object containing data frame on which to perform analysis

numerator

variable in data frame for which you want to calculate proportion and margin of error

denominator

variable in data frame containing population sizes of unequal clusters

ci

(optional) confidence level for establishing a confidence interval using z-score (defaults to 95; restricted to 80, 85, 90, 95 or 99 as input)

na

(optional) value that you want to filter and exclude (defaults to include everything)

N

(optional) population universe (e.g. 10000, nrow(df)); if N value is passed as an argument, margin of error will be calculated using fpc

Value

Returns table of responses (n), proportions, margins of error, lower and upper bounds by factor for a given variable in a stratified sample

References

[1] Survey Sampling, L. Kish, 1965, Equation 6.3.4 [2] Sampling Techniques, W.G. Cochran, 1977, Equation 3.34

Examples

Run this code
# NOT RUN {
alresults <- ssamp(albania, 890, qarku)
cpro(df=alresults, numerator=totalVoters, denominator=zgjedhes, ci=95)
cpro(df=alresults, numerator=pd, denominator=validVotes, ci=95, N=5361)
# }

Run the code above in your browser using DataLab