##Set working directory

setwd("C:/Users/Russell Chan/OneDrive - Universiteit Twente/2020_MSCA_IF/4_2021_Mod_7/Data Analysis/Scripts")

##Packages that are required for the analysis

library(readxl)
library(haven)
library(tidyverse)
library(lme4)
library(effects)
library(lattice)
library(car)
library(ggplot2)
library(knitr)
library(reshape2)
library(dplyr)
library(forcats)
library(DHARMa)
library(Hmisc)
library(phia)
library(lsmeans)
library(emmeans)
library(multcomp)
library(nlme)
library(gplots)
library(scales)
library(Rmisc)

##Import dataset from the directory

d.MSL <- read_excel("C:\\Users\\Russell Chan\\OneDrive - Universiteit Twente\\2020_MSCA_IF\\4_2021_Mod_7\\Data Analysis\\M7_Triallvl_2105231_Final.xlsx")

##Create factors for analysis

#Subject is a factor to account for intraclass variance in linear models
d.MSL$Subject <- factor(d.MSL$Subject)

#Block is our function of time
d.MSL$Block <- factor(d.MSL$Block)

#Accuracy is a factor to know if it determines RT
d.MSL$Trial.ACC.Num <- factor(d.MSL$Trial.ACC.Num)

###Building models

#First model: To simply understand if RT changes as a function of block (i.e. learning)
m.MSL.RT <- lmer(AvgTrial.RT ~ Block + (1|Subject), data = d.MSL)
Anova(m.MSL.RT)
summary(m.MSL.RT)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ Block + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 36672.8
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.058 -0.200 -0.043  0.086 43.416 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  23182   152.3   
##  Residual             255177   505.2   
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)   603.52      53.38  11.305
## Block2       -299.48      32.61  -9.184
## Block3       -348.79      32.61 -10.697
## Block4       -365.19      32.61 -11.200
## Block5       -373.81      32.61 -11.464
## 
## Correlation of Fixed Effects:
##        (Intr) Block2 Block3 Block4
## Block2 -0.305                     
## Block3 -0.305  0.500              
## Block4 -0.305  0.500  0.500       
## Block5 -0.305  0.500  0.500  0.500
#Plotting of quick interactions1
emmip(m.MSL.RT, ~Block)

#The results of the model reveal that indeed AvgTrial.RT (Which is the average of the 6 steps). As block progresses. RT is getting faster.

#Second model: To understand if Trial.RT is different between accurate and inaccurate trials. 
m.MSL.ACC <- lmer(AvgTrial.RT ~ Trial.ACC.Num + (1|Subject), data = d.MSL)
Anova(m.MSL.ACC)
summary(m.MSL.ACC)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ Trial.ACC.Num + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 36751.3
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.020 -0.210 -0.071  0.088 43.063 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  19361   139.1   
##  Residual             260713   510.6   
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##                Estimate Std. Error t value
## (Intercept)      541.05      48.96   11.05
## Trial.ACC.Num1  -289.87      25.30  -11.46
## 
## Correlation of Fixed Effects:
##             (Intr)
## Trl.ACC.Nm1 -0.383
#Plotting of quick interactions2
emmip(m.MSL.ACC, ~Trial.ACC.Num)

#The results of the model reveal that indeed AvgTrial.RT is different between accurate and inaccurate.

#Third model: To understand if Trial.RT as a function of accuracy and block (learning) is different and changing.
m.MSL.RTACC <- lmer(AvgTrial.RT ~ Block * Trial.ACC.Num + (1|Subject), data = d.MSL)
Anova(m.MSL.RTACC)
summary(m.MSL.RTACC)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ Block * Trial.ACC.Num + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 36546.2
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.234 -0.177 -0.030  0.092 43.706 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  20217   142.2   
##  Residual             247714   497.7   
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##                       Estimate Std. Error t value
## (Intercept)             775.85      55.09  14.084
## Block2                 -377.79      53.96  -7.001
## Block3                 -461.22      64.16  -7.189
## Block4                 -451.78      62.60  -7.217
## Block5                 -363.23      68.08  -5.335
## Trial.ACC.Num1         -358.10      46.32  -7.731
## Block2:Trial.ACC.Num1   228.03      68.78   3.315
## Block3:Trial.ACC.Num1   285.67      76.49   3.735
## Block4:Trial.ACC.Num1   253.64      75.21   3.373
## Block5:Trial.ACC.Num1   144.47      79.91   1.808
## 
## Correlation of Fixed Effects:
##             (Intr) Block2 Block3 Block4 Block5 T.ACC. B2:T.A B3:T.A B4:T.A
## Block2      -0.330                                                        
## Block3      -0.276  0.310                                                 
## Block4      -0.289  0.306  0.265                                          
## Block5      -0.270  0.270  0.228  0.237                                   
## Trl.ACC.Nm1 -0.405  0.387  0.322  0.343  0.328                            
## B2:T.ACC.N1  0.261 -0.788 -0.248 -0.244 -0.214 -0.645                     
## B3:T.ACC.N1  0.235 -0.262 -0.841 -0.225 -0.194 -0.580  0.414              
## B4:T.ACC.N1  0.244 -0.254 -0.220 -0.835 -0.201 -0.603  0.412  0.376       
## B5:T.ACC.N1  0.235 -0.227 -0.191 -0.202 -0.857 -0.581  0.377  0.340  0.353
#Plotting of quick interactions3
emmip(m.MSL.RTACC, Block ~Trial.ACC.Num)

