What would an appropriate test be for testing whether group 3 has a larger vital capacity than group 1 from the vitcap dataset in the ISwR package. This is what I was thinking so far, but I'm really not sure if this is the right test to use. Surely this is just showing whether the difference in means = 0 or not?

c = vitcap # Load the vitcap data
c # Displays the data
group1 = subset(c, c[,1]==1) # Creates a subset of group 1
group1 # Displays the subset
group3 = subset(c, c[,1]==3) # Creates a subset of group 3
group3 # Displays the subset
qqplot(group1[,2], group1[,3]) # Checking if the data is normally distributed
qqplot(group3[,2], group3[,3]) # Checking if the data is normally distributed

# The QQ Plots appear to show the data is normally distributed, thus we assume normality

t.test(group1[,3], group3[,3]) # 95% CI for the vital capacity of each group

Any help would be greatly appreciated.

  • 1
    $\begingroup$ I would strongly recommend that you avoid naming your objects after common functions, c in particular... $\endgroup$ – nrussell Apr 15 '15 at 15:47
  • $\begingroup$ If you need help choosing an appropriate statistical test, you should consult a statistician, not a programmer. Such discussions are better for Cross Validated rather than Stack Overflow. $\endgroup$ – MrFlick Apr 15 '15 at 15:53

As long as T-test suits for you, you can add a parameter to it to make a test one-sided:

t.test(rnorm(100, mean = 2, sd = 1), rnorm(100, mean = 0, sd = 1), alternative='greater')

Just change rnorms to group1[,3] and group3[,3] accordingly


In case you want a non-parametric approach, Wilcoxon Rank Sum can be used:

wilcox.test(group1[,3], group3[,3], alternative="greater")
  • $\begingroup$ This is not of itself a test of means (which the title asks for), but tests equality of distribution against a fairly general alternative. With additional assumptions, it makes a perfectly fine test for say a shift in mean, but there are other nonparametric tests which are directly tests for a mean shift. $\endgroup$ – Glen_b -Reinstate Monica Apr 8 '16 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy