Let $X_1$ and $X_2$ be two binomal random variable with respective parameters $n_1$, $p_1$, $n_2$ and $p_2$. Let $x_1$ and $x_2$ be observations of $X_1$ and $X_2$ respectively. I want to try different null hypotheses. If null hypothesis $H_0: p_1=p_2$, we can derive $P(-g(\alpha)<\frac{p_2-p1}{se(p_1-p_2)}<g(\alpha)|H_0)$ easily and check whether is it below $\alpha$ the level of significance ($g(\alpha)=\Phi^{-1}(\alpha/2)$) . But how to do if the null hypothesis is for example $H_0:p2-p1<v$ with $0<v<1$?
1 Answer
Let us reparametrize your problem, I will assume $X_1$ and $X_2$ are independent (you did not specify). Let $\theta = p_2-p_1$ and now $$ X_1 \sim \mathcal{Binom}(n_1, p), \quad X_2\sim\mathcal{Binom}(n_2,p+\theta) $$ and the null hypothesis is $H_0\colon \theta < \nu$, where $0<\nu < 1$ is a prespecified constant. In this formulation, $\theta$ is the focus parameter and $p$ is incidental. So it is natural to focus on the profile likelihood function of $\theta$, profiling out $p$.
This is similar to the situation in
but not the same. The code there can be adapted for this problem. I will do so later when I have some time.
But there is one big difference: Your hypothesis is one-sided, so it corresponds to a one-sided confidence interval. But that can be got from the profile likelihood function as easily as the usual two-sided interval.