moe: Calculate margin of error for simple probability samples

Description Usage Arguments Value Assumptions Finite population correction References See Also Examples

Description

moe calculates margin of error and confidence intervals for simple probability samples, as well as results formatted in accordance with American Psychological Association standards (APA6).

Usage

1
2
moe(proportion, n, conf.level = 0.95, digits = 2,
  population.correction = FALSE, population.size = NULL)

Arguments

proportion

value between 0 and 1 indicating the proportion, such as 0.30 for 30 percent.

n

sample size.

conf.level

confidence level (defaults to 0.95).

digits

number of decimal digits used when formatting the results as APA and human-readable messages (defaults to 2).

population.correction

whether or not results should be corrected by population size (defaults to FALSE), using the Finite Population Correction technique.

population.size

population size used by the population correction (defaults to NULL). Only used if population.correction is set to TRUE.

Value

a list with margin.of.error (margin of error), conf.level (confidence level), conf.lower (confidence interval lower bound), conf.upper (confidence interval upper bound), proportion (proportion), percentage (percentage), z.value (z-value from normal distribution), digits (number of digits used to format APA confidence intervals), n (sample size), population.corrected (whether or not the margin of error is corrected for population size), population.size (population size), fpc (finite population correction, between 0 and 1), sampling.fraction (sampling fraction, ratio of sample size to population size, between 0 and 1), error.uncorrected (margin of error before it is corrected for population size), and apa (APA6 style formatted confidence intervals).

Assumptions

moe assumes a normal distribution by calculating the z-value from qnorm, as well as simple random sampling (i.e., all observations have an equal probability of inclusion).

Finite population correction

When the sampling fraction (ratio of sample size to population size) is large, approximately 5 percent or more, the estimate of the standard error can be corrected by multiplying a Finite Population Correction. To use this correction, set the population.correction argument to TRUE and set the sample size for the population using the population.size argument.

References

Bondy, W. & Zlot, W. (1976). The Standard Error of the Mean and the Difference Between Means for Finite Populations. The American Statistician, 30, 96–97. doi:10.2307/2683803

See Also

qnorm()

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## Not run: 
# Margin of error for party with 30%
# of voters in a sample of 1,200.
moe(proportion=0.30, n=1200)

# Correct for population size (N=300,000),
# using 99% confidence level.
moe(proportion=0.30, n=1200, conf.level=0.99,
    population.correction=TRUE, population.size=300000)

# Get confidence interval.
m <- moe(proportion=0.30, n=1200)
m$conf.lower
m$conf.upper

# Show all information.
summary(m, digits=2)

# APA6 style confidence intervals.
as.character(m, digits=2)

# Print margin of error.
print(m, digits=2)

# 2-sample test for equality of proportions
# (Chi-square) using the minus operator.
m1 <- moe(proportion=0.33, n=1200)
m2 <- moe(proportion=0.40, n=1200)
m1 - m2

## End(Not run)

peterdalle/moe documentation built on May 6, 2019, 6:58 p.m.