I am given two sets of data: price0 and price1, both normally distributed. We denote the means of both sets $\mu_0$ and $\mu_1$ respectively. The question asked is:
"For which values of $a$ can we reject $H_0$ for the following hypothesis test:
$H_0 : \mu_0 \geq \mu_1 - a$
$H_1 : \mu_0 < \mu_1 -a$
on a significance level of $\alpha = 0.05$?
I did this analyticly first and found:
$t = \dfrac{\mu_0-(\mu_1-a)}{\frac{s_0}{\sqrt{n}}} \leq t_{n-1,1-\alpha}$, for $t \in (-\inf, -t_{n-1,1-\alpha}] $, the rejection interval.
Note that in the equation above, $s_0$ is sample standard deviation of price0, $n$ is the total number of elements in price0 and $t_{n-1,1-\alpha}$ is the t-distribution with $n-1$ degrees of freedom and $1-\alpha$ is the percentile. Hence,
$a \leq - \frac{s_0}{\sqrt{n}}\cdot t_{n-1,1-\alpha} - \mu_0 + \mu_1$.
Untill now all is well (for me at least). But when I use t.test() in R ('a' in the code below is the numeric value found by the above inequality):
t.test(price0, mu = mean(price1) - a, alternative = 'g', conf.level = 0.95)
The output with all the numeric values is:
One Sample t-test
data: prijs0
t = -4.6165, df = 22, p-value = 0.9999
alternative hypothesis: true mean is greater than 1074.273
95 percent confidence interval:
886.2384 Inf
sample estimates:
mean of x
937.2174
I am also confused by the output:
alternative hypothesis: true mean is greater than 1074.273
Since I would think my nullhypothesis is: "true mean is greater than 1074.273" (because 1074.273 = mean(price0) - a).
Anyway my t-value is such that it would be an element of the rejection interval, which would mean we would discard $H_0$. But meanwhile my p-value is nearly 1, which means we cannot discard $H_0$, nor can we say anything about whether $H_0$ is true or not.
My question now is, am I doing anything wrong in my code or is it my way of thinking about these types of hypothesis tests?