Be sure to check the solutions to last week’s exercises.
You can still ask any questions about previous weeks’ materials if things aren’t clear!

LEARNING OBJECTIVES

  1. Understand the meaning of model coefficients in the case of a binary predictor.
  2. Be able to state the assumptions underlying a linear model.
  3. Understand how to assess if a fitted model satisfies the linear model assumptions.
  4. Understand how to use transformations when the model violates assumptions.

Research question

Do distracting colours influence game completion time?

A group of students wanted to answer the above research question. To do so, they designed a standard computerized game and a second version with distracting colours. Time to completion and type of game played were recorded for each study participant. See the data description below for more information.

Data: perfection.csv. Click the plus to expand →

Data exploration

Question 1

Read the Perfection game data into R and name the data frame perfection.

Check for the correct encoding of all variables — that is, categorical variables should be factors and numeric variables should be numeric.

Solution

Question 2

Identify the units, the population to which conclusions can be generalised to, the explanatory variable and the response variable. Also classify the variables according to their type.

Is this study an experiment or an observational study?

Solution

Question 3

Display and describe the marginal distribution of game type.

Solution

Question 4

Display and describe the marginal distribution of completion times.

Solution

Question 5

Display and describe the relationship between game type and completion times.

Does it look like the groups have equal mean or spread? Are there any extreme observations?

Solution

Model specification and fitting

Question 6

The researchers hope to determine if distracting colours could impact response times when playing a computerised version of the Perfection game.

Using a two-sided alternative, write out in words and in symbols appropriate null and alternative hypothesis for the research question of interest.

Solution

Question 7

Using the t.test() function, perform a statistical test against the null hypothesis specified above.

Solution

Question 8

Using the linear model function, lm(), fit the following linear model to the Perfection game data: \[ Time = \beta_0 + \beta_1 \ Type + \epsilon \]

Write down the equation of the fitted line.

Solution

Question 9

At the 5% significance level, are the regression coefficients significantly different from zero?

Does the model explain a significant fraction of the variability in completion times?

Solution

Question 10

Do you notice any similarities between the results of the two-sample t-test (performed via t.test()) and those of the linear model fitted via lm()?

Solution

Question 11

Interpret the intercept and slope of the fitted regression model.

Solution

Assumptions check

The test statistics reported in the model results are based on a series of assumptions. If these assumptions are not satisfied, the results will not hold.

You can remember the four assumptions by memorising the acronym LINE:

  • L - Linearity
  • I - Independence
  • N - Normality
  • E - Equal variance

If at least one of these assumptions does not hold, say N - Normality, you might be reporting a LIE.

Question 12

Check if the fitted model satisfies the linearity assumption.

Hint: An equivalent way to assess this is to check that the errors have a mean of zero. That is, there is no pattern left in the residuals as the systematic trend has entirely been captured by the linear model.

Solution

Question 13

Check if the fitted model satisfies the independent errors assumption.

Solution

Question 14

Check if the fitted model satisfies the normality of the errors assumption.

Solution

Question 15

Check if the fitted model satisfies the equal variance assumption.

Solution

References

Kuiper, Shonda, and Jeff Sklar. 2012. Practicing Statistics: Guided Investigations for the Second Course. Pearson Higher Ed.
Stroop, J Ridley. 1935. “Studies of Interference in Serial Verbal Reactions.” Journal of Experimental Psychology 18 (6): 643–62.

  1. Perfection is a popular game in which a person is expected to place an assortment of shaped pegs into the matching spaces.↩︎