# Formula confidence interval for difference in means - one sample t-test

I am looking for the formula of the confidence interval for the difference between means in a one sample t-test. I have only been able to locate the formula for a two sample t-test.

Let me give an example: I have the following ten scores

10,12,13,11.5,9,11,11.1,11.9,12.1,9.3


I want to know if the mean of these scores is significantly different from my population mean of 11.5. When I conduct a one sample t-test in SPSS I get the following results:

t obtained = -10.776
SIG (i.e., P) = 0.000
95% CI of the difference = -5.3363 to -3.4837.


I know how SPSS calculated t and P but not how it calculated the 95% CI of the difference. This 95% CI of the difference is not the same as the CI for the mean. The CI for the mean I can obtain by

$$CI =\bar{x} \pm t S/\sqrt{N}.$$

The confidence interval in this case is: 10.16,12.01. I get the same result if I calculate this in SPSS.

So my question is: what is the formula for the CI of the difference which SPSS produces? How do I get that range? I do not want the CI for the mean. Thanks.

• When you have only one sample, how do you obtain two means? Are you saying you have a paired sample (that is, a dataset of $(X,Y)$ values)?
– whuber
Commented Jun 17, 2011 at 18:59
• @Whuber. No I mean a one sample t-test (as outlined in Healey Statistics: A Tool for Social Research). A one sample t-test is where you are comparing a sample mean to a population mean.The example they give is that you have a mean grade for a university population (4), a sample mean for 115 engineering students and you want to use your sample mean to decide if the mean grade of engineering students is different from the university mean (4). So you only have one sample. What is the formula for the CI for sample means in this case (a one sample t-test)?
– Anne
Commented Jun 17, 2011 at 19:18
• @Anne This is the first example in every statistics textbook. See the Wikipedia article, for instance.
– whuber
Commented Jun 17, 2011 at 19:56
• @ Whuber. This shows how to calculate the CI for the mean not the difference in means. They aren't the same thing or at least SPSS doesn't think so.- confused.
– Anne
Commented Jun 17, 2011 at 20:06
• Since the population mean is known, so just subtract it from your data points, or from your one-sample CI. It is rare for the population mean to be known so the software probably won't do this. Commented Jun 17, 2011 at 20:21

The confidence interval provided by the OP (10.16, 12.01) is correct for the data provided. The SPSS output does not match this data, whether or not the population mean is subtracted. (t value incorrect, CI incorrect, p-value incorrect.) The output is either from a different example or there was some error in what data was passed to the function.

In R:

A = c(10, 12, 13, 11.5, 9, 11, 11.1, 11.9, 12.1, 9.3)

B = A - 11.5

t.test(A, mu=11.5)

### One Sample t-test
### data:  A
### t = -1.0013, df = 9, p-value = 0.3428
### alternative hypothesis: true mean is not equal to 11.5
### 95 percent confidence interval:
### 10.16374 12.01626
### sample estimates:
### mean of x
###     11.09

t.test(B, mu=0)

### One Sample t-test
### data:  B
### t = -1.0013, df = 9, p-value = 0.3428
### alternative hypothesis: true mean is not equal to 0
### 95 percent confidence interval:
### -1.3362575  0.5162575
### sample estimates:
### mean of x
###     -0.41


Since the population mean is known, so just subtract it from your data points, or from your one-sample CI. It is rare for the population mean to be known so the software probably won't do this.

• I've copied this comment by @Aaron as a community wiki answer because they are, more or less, an answer to this question. We have a dramatic gap between answers and questions. At least part of the problem is that some questions are answered in comments: if comments which answered the question were answers instead, we would have fewer unanswered questions.
– mkt
Commented Feb 9, 2019 at 22:47
• I've added a comment to the OP above. This might be a correct answer conceptually, but in the actual question, the SPSS output doesn't match the data provided, so this isn't an accurate answer to the question. Commented Feb 10, 2019 at 16:33