# t.test returns an error "data are essentially constant"

R version 3.1.1 (2014-07-10) -- "Sock it to Me"
> bl <- c(140, 138, 150, 148, 135)
> fu <- c(138, 136, 148, 146, 133)
> t.test(fu, bl, alternative = "two.sided", paired = TRUE)
Error in t.test.default(fu, bl, alternative = "two.sided", paired = TRUE) :
data are essentially constant


Then I change just a single character in my fu dataset:

> fu <- c(138, 136, 148, 146, 132)


and it runs...

> t.test(fu, bl, alternative = "two.sided", paired = TRUE)

Paired t-test


What am I missing here?

• Type bl-fu. Now sd(bl-fu). If it's not obvious, yet, do these: dif=bl-fu then n=length(dif) then mean(dif)/(sd(dif)/sqrt(n))... do you see now? Commented Aug 23, 2014 at 5:35
• whoops, thanks :) agree with me that the error message could have been more newbie-friendly. So this means that as far as statistics go, there's no need for fancy t.test and its a certainty that for each subject there would be a -2 reduction in the fu compared to the bl? Commented Aug 23, 2014 at 5:46

As covered in comments, the issue was that the differences were all 2 (or -2, depending on which way around you write the pairs).

Responding to the question in comments:

So this means that as far as statistics go, there's no need for fancy t.test and its a certainty that for each subject there would be a -2 reduction in the fu compared to the bl?

Well, that depends.

If the distribution of differences really was normal, that would be the conclusion, but it might be that the normality assumption is wrong and the distribution of differences in measurements is actually discrete (maybe in the population you wish to make inference about it's usually -2 but occasionally different from -2).

In fact, seeing that all the numbers are integers, it seems like discreteness is probably the case.

... in which case there's no such certainty that all differences will be -2 in the population -- it's more that there's a lack of evidence in the sample of a difference in the population means any different from -2.

(For example, if 87% of the population differences were -2, there's only a 50-50 chance that any of the 5 sample differences would be anything other than -2. So the sample is quite consistent with there being variation from -2 in the population)

But you would also be led to question the suitability of the assumptions for the t-test -- especially in such a small sample.

• they are blood pressures in mmHg in a baseline and followup checks, so I'm pretty relaxed about assuming normality and of course non-discreteness. It was just an exercise that showed me how much more powerful is paired-t-test (when available) over non-paired. Commented Aug 23, 2014 at 6:29