empirical-methods

Homepage for 17-803 "Empirical Methods" at Carnegie Mellon University


Project maintained by bvasiles Hosted on GitHub Pages — Theme by mattgraham

In-Class Activity: Typing Speed Regression (lecture page, slides)

Lecture18-Simpson

Load the typing speed data: typingSpeed.csv

Part 1: Pooled Regression

Visualize the relationship between number of typos and typing speed. Run a regression analysis on the pooled data.

Interpret the analysis results.

Part 2: Individual Patterns

The data is from 50 participants at 50 measurement occasions each.

Pick 5 random participants and plot their 50 measurement occasions in a joint plot using different colors or symbols. Interpret the data.

Part 3: Two Sources of Variation

As we can see, we have two sources of variation that can be used to explain or predict the rate of errors:

  1. Overall, faster typists make less mistakes (group-level pattern).
  2. When typing faster, typists make more mistakes (individual-level pattern).

Model the typist as a fixed effect. Interpret the regression results.

Part 4: Mixed Effects Model

Now fit a linear mixed model and see how we can detect both the within- and between-group patterns.

library(lme4)
library(lmerTest)
lmer(typos ~ speed + (1 | participant))

Part 5: Within- and Between-Group Effects

What if we want to capture both the within- and between-group patterns in a simple regression?

We can split our predictor (speed) into two variables, each representing a different source of variance:

Fit a simple linear model.

What happens if you fit a linear mixed model with a random intercept for participant?


Solutions