# R: t.test, am I doing this right?

I have these data:

 C <- c(6.9, 8.2, 9.4, 9.2, 7.3, 6, 8.6)
f <- c(5.4, 7.1, 5.6, 7.6)


To find out if C and f are similar or not, I do a t.test:

t.test(C, f, var.equal=TRUE, paired=FALSE)


This returns:

    Two Sample t-test

data:  C and f
t = 2.0115, df = 9, p-value = 0.07515
alternative hypothesis: true difference in means is not equal to 0
95 percent confidence interval:
-0.1891484  3.2248627
sample estimates:
mean of x mean of y
7.942857  6.425000


Am I correct in assuming that this means that I accept $H_0:$ no difference between C and f? - > I fail to reject H0

Upon doing a boxplot of the values, it is seen that the median seem very far apart. • Yes, you have conducted a t-test between C and F. I assume they are different samples? In terms of your conclusion, a non-significant t-test is not evidence for H0. You may want to check this out: stats.stackexchange.com/questions/85903/… – user183974 Aug 31 '18 at 22:21
• Welcome. Reasonable question. (+1) (a) You are using the software correctly for a two-sample, two-sided, pooled t test. It's use of the word 'accept' that is raising some objections. (b) In order to quote computer input/output in questions and answers, start each line with four blank spaces. I did this to edit your question. – BruceET Sep 1 '18 at 0:25
• You have to be careful using "Accept" to summarize test results. It can mean different things in various texts. Usually, in elem courses it is best to say 'fail to reject' so you don't appear to say you have 'proved' $H_0$ is true. Some authors, wishing to avoid double and triple negatives essentially define 'accept' to mean 'fail to reject'. // In advanced theoretical courses, one often speaks of the "Acceptance region" and "Rejection region" for a test statistic; then the verbs 'accept' and 'reject' seem to be freely used. // A test result is a statement about the data not about $H_0.$ – BruceET Sep 1 '18 at 0:30
• An ordinary hypothesis test does not test "similarity". Note that failure to reject doesn't mean there's no difference. – Glen_b Sep 1 '18 at 0:47
• Hi guys, thanks for your advice. I have updates the original post with a boxplot. Do you think the t.test fits the failure to reject H0? – AE35 Sep 1 '18 at 10:30

Comment: Response to question in comment about boxplots.

A major factor in not being able to reject is the very small sample sizes.

Perhaps the boxplots look impressively different, but boxplots give no visual information about sample size. I question whether the boxplot for f with only four observations even makes sense. How do you make an informative 'five number summary' with four observations?

Here is a 'stripchart' of the two samples (and my only excuse for Answer format instead of another Comment). In my view it is a better graphical description of your data, showing small sample sizes and individual observations with some overlap.

all = c(C, f);  gp = c(rep(1,7), 2,2,2,2)
stripchart(all ~ gp, ylim=c(.5,2.5), pch=19) Seeing this stripchart, I'm a bit surprised that you could reject at the 10% level.

Note: Here are boxplots with 'notches'. Notches in the sides of the boxes represent nonparametric confidence intervals for the medians, which are calibrated for comparing two boxplots (in the sense that overlapping notches indicate non-significance). Here the notched boxplots are quite ugly because the notches extend beyond the 'hinges' (quartiles). R gives a message suggesting not to use notches here. I would never recommend this graphic for a report, but it might be a way to illustrate that the boxplots are not impressively different. boxplot(C, f, notch=T, col="skyblue2")
Warning message:
In bxp(list(stats = c(6, 7.1, 8.2, 8.9, 9.4, 5.4, 5.5, 6.35, 7.35,  :
some notches went outside hinges ('box'): maybe set notch=FALSE


You would be incorrect in accepting H0 based on p>.05. You should use equivalence tests (TOST) for these types of conclusions (and I wouldn't use accept even if the TOST works) Here is a link to an R package that will do this for you http://daniellakens.blogspot.com/2016/12/tost-equivalence-testing-r-package.html

• equivalence tests do not determine "no difference". They look at whether two things are close enough to regard as equivalent in a particular sense (which you might regard as 'no practical difference' -- not at all the same thing as 'no difference') – Glen_b Sep 1 '18 at 0:48