rsample: Formula based on https://goo.gl/7oWC9F

Description Usage Arguments Value Examples

View source: R/rsample.R

Description

Formula based on https://goo.gl/7oWC9F

Usage

1
2
rsample(population = 1e+09, confidence_interval = 0.95,
  error_margin = 0.05, response_distribution = 0.5)

Arguments

population

Size of the entire population from which to draw the sample. Defaults to an arbitrarily large population, giving a recommend sample size for the worst case scenario.

confidence_interval

Confidence that the interval within +/- margin of error contains the true parameter. Smaller interval requires larger sample size.

error_margin

Statistic expressing the amount of random sampling error in a survey's results. The larger the margin of error, the less confidence one should have that the poll's reported results are close to the "true" figures. Smaller margin of error requires larger sample size.

response_distribution

Expected distribution of responses, with 50/50 being the "worst case". Known expected distribution decreases the sample size.

Value

The recommended sample size.

Examples

1
2
3
4
5
6
7
8
9
    rsample()
    rsample(population = 15000, confidence_interval = .9, error_margin = .1)
    {
      population = c(100, 200, 30000, 400000)
      sample_size_95_5 = rsample(population)
      sample_size_90_10 = rsample(population, confidence_interval = .9, error_margin = .1)
      data.frame(population, sample_size_95_5, sample_size_90_10)
    }
    plot(rsample(seq(1, 30000)) ~ seq(1, 30000), type = "l")

lukaszkruk/Rsample documentation built on Nov. 4, 2019, 5:13 p.m.