Description Usage Arguments Value Assumptions Finite population correction References See Also Examples
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).
1 2 |
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 |
digits |
number of decimal digits used when formatting the results as APA and human-readable messages (defaults to |
population.correction |
whether or not results should be corrected by population size (defaults to |
population.size |
population size used by the population correction (defaults to |
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).
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).
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.
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
qnorm()
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.