Confused about simple hypothesis testing question I am using R to do some hypothesis testing on a large sample (n=311) and I am getting confused with the results. R returns very different results than I am getting by hand, using the formulas in my textbook.
My data is the difference between (what I think) are two paired sets of observations and is summarized as follows: $$ \bar y_d = 0.0006, s_d=0.02, n_d=311 $$
My hypotheses are: $$H_o:\mu_d = 0\\H_a: \mu_d < 0$$
Which, according to my textbook, gives me this formula for my test statistic: $$t= {{\bar y_d - D_0}\over {s_d/\sqrt {n_d}}} = {{0.0006 - 0}\over{0.02/\sqrt{311}}} = 0.591$$
And this is the start of where I am confused. R gives me the following printout when I run a t.test on it:
data:  dVals 
t = 0.6452, df = 310, p-value = 0.7404
alternative hypothesis: true mean is less than 0 
95 percent confidence interval:
        -Inf 0.002134155 
sample estimates:
mean of x 
    6e-04 

How is R getting this t-stat? Am I computing t using the wrong formula? Also, I can't seem to get the correct p-value no matter what formula/table I try to look in...
And as a last bit, I'm not understanding how a value of t=0.6452 leads to a true Ha since to accept Ha:
$$
t < -t_\alpha \\ 0.6452 < -1.645,\space where\space\alpha=0.05
$$
Which is clearly not true... So shouldn't that mean the null hypothesis is not rejected?
 A: The formula that you used to calculate your test statistic is correct. The next step is to consider a suitable distribution for your test statistic, I guess it should be student t distribution in this case. After that according to your $\alpha$ you need to determine the thereshold from this distribution. What you do is to integrate from minus infinity to to $t_\alpha$ which will give you $95\%$. Then you will simply compare your thereshold $t$ with $t_\alpha$ to decide for the correct hypothesis. I think you problem is with $t_\alpha$ where you got a negative value. I think it should be positive as student t distribution is symmetric around $0$ and when you integrate it from $-\infty$ to $0$ you get $0.5$. As you are after a value that is $95\%$ then you need to have $t_\alpha>0$
A: The formula is right. Your computed test statistic is close to the one in R.  Yours is 0.59 while theirs is 0.65.  You didn't say how you computed $s_d$.  Maybe you calculated it wrong.
It should be $S_d^2=\sum (y_i-\bar{y}_d)^2/(d-1)$. The sum runs from 1 to $d$ where $d=311$ and $y_i$ is the $i$th paired difference and
$\bar y_d = \sum_{i=1}^d y_i/d$
Check to see that you computed them correctly.
If R did all the calculations independently then you can trust their numbers.
The t statistic is not large and the conclusion is that you can't reject the null hypothesis.
