Let two independent random variables, $Y_1$ and $Y_2$ that have binomial distribution have parameters $n_1 = n_2 = 100$, $p_1$ and $p_2$, respectively, be observed to be equal to $y_1 = 50$ and $y_2 = 40$. Determine an approximate $90\%$ confidence interval for $p_1 - p_2$.

I'm pretty new to confidence intervals and wanted help on this problem from my book. I have tried to apply the following definition:

Let $X_1, X_2, \ldots, X_n$ be a sample on a random variable $X$, where $X$ has p.d.f. $f(x;\theta)$, where $\theta\in \Omega$. Let $0 < \alpha < 1$ be specified. Let $L = L(X_1, \ldots, X_n)$ and $U = U(X_1, \ldots, X_n)$ be two statistics. We say that $(L, U)$ is a $(1 - \alpha)100\%$ confidence interval for $\theta$ if $1 - \alpha = P_{\theta}(\theta \in (L, U))$.

However, I have been having trouble applying this definition directly. I can identify $\alpha = 0.1$ here, which means that I think we want $P(L < p_1 - p_2 < U) = 0.9$. Now I'm really not sure how to use this information to get the answer; I have no clue where the observed values would come into play.


1 Answer 1


There are many ways of doing this. I will show one modern way, using profile likelihood. First we use binomial regression, but with an identity link function. That is not usual, but in cases such as this, where the only regressor is a factor variable, it can work fine. Then we can profile the log likelihood function to get an approximate confidence interval. With code in R this can look like, with your data:

mydat <- data.frame(n=c(100, 100),  y=c(50, 40), 

mod0 <- glm(cbind(y, n-y)  ~  group, 

confint(mod0, 2)

giving the following output

Waiting for profiling to be done...
      2.5 %      97.5 % 
-0.23531653  0.03781719 

This likelihood profile confidence interval corresponds to the likelihood ratio test. For some details and other examples see Constructing confidence intervals based on profile likelihood, Profile Likelihood: why optimize all other parameters while tracing a profile for a partitcular one?, What is the relationship between profile likelihood and confidence intervals?

Some similar posts, with answers giving other methods: P value and confidence interval for two sample test of proportions disagree, Comparing the distributions of proportions in two groups, Change in binomial proportion confidence interval

  • $\begingroup$ Thanks for your reply. I would like to use the definition that I have been provided (i.e., I don't want to use any computing software) to find the answer. How can I do this? $\endgroup$
    – user298588
    Commented Mar 11, 2021 at 14:25
  • $\begingroup$ Then you will have to use one of the standard (asymptotic, that is, based somehow on a normal approximation) formulas. I will add to the answer, but look at some of the links in the last paragraph. $\endgroup$ Commented Mar 11, 2021 at 14:27
  • $\begingroup$ I find this answer of yours, which calculates the profile likelihood confidence interval "by hand", more informative. $\endgroup$
    – dipetkov
    Commented Dec 26, 2022 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.