Prostate cancer (one-tailed)

It is estimated that at least half of the men who currently undergo an operation to remove prostate cancer suffer from a particular undesirable side effect. In an effort to reduce the likelihood of this side effect the FDA studied a new method of performing the operation. Out of 19 operations only 3 men suffered the unpleasant side effect. Is it safe to conclude the new method of operation is effective in reducing the side effect?

Let \(p\) be the probability of the patient experiencing the side effect. Then this is a lower-tailed test of

\[ \mathcal{H}_0: p \geq 0.5 \quad \mbox{ v.s. } \quad H_1: p < 0.5. \]

t <- 3
n <- 19
pstar <- 0.5
phi <- pbinom(t, n, pstar)
phi
## [1] 0.002212524

To find a confidence interval we need to find the value of \(p\) would yield \(\mathbb{P}(T \leq t) = \alpha\) for some choice of \(\alpha\).

alpha <- 0.05
f <- function(x, alpha, lower.tail=TRUE) { alpha - pbinom(t, n, x, lower.tail=lower.tail) }
soln <- uniroot(f, c(0,1), alpha=alpha)
pU <- soln$root
pU
## [1] 0.3594267
p <- seq(0,1, length=1000)
plot(p, pbinom(t, n, p), type="l", lwd=2, main="finding upper confidence limit")
abline(h=alpha, col="gray")
legend("topright", c("pbinom up to t=3 (n=19)", "alpha=0.05"), lty=1, lwd=c(2,1), col=c("black", "gray"))

qbeta(1-alpha, t+1, n-t)
## [1] 0.3594256

R has a built-in library for this sort of thing.

binom.test(t, n, alternative="less")
## 
##  Exact binomial test
## 
## data:  t and n
## number of successes = 3, number of trials = 19, p-value = 0.002213
## alternative hypothesis: true probability of success is less than 0.5
## 95 percent confidence interval:
##  0.0000000 0.3594256
## sample estimates:
## probability of success 
##              0.1578947

Mendelian inheritance (two-tailed)

Under simple Mendelian inheritance a cross between plants of two particular genotypes may be expected to produce progeny one-fourth of which are “dwarf” and three-fourths of which are “tall”. In an experiment to determine if the assumption of simple Mendelian inheritance is reasonable in a certain situation, a cross results in progeny having 243 dwarf plants and 682 tall plants.

If “class 1” denotes “tall”, then \(p^* = 3/4\) and \(T\) is the number of tall plants. The null hypothesis of simple Mendelian inheritance is equivalent under the model to \(\mathcal{H}_0: p = 3/4\), with the alternative of interest being two-sided, \(\mathcal{H}_1: p \ne 3/4\).

We may now commence with the test.

n <- 925
t <- 682
pstar <- 3/4
rhs <- seq(ceiling(n*pstar), n) 
tU <- sum(dbinom(rhs, n, pstar) <= dbinom(t, n, pstar))
tU
## [1] 220
phi <- pbinom(t, n, pstar) + pbinom(n - tU, n, pstar, lower.tail=FALSE)
phi
## [1] 0.3824916
2*pbinom(t, n, pstar)
## [1] 0.3920185

For the CI we follow the same procedure as above, except use \(\alpha/2\).

alpha <- 0.05
f <- function(x, alpha, lower.tail=TRUE) { alpha - pbinom(t, n, x, lower.tail=lower.tail) }
pU <- uniroot(f, c(0,1), alpha=alpha/2)$root
pL <- uniroot(f, c(0,1), alpha=alpha/2, lower.tail=FALSE)$root
c(pL, pU)
## [1] 0.7087742 0.7654085
c(qbeta(alpha/2, t+1, n-t+1), qbeta(1-alpha/2, t+1, n-t))
## [1] 0.7079776 0.7654066

Finally, we can do the whole thing with one call to a library routine.

binom.test(t, n, p=3/4)
## 
##  Exact binomial test
## 
## data:  t and n
## number of successes = 682, number of trials = 925, p-value =
## 0.3825
## alternative hypothesis: true probability of success is not equal to 0.75
## 95 percent confidence interval:
##  0.7076683 0.7654066
## sample estimates:
## probability of success 
##              0.7372973