0

I try to conduct a t.test and compare against a reference group (d). My data look like:

Letter  method  Wiederfindung.ng
a   Quantus           4
a   Quantus           4
a   Quantus           4
b   Quantus           6
b   Quantus           5
b   Quantus           5
c   Quantus           18
c   Quantus           39
c   Quantus           12
d   theoretical       28,12

compare_means(Wiederfindung.ng ~ Letter,  data = Sa_Quantus_low, ref.group = "d", method = "t.test")

I receive on the consonle:

Error in t.test.default(xi, xj, paired = paired, alternative = alternative, : not enough 'y' observations

When I change the method from t.test to wilcox.test I get no error message.

compare_means(Wiederfindung.ng ~ Letter,  data = Sa_Quantus_low, ref.group = "d", method = "wilcox.test")

I want to know if there is any difference between the letters a,b,c to d.

Amira Bedhiafi
  • 8,088
  • 6
  • 24
  • 60
Anne
  • 1
  • Have you seen this - [Error using t.test() in R - not enough 'y' observations](https://stackoverflow.com/questions/15656614/error-using-t-test-in-r-not-enough-y-observations)? – pogibas Jul 17 '19 at 08:55
  • I find it weird that the test does not complain about the fact that the Wiederfindung.ng column is a character vector which does not contain a number in the last row. – January Jul 17 '19 at 09:25

1 Answers1

0

compare_means from ggpubr is a function that should probably never be used, at least not with a t-test, because it makes multiple comparisons between groups while not doing a proper ANOVA with a proper post-hoc test. And your data does not even look like suitable for a parametric method anyway (are these counts?).

In any case, compare_means calls t.test for the individual comparisons. This fails when the group has a single observation, like in the last row of your data. Also, even if you removed the group d and specified another reference group, it would still fail, because your data is not numeric. However, because t.test is what it is, the error message will not be helpful: it will not tell you that you have given it a character vector to work with, but instead it will say

Error in if (stderr < 10 * .Machine$double.eps * max(abs(mx), abs(my))) stop("data are essentially constant") : missing value where TRUE/FALSE needed

January
  • 16,320
  • 6
  • 52
  • 74
  • Thanks for your hint with compare_means from ggpubr. After looking at histogramm and q-q-plot as well as comparison between mean and media I thought to use a non-parametric test. But p-value from shapiro-wilk was about 0.06. I decided to test parametric and non-parametric and compare the results, if they show same signficances. – Anne Jul 18 '19 at 09:13
  • Please beware of normality tests. [Here](https://stats.stackexchange.com/questions/2492/is-normality-testing-essentially-useless) is a good discussion. The problem is that without enough samples, you will never reject the normality hypothesis, and with enough samples, you will always reject it. Then again, t.test is quite robust even in non-normal data. And if you decide to run alternative tests, have you given a thought about what you will do if the results are different? (they usually are in some of the cases). – January Jul 18 '19 at 09:29