#The results of the model reveal that indeed AvgTrial.RT modulated by accuracy and that there is a significant interaction with blocks.  We will know the direction of the change only when we plot it later.

#Fourth model: To understand if CoM Velocity is changing as learning occurs.
m.MSL.COMVE <- lmer(COM.X.VE ~ Block + (1|Subject), data = d.MSL)
## boundary (singular) fit: see ?isSingular
Anova(m.MSL.COMVE)
summary(m.MSL.COMVE)
## Linear mixed model fit by REML ['lmerMod']
## Formula: COM.X.VE ~ Block + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: -8615
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6418 -0.6246  0.0012  0.6528  3.6028 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev. 
##  Subject  (Intercept) 7.660e-20 2.768e-10
##  Residual             1.584e-03 3.980e-02
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept) 0.010226   0.001817   5.629
## Block2      0.007319   0.002569   2.849
## Block3      0.012244   0.002569   4.766
## Block4      0.015556   0.002569   6.055
## Block5      0.024984   0.002569   9.725
## 
## Correlation of Fixed Effects:
##        (Intr) Block2 Block3 Block4
## Block2 -0.707                     
## Block3 -0.707  0.500              
## Block4 -0.707  0.500  0.500       
## Block5 -0.707  0.500  0.500  0.500
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see ?isSingular
#Plotting of quick interactions5
emmip(m.MSL.COMVE, ~Block)

#4.5 model: To understand if CoM Velocity is changing with Accuracy.
m.MSL.COMVE.ACC <- lmer(COM.X.VE ~ Trial.ACC.Num + (1|Subject), data = d.MSL)
Anova(m.MSL.COMVE.ACC)
summary(m.MSL.COMVE.ACC)
## Linear mixed model fit by REML ['lmerMod']
## Formula: COM.X.VE ~ Trial.ACC.Num + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: -8554.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5342 -0.6688 -0.0168  0.6439  3.7863 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Subject  (Intercept) 1.953e-06 0.001398
##  Residual             1.642e-03 0.040521
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##                Estimate Std. Error t value
## (Intercept)    0.017308   0.001702  10.168
## Trial.ACC.Num1 0.006658   0.001915   3.476
## 
## Correlation of Fixed Effects:
##             (Intr)
## Trl.ACC.Nm1 -0.835
#Plotting of quick interactions Model 4.5
emmip(m.MSL.COMVE.ACC, ~Trial.ACC.Num)

#The results support that COM.X Velocity is indeed changing with accuracy. Accurate trials are slower than inaccurate trials. Perhaps some impulsitivity there.

