Skip to content

Instantly share code, notes, and snippets.

@smithdanielle
Created November 4, 2015 15:15
Show Gist options
  • Save smithdanielle/293d78f64739dff6557e to your computer and use it in GitHub Desktop.
Save smithdanielle/293d78f64739dff6557e to your computer and use it in GitHub Desktop.
Variations on typical lme4 models for the ssw2014 experiment; includes residual TNO scores and PCA
ssw2014.data$behavioural$resid.log.crossedTNO<-residuals(lm(log.crossedTNO~log.uncrossedTNO, data = ssw2014.data$behavioural))
ssw2014.data$behavioural$resid.log.uncrossedTNO<-residuals(lm(log.uncrossedTNO~log.crossedTNO, data = ssw2014.data$behavioural))
ssw2014.data$behavioural$c.resid.log.crossedTNO<-scale(ssw2014.data$behavioural$resid.log.crossedTNO, center = T, scale = F)
ssw2014.data$behavioural$c.resid.log.uncrossedTNO<-scale(ssw2014.data$behavioural$resid.log.uncrossedTNO, center = T, scale = F)
ssw2014.data$behavioural$principal.component.TNO<-prcomp(ssw2014.data$behavioural[,c("log.crossedTNO", "log.uncrossedTNO")], center = T, scale. = T)$x[,"PC1"]
ssw2014.data$behavioural$c.principal.component.TNO<-scale(ssw2014.data$behavioural$principal.component.TNO, center = T, scale = F)
ssw2014.mixed.all.residUncrossed<-mixed(formula = z.score ~ view*activity*c.log.crossedTNO*c.age + view*activity*c.resid.log.uncrossedTNO*c.age + (1+activity+view|ID), data = ssw2014.data$behavioural)
ssw2014.mixed.all.residCrossed<-mixed(formula = z.score ~ view*activity*c.resid.log.crossedTNO*c.age + view*activity*c.log.uncrossedTNO*c.age + (1+activity+view|ID), data = ssw2014.data$behavioural)
# ssw2014.mixed.all.resid.vif<-vif.mer(ssw2014.mixed.all.resid$full.model)
# ssw2014.mixed.all.resid.kappa<-kappa.mer(ssw2014.mixed.all.resid$full.model)
ssw2014.mixed.crossed.resid<-mixed(formula = z.score ~ view*activity*c.resid.log.crossedTNO*c.age + (1+activity+view|ID), data = ssw2014.data$behavioural)
ssw2014.mixed.uncrossed.resid<-mixed(formula = z.score ~ view*activity*c.resid.log.uncrossedTNO*c.age + (1+activity+view|ID), data = ssw2014.data$behavioural)
ssw2014.mixed.pca<-mixed(formula = z.score ~ view*activity*c.principal.component.TNO*c.age + (1+activity+view|ID), data = ssw2014.data$behavioural)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment