Single Proportion
Menu location: Analysis_Proportions_Single.
This function compares an observed single binomial proportion with an expected proportion.
expected proportion (binomial parameter) = pi
successes = r
observations/trials = n
observed proportion p = r / n
The expected proportion (pi) is the probability of success on each trial, for example pi = 0.5 for coming up heads on the toss of a coin. The sign test is basically a single proportion test based on pi = 0.5. Some authors refer to this method as a "binomial test".
StatsDirect provides an exact confidence interval and an approximate mid-P confidence interval for the single proportion. You are also given exact P and exact mid-P hypothesis tests for the proportion in comparison with an expected proportion, i.e. null hypothesis that p = pi (Armitage and Berry, 1994; Gardner and Altman, 1989).
Assumptions:
- two mutually exclusive outcomes
- random sample
Consider using mid-P values and intervals when you have several similar studies to consider within an overall investigation (Armitage and Berry, 1994; Barnard, 1989).
Technical Validation
The Clopper-Pearson method is used for the exact confidence interval and the Newcombe-Wilson method is used for the mid-P confidence interval (Newcombe, 1998c). Mid-P probabilities are found by subtracting half the exact probability for the observed count from the cumulative total; this subtraction is done on each side for the two sided result.
The P values are exact cumulative binomial probabilities, whatever the size of the sample. The two sided P value is the sum of the probabilities of the counts that are no more probable than the observed count; with an expected proportion of 0.5 this is twice the one sided P value, or 1 if that is more.
Example
From Armitage and Berry (1994, p. 119).
In a trial of two analgesics, X and Y, 100 patients tried each drug for a week. The trial order was randomized. 65 out of 100 preferred drug Y.
To analyse these data in StatsDirect you must select single proportion from the proportions section of the analysis menu. To select a 95% confidence interval just press enter when you are presented with the confidence interval menu. Enter n as 100 and r as 65. Enter the binomial test proportion as 0.5, this is because you would expect 50% of an infinite number of patients to prefer drug Y if there was no difference between X and Y.
For this example:
Total = 100, response = 65
Proportion = 0.65
Exact (Clopper-Pearson) 95% confidence interval = 0.548151 to 0.742706
Using null hypothesis that the population proportion equals 0.5
Binomial one sided P = 0.0018
Binomial two sided P = 0.0035
Approximate (Wilson) 95% mid-P confidence interval = 0.552544 to 0.736358
Binomial one sided mid-P = 0.0013
Binomial two sided mid-P = 0.0027
Here we can conclude that the proportion was statistically significantly different from 0.5. With 95% confidence we can state that the true population value for the proportion lies somewhere between 0.55 and 0.74.
R code
This R code reproduces the example above. It needs no packages and was checked with R 4.6.1. Paste it into R, or save it as a script and run it.
# Single proportion: the StatsDirect help example (Armitage and Berry 1994, p. 119,
# 65 of 100 patients preferred analgesic Y) in R
n <- 100
r <- 65
pi0 <- 0.5 # the expected proportion under the null
# R's standard test gives the exact (Clopper-Pearson) confidence interval and an
# exact two sided P. StatsDirect's two sided P is the total probability of the
# counts no more likely than the observed count; the two agree here and in the
# other cases tried (for example 7 of 12 against 0.3: 0.0524 from both).
print(binom.test(r, n, p = pi0))
# The report's lines, to 6 decimal places, P values to 4
six <- function(x) formatC(x, digits = 6, format = "f", drop0trailing = TRUE)
pv <- function(p) {
if (p < 0.0001) "P < 0.0001" else
paste("P =", formatC(p, digits = 4, format = "f", drop0trailing = TRUE))
}
ci <- binom.test(r, n, p = pi0)$conf.int
cat("Total = ", n, ", response = ", r, "\n", sep = "")
cat("Proportion =", six(r / n), "\n")
cat("Exact (Clopper-Pearson) 95% confidence interval =", six(ci[1]), "to", six(ci[2]),
"\n")
# One sided P: the smaller of the two tail probabilities, each including the
# observed count (alternative = "less" and "greater" in binom.test give them)
lower <- pbinom(r, n, pi0) # P(count <= r)
upper <- pbinom(r - 1, n, pi0, lower.tail = FALSE) # P(count >= r)
cat("Binomial one sided", pv(min(lower, upper)), "\n")
cat("Binomial two sided", pv(binom.test(r, n, p = pi0)$p.value), "\n")
# The Wilson score interval, which prop.test gives when its continuity
# correction is turned off
wilson <- prop.test(r, n, correct = FALSE)$conf.int
cat("Approximate (Wilson) 95% mid-P confidence interval =", six(wilson[1]), "to",
six(wilson[2]), "\n")
# Mid-P: half the probability of the observed count is taken off the smaller
# tail, and the two sided mid-P is twice the one sided
mid <- min(lower, upper) - dbinom(r, n, pi0) / 2
cat("Binomial one sided mid-", pv(mid), "\n", sep = "")
cat("Binomial two sided mid-", pv(2 * mid), "\n", sep = "")