#Fifth model: To understand The interaction if RT predicts CoM.X Velocity changes is changing as learning occurs.
m.MSL.COMVE.RT.Inter <- lmer(AvgTrial.RT ~ Block * COM.X.VE + (1|Subject), data = d.MSL)
Anova(m.MSL.COMVE.RT.Inter)
summary(m.MSL.COMVE.RT.Inter)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ Block * COM.X.VE + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 36598.1
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.091 -0.196 -0.044  0.087 43.370 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  23163   152.2   
##  Residual             255555   505.5   
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##                 Estimate Std. Error t value
## (Intercept)       613.24      54.06  11.343
## Block2           -311.03      35.75  -8.701
## Block3           -359.14      35.90 -10.003
## Block4           -370.00      36.11 -10.246
## Block5           -386.23      38.32 -10.079
## COM.X.VE         -950.89     842.36  -1.129
## Block2:COM.X.VE  1055.01    1077.21   0.979
## Block3:COM.X.VE   979.09    1003.26   0.976
## Block4:COM.X.VE   760.37     978.81   0.777
## Block5:COM.X.VE  1027.41     987.30   1.041
## 
## Correlation of Fixed Effects:
##             (Intr) Block2 Block3 Block4 Block5 COM.X. B2:COM B3:COM B4:COM
## Block2      -0.314                                                        
## Block3      -0.312  0.473                                                 
## Block4      -0.311  0.470  0.467                                          
## Block5      -0.293  0.443  0.441  0.439                                   
## COM.X.VE    -0.159  0.241  0.240  0.239  0.224                            
## B2:COM.X.VE  0.125 -0.394 -0.188 -0.186 -0.175 -0.782                     
## B3:COM.X.VE  0.134 -0.203 -0.387 -0.200 -0.188 -0.839  0.657              
## B4:COM.X.VE  0.137 -0.207 -0.206 -0.386 -0.194 -0.861  0.673  0.722       
## B5:COM.X.VE  0.136 -0.205 -0.204 -0.204 -0.439 -0.853  0.667  0.716  0.734
#Plotting of quick interactions5
emmip(m.MSL.COMVE.RT.Inter, Block~COM.X.VE)
## Suggestion: Add 'at = list(COM.X.VE = ...)' to call to see > 1 value per group.
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#Not significant result.  Significance only between block and RT but not the interactions of the velocity and Trial RT within the blocks.

#Sixth model: To understand The interaction if RT predicts CoM.X Velocity changes that is modulated by blocks (learning).
m.MSL.COMVE.RT <- lmer(AvgTrial.RT ~ COM.X.VE + (1|Subject), data = d.MSL)
Anova(m.MSL.COMVE.RT)
summary(m.MSL.COMVE.RT)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ COM.X.VE + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 36867.7
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -0.677 -0.240 -0.105  0.080 42.395 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  23182   152.3   
##  Residual             274085   523.5   
## Number of obs: 2400, groups:  Subject, 10
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)   341.21      49.67   6.870
## COM.X.VE     -681.11     263.51  -2.585
## 
## Correlation of Fixed Effects:
##          (Intr)
## COM.X.VE -0.118
#Plotting of quick interactions6
emmip(m.MSL.COMVE.RT, ~COM.X.VE)
## Suggestion: Add 'at = list(COM.X.VE = ...)' to call to see > 1 value per group.
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

#When block is removed however, there is a relationship with RT and COM.  Scatter plot here will show the linear relationship.

###Effects and plots of the models

#We now we need prepare the data to plot the effects and not the raw numbers.  Because after statistical testing the numbers are changed and the raw values are not representative of the models after factors were specified.

#Effects Model 1
ae.m.MSL.RT <- allEffects(m.MSL.RT)
ae.m.df.RT <- as.data.frame(ae.m.MSL.RT[[1]])

#The plot of RT~Block
RT <- ggplot(ae.m.df.RT, aes(x=Block, y=fit)) +
  geom_errorbar(aes(ymin=lower, ymax=upper), width=.1) +
  geom_line() +
  geom_point() +
  ylab("RT (ms)") +
  xlab("Block") +
  ggtitle("RT~Block") +
  theme_classic()

print(RT)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

##Block determines RT.  Difference is predicated on the difference in the 1st block.  

#Effects Model 2
ae.m.MSL.ACC <- allEffects(m.MSL.ACC)
ae.m.df.ACC <- as.data.frame(ae.m.MSL.ACC[[1]])

#The plot of RT~ACC
ACC<-ggplot(ae.m.df.ACC, aes(x=Trial.ACC.Num,y=fit))+
  geom_errorbar(aes(ymin=lower, ymax=upper), width=.1) +
  geom_point() +
  geom_line()+
  ylab("RT (ms)")+
  xlab("ACC")+
  ggtitle("RT~ACC")+
  theme_classic()

print(ACC)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

##Clear difference between accurate and inaccurate.  Accurate significantly faster.

#Effects Model 3
ae.m.MSL.RTACC <- allEffects(m.MSL.RTACC)
ae.m.df.RTACC <- as.data.frame(ae.m.MSL.RTACC[[1]])

#The plot of RT~Block*ACC
RTACC<-ggplot(ae.m.df.RTACC, aes(x=Block,y=fit, group=Trial.ACC.Num))+
  geom_ribbon(aes(ymin=lower, ymax=upper, fill=Trial.ACC.Num), alpha=0.2) +
  geom_line(aes(size=1, color=Trial.ACC.Num)) +
  geom_point(aes(color=Trial.ACC.Num, shape=Trial.ACC.Num, size=2))+
  ylab("RT (ms)")+
  xlab("Block")+
  ggtitle("RT~ACC*Block")+
  theme_classic()
