1. Learn
  2. /
  3. Courses
  4. /
  5. Intro to Statistics with R: Student's T-test

Exercise

Let R do the dirty work

Thanks to the handy t.test() function in R, it's not necessary to manually compute the t-statistic every time you want to do a t-test. Similarly, the cohensD() function from the lsr package automates the process of computing Cohen's d. We'll continue with the working memory example to illustrate.

In the case of our dependent t-test, we need to specify these arguments to t.test():

  • x: Column of wm_t containing post-training intelligence scores
  • y: Column of wm_t containing pre-training intelligence scores
  • paired: Whether we're doing a dependent (i.e. paired) t-test or independent t-test. In this example, it's TRUE

Note that t.test() carries out a two-sided t-test by default, which is exactly what we want here, but this behavior can be altered with the alternative argument. See ?t.test for more info.

For cohensD(), we'll need to specify three arguments:

  • x: Column of wm_t containing post-training intelligence scores
  • y: Column of wm_t containing pre-training intelligence scores
  • method: Version of Cohen's d to compute, which should be "paired" in this case

If you're successful, you'll get the same values you got when you did everything "by hand" in the previous exercises.

Instructions

100 XP

The wm_t dataset has been loaded into your workspace.

  • Apply t.test() to wm_t to test whether there's a significant difference between pre- and post-training intelligence scores. Post-training scores are contained in wm_t$post and pre-training scores in wm_t$pre. Don't save the result.
  • Apply cohensD() to wm_t to compute Cohen's d. Use the same columns as inputs for x and y. Don't save the result.