Reading t.test output
◈ 7 cardsR’s t.test prints t, df, the p-value, the alternative, a confidence interval and the sample mean; alternative = sets the tail, and the one-sided p is half the two-sided one.
The printout, line by line
The paper prints R output and asks you to read it. For Cedar & Stone's sixteen files (mean 53, sd 6.4, stored in a vector hrs), the one-sided test of L10.5 is one call — mu = sets and alternative = sets the tail:
> t.test(hrs, mu = 50, alternative = "greater")
One Sample t-test
data: hrs
t = 1.875, df = 15, p-value = 0.0402
alternative hypothesis: true mean is greater than 50
95 percent confidence interval:
50.19512 Inf
sample estimates:
mean of x
53
Map each line to the hand computation:
t = 1.875, df = 15— step 2, exactly: on df.p-value = 0.0402— step 3, the exact upper-tail area beyond 1.875 that the table could only bracket as . It sits inside the bracket, as it must.alternative hypothesis: true mean is greater than 50— R restating ; check it against your step 1.95 percent confidence interval: 50.19512 Inf— a one-sided interval, a lower bound only, matching the one-sided test: every below 50.20 is rejected at 5 %. Not the two-sided interval of Module 9.mean of x 53— .
The decision is yours to write; R never says reject. : reject at 5 %, with the same sentence as L10.5.
The default call is two-sided
Drop alternative = and R tests :
> t.test(hrs, mu = 50)
t = 1.875, df = 15, p-value = 0.0804
alternative hypothesis: true mean is not equal to 50
95 percent confidence interval:
49.58968 56.41032
Same , same df; the p-value has doubled to 0.0804, and the interval is now the ordinary two-sided one — , built with . This is the one to compare with the hand bracket: doubling at both ends gives , and 0.0804 is inside. At 5 % two-sided, do not reject — 50 lies inside , L10.7's duality once more.
If a question is one-sided and the paper prints the default output, halve the printed p (the estimate 53 lies in the predicted direction): .
The quantiles behind the table
> qt(0.95, 15); qt(0.975, 15)
[1] 1.75305
[1] 2.13145
qt(0.95, 15) is the table's (5 % above); qt(0.975, 15) is . R indexes by the cumulative probability, the table by the upper tail — the translation is , as in L9.5. pt(1.875, 15, lower.tail = FALSE) returns the 0.0402 on the printout.
Reading checklist
Given any t.test printout: find in mu =; find the tail in the alternative hypothesis line; read and df; compare p with — halving first if the call was two-sided and the question is not; write the decision and the sentence yourself; and know which interval the call produced.