print(RTACC)

##Differences in accurate and inaccurate trials.  Again predicated on the 1st block.  In general, the RT is decreasing per block too, even for inaccurate trials.


#Effects Model 4
ae.m.MSL.COMVE <- allEffects(m.MSL.COMVE)
ae.m.df.COMVE <- as.data.frame(ae.m.MSL.COMVE[[1]])

#The plot of COMVelocity~Block
COMVE <- ggplot(ae.m.df.COMVE, aes(x=Block, y=fit)) +
  geom_errorbar(aes(ymin=lower, ymax=upper), width=.1) +
  geom_line() +
  geom_point() +
  ylab("COM Velocity (m)") +
  xlab("Block") +
  ggtitle("COM Velocity~Block") +
  theme_classic()

print(COMVE)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

##The COM is moving faster overtime.  There are differences in 1st vs 3rd, 1st vs 4th and 1st vs 5th (largest increase in velocity).

#Effects Model 4.5
ae.m.MSL.COMVE.ACC <- allEffects(m.MSL.COMVE.ACC)
ae.m.df.COMVE.ACC <- as.data.frame(ae.m.MSL.COMVE.ACC[[1]])

#The plot of RT~ACC
COMVE.ACC<-ggplot(ae.m.df.COMVE.ACC, aes(x=Trial.ACC.Num,y=fit))+
  geom_errorbar(aes(ymin=lower, ymax=upper), width=.1) +
  geom_point() +
  geom_line()+
  ylab("COM X Velocity(m/s)")+
  xlab("ACC")+
  ggtitle("COM X Velocity~ACC")+
  theme_classic()

print(COMVE.ACC)
## geom_path: Each group consists of only one observation. Do you need to adjust
## the group aesthetic?

##The COM is faster for inaccurate trials but more variable compared to accurate trials which are slower but less variable.  This suggests that there is a level of certainty with the motion in accurate trials since they don't fluctuate as much.

#Effects Model 5
ae.m.COMVE.RT.Inter <- allEffects(m.MSL.COMVE.RT.Inter)
ae.m.df.COMVE.RT.Inter <- as.data.frame(ae.m.COMVE.RT.Inter[[1]])

#The plot of RT ~ Block * COM.X.VE
RTCOMVE.inter<-ggplot(ae.m.df.COMVE.RT.Inter, aes(x=COM.X.VE,y=fit, color=Block))+
  geom_ribbon(aes(ymin=lower, ymax=upper, fill=Block), alpha=0.2) +
  geom_line() +
  geom_point()+
  ylab("RT (ms)")+
  xlab("COM Velocity (m/s)")+
  ggtitle("RT~Block*COMVE")+
  theme_classic() +
  facet_wrap(~Block)

print(RTCOMVE.inter)

##Fast and slow COM have the same reaction times by block 3 to 5.  So COM when understood from a block perspective has no differences.  Even in the 1st block.

#Effects Model 6 - So now we remove the issue of block and just check how Trial RT predicts COM Velocity
ae.m.COMVE.RT <- allEffects(m.MSL.COMVE.RT)
ae.m.df.COMVE.RT <- as.data.frame(ae.m.COMVE.RT[[1]])

#The plot of RT ~ COMVelocity
RTCOMVE <- ggplot(ae.m.df.COMVE.RT, aes(x=COM.X.VE, y=fit)) +
  geom_errorbar(aes(ymin=lower, ymax=upper), width=0.075) +
  geom_line() +
  geom_point() +
  ylab("RT (ms)") +
  xlab("COM Velocity (m/s)") +
  ggtitle("RT~COM Velocity") +
  theme_classic()

print(RTCOMVE)

##This is just a clear and significant linear relationship in that the fastest RT is also predicting the fastest COM Velocities.

#Posthocs (Tukey tests for sanity checks. Not really needed.)

