Contrasts

Learning Objectives

At the end of this lab, you will:

  1. Understand how to specify contracts to test specific effects.
  2. Understand different types of study design.

What You Need

  1. Be up to date with lectures
  2. Have completed previous lab exercises from Week 1 and Week 2

Required R Packages

Remember to load all packages within a code chunk at the start of your RMarkdown file using library(). If you do not have a package and need to install, do so within the console using install.packages(" "). For further guidance on installing/updating packages, see Section C here.

For this lab, you will need to load the following package(s):

  • tidyverse
  • psych
  • kableExtra
  • emmeans

Lab Data

You can download the data required for this lab here or read it in via this link https://uoepsy.github.io/data/caffeinedrink.csv

Study Overview

Research Question

Does WPM differ by caffeine treatment condition?

To investigate if the number of words typed per minute (WPM) differs among caffeine treatment conditions, the researchers conducted an experiment where participants were randomly allocated to one of four treatment conditions. Two of these conditions included non-caffeinated drinks - control (water) and mint tea, and the other two caffeinated drinks - coffee and red bull.

Drink Caffeine Temp
Control (Water) No Cold
Red Bull Yes Cold
Coffee Yes Hot
Mint Tea No Hot

In addition to the above research question, the researchers were also specifically interested in the following comparisons:

  • Whether having some kind of caffeine (i.e., red bull or coffee), rather than no caffeine (i.e., control - water or mint tea), resulted in a difference in average WPM
  • Whether there was a difference in average WPM between those with hot drinks (i.e., mint tea / coffee) in comparison to those with cold drinks (control - water / red bull)
Caffeine data codebook

Setup

Setup
  1. Create a new RMarkdown file
  2. Load the required package(s)
  3. Read the caffeinedrink dataset into R, assigning it to an object named caffeine

Solution


Question 1

Firstly, examine the dataset, and perform any necessary and appropriate data management steps.

Secondly, set an appropriate reference group based on the research question.

Solution


Question 2

Formally state:

  • a linear model to investigate whether there are differences in WPM based on caffeine treatment conditions
  • your chosen significance level
  • the null and alternative hypotheses

Solution


Question 3

Provide a table of descriptive statistics and visualise your data.

Remember to interpret your plot in the context of the study (i.e., comment on any observed differences among treatment groups).

  1. For your table of descriptive statistics, both the group_by() and summarise() functions will come in handy here.
  2. Recall that when visualising categorical variables, geom_boxplot() may be most appropriate to use.
  3. Make sure to comment on any observed differences among the sample means of the four treatment conditions.

Solution


Question 4

Fit the specified model, and assign it the name “caf_mdl1”.

Examine and describe the coefficients in the output of summary() before interpreting the \(F\)-test results from anova() in the context of the ANOVA null hypothesis.

Solution


Question 5

Formally state the two planned comparisons that the researchers were interested in as testable hypotheses.

Solution


Question 6

After checking the levels of the factor treatment, use emmeans() to obtain the estimated treatment means and uncertainties for your factor.

Use plot() to visualise this.

Solution


Question 7

Specify the coefficients of the comparisons and run the contrast analysis. Obtain 95% confidence intervals, and then interpret your results in relation to the researchers hypotheses.

Ordering matters here - look again at the output of levels(caffeine$treatment) as this will help you when assigning your weights.

Solution

Study Design

For each of the below experiment descriptions, note (1) the design, (2) number of variables of interest, (3) levels of categorical variables, (4) what you think the reference group should be and why.

Question 8

A group of researchers were interested in whether sleep deprivation influenced reaction time. They hypothesised that sleep deprived individuals would have slower reaction times than non-sleep deprived individuals.

To test this, they recruited 60 participants who were matched on a number of demographic variables including age and sex. One member of each pair (e.g., female aged 18) was placed into a different sleep condition - ‘Sleep Deprived’ (4 hours per night) or ‘Non-Sleep Deprived’ (8 hours per night).

Solution


Question 9

A group of researchers were interested in replicating an experiment testing the Stroop Effect.

They recruited 50 participants who took part in Task A (word colour and meaning are congruent) and Task B (word colour and meaning are incongruent) where they were asked to name the color of the ink instead of reading the word. The order of presentation was counterbalanced across participants. The researchers hypothesised that participants would take significantly more time (‘response time’ measured in seconds) to complete Task B than Task A.

You can test yourself here for fun: Stroop Task

Solution


Question 10

A group of researchers wanted to test a hypothesised theory according to which patients with amnesia will have a deficit in explicit memory but not implicit memory. Huntingtons patients, on the other hand, will display the opposite: they will have no deficit in explicit memory, but will have a deficit in implicit memory.

To test this, researchers designed a study that included two variables: ‘Diagnosis’ (Amnesic, Huntingtons, Control) and ‘Task’ (Grammar, Classification, Recognition) where participants were randomly assigned to a Task condition. The first two tasks (Grammar and Classification) are known to reflect implicit memory processes, whereas the Recognition task is known to reflect explicit memory processes.

Solution