Skip to content

Instantly share code, notes, and snippets.

@njudd
Last active July 8, 2025 14:58
Show Gist options
  • Select an option

  • Save njudd/4a2c53490eb4353cda29426e431be6ad to your computer and use it in GitHub Desktop.

Select an option

Save njudd/4a2c53490eb4353cda29426e431be6ad to your computer and use it in GitHub Desktop.
Two Timepoint Reschange
if (!require(pacman)) {install.packages("pacman")}
pacman::p_load(data.table, psych)
load(url("http://alecri.github.io/downloads/data/dental.RData")) # snagging random long data
setDT(dental)
dental
dental$delta <- dental$y14 - dental$y8
describe(dental$delta)
dental$res <- as.numeric(lm(y14 ~ y8, data = dental)$residuals)
dental$deltaRES <- as.numeric(lm(delta ~ y8, data = dental)$residuals)
cor(dental$res, dental$deltaRES) # R = 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment