You can use the equivalence between confidence intervals and hypothesis testing: Can we reject a null hypothesis with confidence intervals produced via sampling rather than the null hypothesis? Then you will compute the confidence interval for the difference of the means and reject the null hypothesis when none of the values between $\pm \delta$ are inside the interval.
But with this method you will reject the null hypothesis less often than the aimed significance level (ie. the p-value is overestimates, too high, and the power of the test is less). This difference arrises because confidence intervals relate to point hypotheses, which is not your case.
Graphical view of the sample distribution of $\bar{x}-\bar{y}$ and $\hat{\sigma}$
The images below sketch two situations for a t-test:
- When we compare two samples with equal size and variance and the null hypothesis is $$H_0: \mu_y-\mu_x = 0$$ then we look at the value of the t-statistic, which relates to the likelihood-ratio. $$t = \frac{1}{\sqrt{2/n}} \frac{d}{s_p}$$
- When we use instead the null hypothesis $$H_0: \vert \mu_y-\mu_x \vert \leq \delta$$
then the likelihood ratio test will work out the same and be like the t-statistic but now the boundaries are shifted to the left and the right.
In the image below the boundaries for the t-value of a 95% significance test are drawn. These boundaries are compared with sample distributions of the standard deviation and difference of means for samples of size 5. The $X$ and $Y$ are normal distributed with equal variance and equal means, except in the lower image where the means differ by $\mu_y-\mu_X = 0.5$.
Likelihood ratio test, T-test with shifted boundaries, not ideal
In the first image, you see that 5% of the samples lead to a rejection of the hypothesis (as designed by setting the level at 95%). However, in the lower image, the rejection rate is lower and not equal to 5% (Because the boundaries are wider due to the shift $\delta$), and the nominal p-value of 5% overestimates the actual p-value.
So possibly one can choose to draw the boundaries more narrow. But for large $s_p$ you get closer to the current boundaries (Intuitively you can say that $\delta$ becomes less important, relatively smaller, when the variance of the variables is large).
The reason is that we do not need to necessarily use the likelihood ratio test, is that we are not dealing with a simple hypothesis. According to the Neyman-Pearson lemma the likelihood ratio test is the most powerful test. But, that is only true when the hypotheses are simple hypotheses (like $H_0: \mu_y-\mu_x = 0$), and we have a composite hypothesis (like $H_0: -\delta \leq \mu_y-\mu_x \leq \delta$). For a composite hypothesis the likelihood ratio test may not always give the specified significance level (we choose boundaries for the likelihood ratio according to the worst case).
So we can make sharper boundaries than the likelihood ratio test. However, there is no unique way to do this.
R-code for the images:
nsim <- 10^4
nsmp <- 5
rowDevs <- function(x) {
n <- length(x[1,])
sqrt((rowMeans(x^2)-rowMeans(x)^2)*n/(n-1))
}
### simulations
set.seed(1)
x <- matrix(rnorm(nsim*nsmp),nsim)
y <- matrix(rnorm(nsim*nsmp),nsim)
### statistics of difference and variance
d <- rowMeans(y)-rowMeans(x)
v <- (0.5*rowDevs(x)+0.5*rowDevs(y))
## colouring 5% points with t-values above/below qt(0.975, df = 18)
dv_slope <- qt(0.975, df = 18)*sqrt(2/nsmp)
col <- (d/v > dv_slope)+(d/v < -dv_slope)
### plot points
plot(d,v, xlim = c(-4,4), ylim = c(0,1.5),
pch = 21, col = rgb(col,0,0,0.1), bg = rgb(col,0,0,0.1), cex = 0.5,
xlab = expression(d == bar(y)-bar(x)),
ylab = expression(s[p] == sqrt(0.5*s[x]+0.5*s[y])),
xaxs = "i", yaxs = "i",
main = expression(H[0] : mu[y]-mu[x]==0))
lines(c(0,10),c(0,10)/dv_slope, col = 1, lty = 2)
lines(-c(0,10),c(0,10)/dv_slope, col = 1, lty = 2)
## colouring 5% points with t-values above/below qt(0.975, df = 18)
dlt <- 0.5
## colouring 5% points with t-values above/below qt(0.975, df = 18)
dv_slope <- qt(0.975, df = 18)*sqrt(2/nsmp)
col <- ((d-2*dlt)/v > dv_slope)+((d)/v < -dv_slope)
### plot points
plot(d-dlt,v, xlim = c(-4,4), ylim = c(0,1.5),
pch = 21, col = rgb(col,0,0,0.1), bg = rgb(col,0,0,0.1), cex = 0.5,
xlab = expression(d == bar(y)-bar(x)),
ylab = expression(s[p] == sqrt(0.5*s[x]+0.5*s[y])),
xaxs = "i", yaxs = "i",
main = expression(H[0] : "|" * mu[x]-mu[y] * "|" <= delta))
lines(c(0,10)+dlt,c(0,10)/dv_slope, col = 1, lty = 2)
lines(-c(0,10)-dlt,c(0,10)/dv_slope, col = 1, lty = 2)
Why does the t-test work for point hypothesis, $H_0 : \mu = 0$, but not for a composite hypothesis $H_0: \sigma \leq \mu \leq \sigma$?
In the image below we draw the situation like above, but now we change the standard deviation $\sigma$ of the population from which we draw the sample. Now the image contains two separate clouds. In the one case $\sigma = 1$ like before. In the other case $\sigma = 0.2$, and this creates the additional smaller little cloud of points.
The diagonal lines are the borders for some critical level of the likelihood ratio. The first case (upper image) is for a point null hypothesis $H_0 : \mu = 0$, the second case is for a composite hypothesis $H_0: \sigma \leq \mu \leq \sigma$ (where in this particular image $\sigma = 0.15$).
When we consider the probability of rejecting the null hypothesis if it is true (type I error), then this probability will depend on the parameters $\mu$ and $\sigma$ (which can differ within the null hypothesis).
Dependency on $\mu$: When $\mu$ is closer to either $\pm \delta$ instead of $0$ then it might be intuitive that the null hypothesis is more likely to be rejected, and that we can not make a test such that the the type 1 error is the same for whatever value of $\mu$ that corresponds to the null hypothesis.
Dependency on $\sigma$: The rejection probability will also depend on $\sigma$.
In the first case/image (point hypothesis), then independent of $\sigma$ the type I error will be constant. If we change the $\sigma$ then this relates to scaling the sample distribution (represented by the cloud of points in the image) in both vertical and horizontal directions and the diagonal boundary line will intersect the same proportion.
In the second case/image (composite hypothesis), then the the type I error will depend on $\sigma$. The boundary lines are shifted and do not pass through the center of the scaling transformation, so the scaling won't be an invariant transformation anymore with regards to the type I error.
While these borders relate to some critical likelihood ratio, this is based on the ratio for a specific case out of the composite hypotheses, and may not be optimal for other cases. (in the case of point hypotheses there are no 'other cases', or in the case of the "point hypothesis" $\mu_a - \mu_b = 0$, which is not really a point hypothesis because $\sigma$ is not specified in the hypothesis, it happens to work out because the likelihood ratio is independent of $\sigma$).