#Summary of posthocs
summary(glht(m.MSL.RT, linfct = mcp(Block = "Tukey")), test = adjusted("holm"))
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = AvgTrial.RT ~ Block + (1 | Subject), data = d.MSL)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 2 - 1 == 0  -299.48      32.61  -9.184   <2e-16 ***
## 3 - 1 == 0  -348.79      32.61 -10.697   <2e-16 ***
## 4 - 1 == 0  -365.19      32.61 -11.200   <2e-16 ***
## 5 - 1 == 0  -373.81      32.61 -11.464   <2e-16 ***
## 3 - 2 == 0   -49.30      32.61  -1.512    0.522    
## 4 - 2 == 0   -65.71      32.61  -2.015    0.219    
## 5 - 2 == 0   -74.33      32.61  -2.280    0.136    
## 4 - 3 == 0   -16.41      32.61  -0.503    1.000    
## 5 - 3 == 0   -25.03      32.61  -0.768    1.000    
## 5 - 4 == 0    -8.62      32.61  -0.264    1.000    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)
summary(glht(m.MSL.ACC, linfct = mcp(Trial.ACC.Num = "Tukey")), test = adjusted("holm"))
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = AvgTrial.RT ~ Trial.ACC.Num + (1 | Subject), data = d.MSL)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 1 - 0 == 0   -289.9       25.3  -11.46   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)
summary(glht(m.MSL.RTACC, linfct = mcp(Block = "Tukey")), test = adjusted("holm"))
## Warning in mcp2matrix(model, linfct = linfct): covariate interactions found --
## default contrast might be inappropriate
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = AvgTrial.RT ~ Block * Trial.ACC.Num + (1 | Subject), 
##     data = d.MSL)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 2 - 1 == 0 -377.786     53.960  -7.001 2.03e-11 ***
## 3 - 1 == 0 -461.216     64.157  -7.189 5.88e-12 ***
## 4 - 1 == 0 -451.782     62.602  -7.217 5.32e-12 ***
## 5 - 1 == 0 -363.227     68.082  -5.335 6.68e-07 ***
## 3 - 2 == 0  -83.429     69.844  -1.195        1    
## 4 - 2 == 0  -73.996     69.000  -1.072        1    
## 5 - 2 == 0   14.559     74.609   0.195        1    
## 4 - 3 == 0    9.434     76.877   0.123        1    
## 5 - 3 == 0   97.988     82.238   1.192        1    
## 5 - 4 == 0   88.555     80.856   1.095        1    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)
summary(glht(m.MSL.COMVE.ACC, linfct = mcp(Trial.ACC.Num = "Tukey")), test = adjusted("holm"))
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = COM.X.VE ~ Trial.ACC.Num + (1 | Subject), data = d.MSL)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 1 - 0 == 0 0.006658   0.001915   3.476 0.000509 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)
summary(glht(m.MSL.COMVE, linfct = mcp(Block = "Tukey")), test = adjusted("holm"))
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = COM.X.VE ~ Block + (1 | Subject), data = d.MSL)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 2 - 1 == 0 0.007319   0.002569   2.849  0.01316 *  
## 3 - 1 == 0 0.012244   0.002569   4.766 1.13e-05 ***
## 4 - 1 == 0 0.015556   0.002569   6.055 1.12e-08 ***
## 5 - 1 == 0 0.024984   0.002569   9.725  < 2e-16 ***
## 3 - 2 == 0 0.004925   0.002569   1.917  0.11049    
## 4 - 2 == 0 0.008237   0.002569   3.206  0.00538 ** 
## 5 - 2 == 0 0.017665   0.002569   6.876 5.53e-11 ***
## 4 - 3 == 0 0.003312   0.002569   1.289  0.19728    
## 5 - 3 == 0 0.012740   0.002569   4.959 4.95e-06 ***
## 5 - 4 == 0 0.009428   0.002569   3.670  0.00121 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)
summary(glht(m.MSL.COMVE.RT.Inter, linfct = mcp(Block = "Tukey")), test = adjusted("holm"))
## Warning in mcp2matrix(model, linfct = linfct): covariate interactions found --
## default contrast might be inappropriate
## 
##   Simultaneous Tests for General Linear Hypotheses
## 
## Multiple Comparisons of Means: Tukey Contrasts
## 
## 
## Fit: lmer(formula = AvgTrial.RT ~ Block * COM.X.VE + (1 | Subject), 
##     data = d.MSL)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 2 - 1 == 0  -311.03      35.75  -8.701   <2e-16 ***
## 3 - 1 == 0  -359.14      35.90 -10.003   <2e-16 ***
## 4 - 1 == 0  -370.00      36.11 -10.246   <2e-16 ***
## 5 - 1 == 0  -386.23      38.32 -10.079   <2e-16 ***
## 3 - 2 == 0   -48.11      36.78  -1.308    0.764    
## 4 - 2 == 0   -58.97      37.00  -1.594    0.555    
## 5 - 2 == 0   -75.20      39.16  -1.920    0.329    
## 4 - 3 == 0   -10.86      37.16  -0.292    1.000    
## 5 - 3 == 0   -27.09      39.31  -0.689    1.000    
## 5 - 4 == 0   -16.23      39.48  -0.411    1.000    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)