#Set Working Directory

setwd("C:/Users/RussellChan/OneDrive - University of Twente/2020_MSCA_IF/1_Master_thesis/1_ Daphne_2020_ML_Expertise/Behavioural Results")

#Load packages

library(readxl)
## Warning: package 'readxl' was built under R version 4.1.1
library(haven)
## Warning: package 'haven' was built under R version 4.1.1
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.1
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.4     v dplyr   1.0.7
## v tidyr   1.1.3     v stringr 1.4.0
## v readr   2.0.1     v forcats 0.5.1
## Warning: package 'ggplot2' was built under R version 4.1.1
## Warning: package 'tibble' was built under R version 4.1.1
## Warning: package 'tidyr' was built under R version 4.1.1
## Warning: package 'readr' was built under R version 4.1.1
## Warning: package 'purrr' was built under R version 4.1.1
## Warning: package 'dplyr' was built under R version 4.1.1
## Warning: package 'stringr' was built under R version 4.1.1
## Warning: package 'forcats' was built under R version 4.1.1
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
library(lme4)
## Warning: package 'lme4' was built under R version 4.1.1
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
library(effects)
## Warning: package 'effects' was built under R version 4.1.1
## Loading required package: carData
## Warning: package 'carData' was built under R version 4.1.1
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
library(lattice)
## Warning: package 'lattice' was built under R version 4.1.1
library(car)
## Warning: package 'car' was built under R version 4.1.1
## 
## Attaching package: 'car'
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
library(ggplot2)
library(knitr)
## Warning: package 'knitr' was built under R version 4.1.1
library(reshape2)
## Warning: package 'reshape2' was built under R version 4.1.1
## 
## Attaching package: 'reshape2'
## The following object is masked from 'package:tidyr':
## 
##     smiths
library(dplyr)
library(forcats)
library(DHARMa)
## Warning: package 'DHARMa' was built under R version 4.1.1
## This is DHARMa 0.4.3. For overview type '?DHARMa'. For recent changes, type news(package = 'DHARMa') Note: Syntax of plotResiduals has changed in 0.3.0, see ?plotResiduals for details
library(Hmisc)
## Warning: package 'Hmisc' was built under R version 4.1.1
## Loading required package: survival
## Loading required package: Formula
## Warning: package 'Formula' was built under R version 4.1.1
## 
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:dplyr':
## 
##     src, summarize
## The following objects are masked from 'package:base':
## 
##     format.pval, units
library(phia)
## Warning: package 'phia' was built under R version 4.1.1
library(lsmeans)
## Warning: package 'lsmeans' was built under R version 4.1.1
## Loading required package: emmeans
## Warning: package 'emmeans' was built under R version 4.1.1
## The 'lsmeans' package is now basically a front end for 'emmeans'.
## Users are encouraged to switch the rest of the way.
## See help('transition') for more information, including how to
## convert old 'lsmeans' objects and scripts to work with 'emmeans'.
library(emmeans)
library(multcomp)
## Warning: package 'multcomp' was built under R version 4.1.1
## Loading required package: mvtnorm
## Warning: package 'mvtnorm' was built under R version 4.1.1
## Loading required package: TH.data
## Warning: package 'TH.data' was built under R version 4.1.1
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:dplyr':
## 
##     select
## 
## Attaching package: 'TH.data'
## The following object is masked from 'package:MASS':
## 
##     geyser
library(nlme)
## Warning: package 'nlme' was built under R version 4.1.1
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:lme4':
## 
##     lmList
## The following object is masked from 'package:dplyr':
## 
##     collapse
library(gplots)
## Warning: package 'gplots' was built under R version 4.1.1
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess

#Load DF

## Importing the dataset
d.ML<-read.table("FinalBehavDF26_211117.csv", sep = ",", header = T, stringsAsFactors = F)
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
## EOF within quoted string
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
## number of items read is not a multiple of the number of columns
d.ML2<-read.table("FinalBehavDF26_Keypress_211117.csv", sep = ",", header = T, stringsAsFactors = F)
## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
## EOF within quoted string

## Warning in scan(file = file, what = what, sep = sep, quote = quote, dec = dec, :
## number of items read is not a multiple of the number of columns
d.MSL <- read_excel("FinalBehavDF26_211117.xlsx")
d.MSL2 <- read_excel("FinalBehavDF26_Keypress_211117.xlsx")

d.MSL3 <- read_excel("6Key_Trial_ACC_Hand_211118.xlsx")

#Create Factors

#Factors for blocks
d.MSL$Subject <- factor(d.MSL$Subject)
d.MSL$Block <- factor(d.MSL$Block)
d.MSL$Trial.ACC <- factor(d.MSL$Trial.ACC)
d.MSL$Hand.indicator <- factor(d.MSL$Hand.indicator)

#For finger positioning
d.MSL2$Position <- factor(d.MSL2$Position)
d.MSL2$Block <- factor(d.MSL2$Block)
d.MSL2$Subject <- factor(d.MSL2$Subject)

#For ACC
d.MSL3$Block <- factor(d.MSL3$Block)
d.MSL3$Subject <- factor(d.MSL3$Subject)

#Models

#Checking ACC
m.MSL.ACCper <- lmer(ACC.Per ~ Block + (1|Subject), data = d.MSL3)
Anova(m.MSL.ACCper)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: ACC.Per
##        Chisq Df Pr(>Chisq)    
## Block 168.59  4  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m.MSL.ACCper)
## Linear mixed model fit by REML ['lmerMod']
## Formula: ACC.Per ~ Block + (1 | Subject)
##    Data: d.MSL3
## 
## REML criterion at convergence: 1042.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9429 -0.5207  0.0537  0.5705  3.5144 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 327.7    18.10   
##  Residual             126.7    11.25   
## Number of obs: 130, groups:  Subject, 26
## 
## Fixed effects:
##             Estimate Std. Error t value
## (Intercept)   44.872      4.181  10.733
## Block2        23.478      3.122   7.521
## Block3        30.369      3.122   9.729
## Block4        34.135      3.122  10.935
## Block5        34.135      3.122  10.935
## 
## Correlation of Fixed Effects:
##        (Intr) Block2 Block3 Block4
## Block2 -0.373                     
## Block3 -0.373  0.500              
## Block4 -0.373  0.500  0.500       
## Block5 -0.373  0.500  0.500  0.500
#Overall Trial and ACC
m.MSL.RTACC <- lmer(AvgTrial.RT ~ Block * Trial.ACC + (1|Subject), data = d.MSL)
Anova(m.MSL.RTACC)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: AvgTrial.RT
##                   Chisq Df Pr(>Chisq)    
## Block           312.990  4  < 2.2e-16 ***
## Trial.ACC       293.977  1  < 2.2e-16 ***
## Block:Trial.ACC  21.326  4  0.0002729 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m.MSL.RTACC)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ Block * Trial.ACC + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 92376.3
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -2.000 -0.295 -0.079  0.151 55.044 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  20781   144.2   
##  Residual             157266   396.6   
## Number of obs: 6240, groups:  Subject, 26
## 
## Fixed effects:
##                           Estimate Std. Error t value
## (Intercept)                 498.85      32.97  15.132
## Block2                     -127.82      21.63  -5.910
## Block3                     -176.64      21.25  -8.314
## Block4                     -192.26      21.08  -9.121
## Block5                     -207.95      21.10  -9.857
## Trial.ACCIncorrect          288.37      23.06  12.508
## Block2:Trial.ACCIncorrect  -102.13      33.25  -3.071
## Block3:Trial.ACCIncorrect  -149.49      34.74  -4.303
## Block4:Trial.ACCIncorrect   -99.63      35.83  -2.781
## Block5:Trial.ACCIncorrect   -56.25      35.98  -1.563
## 
## Correlation of Fixed Effects:
##             (Intr) Block2 Block3 Block4 Block5 T.ACCI B2:T.A B3:T.A B4:T.A
## Block2      -0.398                                                        
## Block3      -0.406  0.617                                                 
## Block4      -0.411  0.622  0.634                                          
## Block5      -0.411  0.621  0.634  0.641                                   
## Trl.ACCIncr -0.386  0.574  0.586  0.596  0.596                            
## Blc2:T.ACCI  0.256 -0.653 -0.402 -0.404 -0.403 -0.665                     
## Blc3:T.ACCI  0.244 -0.379 -0.614 -0.387 -0.386 -0.634  0.453              
## Blc4:T.ACCI  0.240 -0.368 -0.376 -0.590 -0.378 -0.623  0.436  0.420       
## Blc5:T.ACCI  0.240 -0.366 -0.374 -0.378 -0.590 -0.623  0.432  0.418  0.407
#RT * Hand * ACC
m.MSL.RTACCHand <- lmer(AvgTrial.RT ~ Block * Trial.ACC * Hand.indicator + (1|Subject), data = d.MSL)
Anova(m.MSL.RTACCHand)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: AvgTrial.RT
##                                   Chisq Df Pr(>Chisq)    
## Block                          312.6479  4  < 2.2e-16 ***
## Trial.ACC                      293.0182  1  < 2.2e-16 ***
## Hand.indicator                   1.0287  1  0.3104548    
## Block:Trial.ACC                 20.9217  4  0.0003282 ***
## Block:Hand.indicator             2.1289  4  0.7120680    
## Trial.ACC:Hand.indicator         1.5804  1  0.2087086    
## Block:Trial.ACC:Hand.indicator   1.7269  4  0.7858234    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m.MSL.RTACCHand)
## Linear mixed model fit by REML ['lmerMod']
## Formula: AvgTrial.RT ~ Block * Trial.ACC * Hand.indicator + (1 | Subject)
##    Data: d.MSL
## 
## REML criterion at convergence: 92280
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.999 -0.296 -0.078  0.153 54.940 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  20733   144.0   
##  Residual             157331   396.6   
## Number of obs: 6240, groups:  Subject, 26
## 
## Fixed effects:
##                                               Estimate Std. Error t value
## (Intercept)                                    500.556     36.710  13.635
## Block2                                        -134.220     30.266  -4.435
## Block3                                        -170.634     29.646  -5.756
## Block4                                        -196.886     29.480  -6.679
## Block5                                        -209.927     29.401  -7.140
## Trial.ACCIncorrect                             248.618     32.160   7.731
## Hand.indicatorRight                             -3.636     33.591  -0.108
## Block2:Trial.ACCIncorrect                      -70.811     46.914  -1.509
## Block3:Trial.ACCIncorrect                     -110.416     49.272  -2.241
## Block4:Trial.ACCIncorrect                      -72.316     50.294  -1.438
## Block5:Trial.ACCIncorrect                      -17.182     51.232  -0.335
## Block2:Hand.indicatorRight                      12.919     43.210   0.299
## Block3:Hand.indicatorRight                     -12.074     42.419  -0.285
## Block4:Hand.indicatorRight                       9.387     42.044   0.223
## Block5:Hand.indicatorRight                       4.090     42.047   0.097
## Trial.ACCIncorrect:Hand.indicatorRight          77.882     45.286   1.720
## Block2:Trial.ACCIncorrect:Hand.indicatorRight  -60.692     66.261  -0.916
## Block3:Trial.ACCIncorrect:Hand.indicatorRight  -75.445     69.079  -1.092
## Block4:Trial.ACCIncorrect:Hand.indicatorRight  -51.929     71.510  -0.726
## Block5:Trial.ACCIncorrect:Hand.indicatorRight  -76.142     71.540  -1.064
## 
## Correlation matrix not shown by default, as p = 20 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it

#Finger press

#Model for concatenation
m.MSL.position <- lmer(feedback.RT ~ Position * Block + (1|Subject), data = d.MSL2)
Anova(m.MSL.position)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: feedback.RT
##                   Chisq Df Pr(>Chisq)    
## Position       1190.457  5  < 2.2e-16 ***
## Block           907.916  4  < 2.2e-16 ***
## Position:Block   53.748 20  6.303e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(m.MSL.position)
## Linear mixed model fit by REML ['lmerMod']
## Formula: feedback.RT ~ Position * Block + (1 | Subject)
##    Data: d.MSL2
## 
## REML criterion at convergence: 604031.4
## 
## Scaled residuals: 
##    Min     1Q Median     3Q    Max 
## -1.688 -0.267 -0.105  0.047 96.365 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)  26851   163.9   
##  Residual             597114   772.7   
## Number of obs: 37440, groups:  Subject, 26
## 
## Fixed effects:
##                  Estimate Std. Error t value
## (Intercept)      1044.549     38.874  26.870
## Position2        -464.724     30.934 -15.023
## Position3        -511.147     30.934 -16.524
## Position4        -459.536     30.934 -14.855
## Position5        -447.877     30.934 -14.478
## Position6        -437.054     30.934 -14.129
## Block2           -331.837     30.934 -10.727
## Block3           -418.853     30.934 -13.540
## Block4           -430.942     30.934 -13.931
## Block5           -399.487     30.934 -12.914
## Position2:Block2  122.889     43.747   2.809
## Position3:Block2  202.824     43.747   4.636
## Position4:Block2  173.731     43.747   3.971
## Position5:Block2  113.039     43.747   2.584
## Position6:Block2   11.473     43.747   0.262
## Position2:Block3  163.530     43.747   3.738
## Position3:Block3  195.252     43.747   4.463
## Position4:Block3  173.803     43.747   3.973
## Position5:Block3  122.696     43.747   2.805
## Position6:Block3   50.469     43.747   1.154
## Position2:Block4  168.374     43.747   3.849
## Position3:Block4  195.320     43.747   4.465
## Position4:Block4  183.142     43.747   4.186
## Position5:Block4  122.687     43.747   2.804
## Position6:Block4   46.493     43.747   1.063
## Position2:Block5  123.251     43.747   2.817
## Position3:Block5  143.081     43.747   3.271
## Position4:Block5  140.810     43.747   3.219
## Position5:Block5   76.185     43.747   1.741
## Position6:Block5    4.442     43.747   0.102
## 
## Correlation matrix not shown by default, as p = 30 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it

#Posthocs

#ACC Percentage
lsmeans(m.MSL.ACCper, pairwise ~ Block )
## $lsmeans
##  Block lsmean   SE   df lower.CL upper.CL
##  1       44.9 4.18 40.6     36.4     53.3
##  2       68.3 4.18 40.6     59.9     76.8
##  3       75.2 4.18 40.6     66.8     83.7
##  4       79.0 4.18 40.6     70.6     87.5
##  5       79.0 4.18 40.6     70.6     87.5
## 
## Degrees-of-freedom method: kenward-roger 
## Confidence level used: 0.95 
## 
## $contrasts
##  contrast estimate   SE  df t.ratio p.value
##  1 - 2      -23.48 3.12 100  -7.521  <.0001
##  1 - 3      -30.37 3.12 100  -9.729  <.0001
##  1 - 4      -34.13 3.12 100 -10.935  <.0001
##  1 - 5      -34.13 3.12 100 -10.935  <.0001
##  2 - 3       -6.89 3.12 100  -2.208  0.1854
##  2 - 4      -10.66 3.12 100  -3.414  0.0081
##  2 - 5      -10.66 3.12 100  -3.414  0.0081
##  3 - 4       -3.77 3.12 100  -1.206  0.7476
##  3 - 5       -3.77 3.12 100  -1.206  0.7476
##  4 - 5        0.00 3.12 100   0.000  1.0000
## 
## Degrees-of-freedom method: kenward-roger 
## P value adjustment: tukey method for comparing a family of 5 estimates
#RT ACC Posthocs
lsmeans(m.MSL.RTACC, pairwise ~ Block | Trial.ACC) #Block_ACC
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 6240' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 6240)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 6240' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 6240)' or larger];
## but be warned that this may result in large computation time and memory use.
## $lsmeans
## Trial.ACC = Correct:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        499 33.0 Inf       434       563
##  2        371 31.4 Inf       309       433
##  3        322 31.1 Inf       261       383
##  4        307 31.0 Inf       246       367
##  5        291 31.0 Inf       230       352
## 
## Trial.ACC = Incorrect:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        787 32.1 Inf       724       850
##  2        557 34.8 Inf       489       626
##  3        461 36.5 Inf       389       533
##  4        495 37.6 Inf       422       569
##  5        523 37.7 Inf       449       597
## 
## Degrees-of-freedom method: asymptotic 
## Confidence level used: 0.95 
## 
## $contrasts
## Trial.ACC = Correct:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2       127.8 21.6 Inf   5.910  <.0001
##  1 - 3       176.6 21.2 Inf   8.314  <.0001
##  1 - 4       192.3 21.1 Inf   9.121  <.0001
##  1 - 5       208.0 21.1 Inf   9.857  <.0001
##  2 - 3        48.8 18.8 Inf   2.601  0.0702
##  2 - 4        64.4 18.6 Inf   3.469  0.0047
##  2 - 5        80.1 18.6 Inf   4.309  0.0002
##  3 - 4        15.6 18.1 Inf   0.863  0.9105
##  3 - 5        31.3 18.1 Inf   1.728  0.4166
##  4 - 5        15.7 17.9 Inf   0.878  0.9050
## 
## Trial.ACC = Incorrect:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2       229.9 25.2 Inf   9.130  <.0001
##  1 - 3       326.1 27.4 Inf  11.891  <.0001
##  1 - 4       291.9 28.9 Inf  10.086  <.0001
##  1 - 5       264.2 29.0 Inf   9.098  <.0001
##  2 - 3        96.2 30.2 Inf   3.186  0.0126
##  2 - 4        61.9 31.7 Inf   1.956  0.2877
##  2 - 5        34.3 31.8 Inf   1.077  0.8183
##  3 - 4       -34.2 33.4 Inf  -1.026  0.8433
##  3 - 5       -61.9 33.5 Inf  -1.849  0.3452
##  4 - 5       -27.7 34.7 Inf  -0.797  0.9315
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 5 estimates
#Between blocks for accurate trials, differences were predicated mainly in 1st block RT and rest of the blocks and some of Block 2.  
#For inaccuarate trials, differences were between block 1 and rest of blocks and between block 2 and 3.  Rest were not significant.

#ACC_Block
lsmeans(m.MSL.RTACC, pairwise ~ Trial.ACC | Block) 
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 6240' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 6240)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 6240' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 6240)' or larger];
## but be warned that this may result in large computation time and memory use.
## $lsmeans
## Block = 1:
##  Trial.ACC lsmean   SE  df asymp.LCL asymp.UCL
##  Correct      499 33.0 Inf       434       563
##  Incorrect    787 32.1 Inf       724       850
## 
## Block = 2:
##  Trial.ACC lsmean   SE  df asymp.LCL asymp.UCL
##  Correct      371 31.4 Inf       309       433
##  Incorrect    557 34.8 Inf       489       626
## 
## Block = 3:
##  Trial.ACC lsmean   SE  df asymp.LCL asymp.UCL
##  Correct      322 31.1 Inf       261       383
##  Incorrect    461 36.5 Inf       389       533
## 
## Block = 4:
##  Trial.ACC lsmean   SE  df asymp.LCL asymp.UCL
##  Correct      307 31.0 Inf       246       367
##  Incorrect    495 37.6 Inf       422       569
## 
## Block = 5:
##  Trial.ACC lsmean   SE  df asymp.LCL asymp.UCL
##  Correct      291 31.0 Inf       230       352
##  Incorrect    523 37.7 Inf       449       597
## 
## Degrees-of-freedom method: asymptotic 
## Confidence level used: 0.95 
## 
## $contrasts
## Block = 1:
##  contrast            estimate   SE  df z.ratio p.value
##  Correct - Incorrect     -288 23.1 Inf -12.508  <.0001
## 
## Block = 2:
##  contrast            estimate   SE  df z.ratio p.value
##  Correct - Incorrect     -186 24.9 Inf  -7.489  <.0001
## 
## Block = 3:
##  contrast            estimate   SE  df z.ratio p.value
##  Correct - Incorrect     -139 26.9 Inf  -5.165  <.0001
## 
## Block = 4:
##  contrast            estimate   SE  df z.ratio p.value
##  Correct - Incorrect     -189 28.0 Inf  -6.734  <.0001
## 
## Block = 5:
##  contrast            estimate   SE  df z.ratio p.value
##  Correct - Incorrect     -232 28.2 Inf  -8.245  <.0001
## 
## Degrees-of-freedom method: asymptotic
#Across all blocks, accurate trials were faster than inaccurate trials

#Quick plots
emmip(m.MSL.RTACC, Trial.ACC ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 6240' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 6240)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 6240' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 6240)' or larger];
## but be warned that this may result in large computation time and memory use.

#Concetanation
summary(glht(m.MSL.position, 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 = feedback.RT ~ Position * Block + (1 | Subject), 
##     data = d.MSL2)
## 
## Linear Hypotheses:
##            Estimate Std. Error z value Pr(>|z|)    
## 2 - 1 == 0  -331.84      30.93 -10.727  < 2e-16 ***
## 3 - 1 == 0  -418.85      30.93 -13.540  < 2e-16 ***
## 4 - 1 == 0  -430.94      30.93 -13.931  < 2e-16 ***
## 5 - 1 == 0  -399.49      30.93 -12.914  < 2e-16 ***
## 3 - 2 == 0   -87.02      30.93  -2.813  0.02454 *  
## 4 - 2 == 0   -99.10      30.93  -3.204  0.00814 ** 
## 5 - 2 == 0   -67.65      30.93  -2.187  0.11499    
## 4 - 3 == 0   -12.09      30.93  -0.391  1.00000    
## 5 - 3 == 0    19.37      30.93   0.626  1.00000    
## 5 - 4 == 0    31.45      30.93   1.017  0.92772    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## (Adjusted p values reported -- holm method)
lsmeans(m.MSL.position, pairwise ~ Block | Position)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 37440' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 37440)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 37440' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 37440)' or larger];
## but be warned that this may result in large computation time and memory use.
## $lsmeans
## Position = 1:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1       1045 38.9 Inf       968      1121
##  2        713 38.9 Inf       637       789
##  3        626 38.9 Inf       550       702
##  4        614 38.9 Inf       537       690
##  5        645 38.9 Inf       569       721
## 
## Position = 2:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        580 38.9 Inf       504       656
##  2        371 38.9 Inf       295       447
##  3        325 38.9 Inf       248       401
##  4        317 38.9 Inf       241       393
##  5        304 38.9 Inf       227       380
## 
## Position = 3:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        533 38.9 Inf       457       610
##  2        404 38.9 Inf       328       481
##  3        310 38.9 Inf       234       386
##  4        298 38.9 Inf       222       374
##  5        277 38.9 Inf       201       353
## 
## Position = 4:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        585 38.9 Inf       509       661
##  2        427 38.9 Inf       351       503
##  3        340 38.9 Inf       264       416
##  4        337 38.9 Inf       261       413
##  5        326 38.9 Inf       250       403
## 
## Position = 5:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        597 38.9 Inf       520       673
##  2        378 38.9 Inf       302       454
##  3        301 38.9 Inf       224       377
##  4        288 38.9 Inf       212       365
##  5        273 38.9 Inf       197       350
## 
## Position = 6:
##  Block lsmean   SE  df asymp.LCL asymp.UCL
##  1        607 38.9 Inf       531       684
##  2        287 38.9 Inf       211       363
##  3        239 38.9 Inf       163       315
##  4        223 38.9 Inf       147       299
##  5        212 38.9 Inf       136       289
## 
## Degrees-of-freedom method: asymptotic 
## Confidence level used: 0.95 
## 
## $contrasts
## Position = 1:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      331.84 30.9 Inf  10.727  <.0001
##  1 - 3      418.85 30.9 Inf  13.540  <.0001
##  1 - 4      430.94 30.9 Inf  13.931  <.0001
##  1 - 5      399.49 30.9 Inf  12.914  <.0001
##  2 - 3       87.02 30.9 Inf   2.813  0.0394
##  2 - 4       99.11 30.9 Inf   3.204  0.0118
##  2 - 5       67.65 30.9 Inf   2.187  0.1846
##  3 - 4       12.09 30.9 Inf   0.391  0.9951
##  3 - 5      -19.37 30.9 Inf  -0.626  0.9709
##  4 - 5      -31.45 30.9 Inf  -1.017  0.8477
## 
## Position = 2:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      208.95 30.9 Inf   6.755  <.0001
##  1 - 3      255.32 30.9 Inf   8.254  <.0001
##  1 - 4      262.57 30.9 Inf   8.488  <.0001
##  1 - 5      276.24 30.9 Inf   8.930  <.0001
##  2 - 3       46.38 30.9 Inf   1.499  0.5630
##  2 - 4       53.62 30.9 Inf   1.733  0.4133
##  2 - 5       67.29 30.9 Inf   2.175  0.1891
##  3 - 4        7.24 30.9 Inf   0.234  0.9993
##  3 - 5       20.91 30.9 Inf   0.676  0.9616
##  4 - 5       13.67 30.9 Inf   0.442  0.9921
## 
## Position = 3:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      129.01 30.9 Inf   4.171  0.0003
##  1 - 3      223.60 30.9 Inf   7.228  <.0001
##  1 - 4      235.62 30.9 Inf   7.617  <.0001
##  1 - 5      256.41 30.9 Inf   8.289  <.0001
##  2 - 3       94.59 30.9 Inf   3.058  0.0189
##  2 - 4      106.61 30.9 Inf   3.446  0.0052
##  2 - 5      127.39 30.9 Inf   4.118  0.0004
##  3 - 4       12.02 30.9 Inf   0.389  0.9952
##  3 - 5       32.80 30.9 Inf   1.060  0.8268
##  4 - 5       20.78 30.9 Inf   0.672  0.9625
## 
## Position = 4:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      158.11 30.9 Inf   5.111  <.0001
##  1 - 3      245.05 30.9 Inf   7.922  <.0001
##  1 - 4      247.80 30.9 Inf   8.011  <.0001
##  1 - 5      258.68 30.9 Inf   8.362  <.0001
##  2 - 3       86.94 30.9 Inf   2.811  0.0397
##  2 - 4       89.69 30.9 Inf   2.900  0.0307
##  2 - 5      100.57 30.9 Inf   3.251  0.0101
##  3 - 4        2.75 30.9 Inf   0.089  1.0000
##  3 - 5       13.63 30.9 Inf   0.441  0.9922
##  4 - 5       10.88 30.9 Inf   0.352  0.9967
## 
## Position = 5:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      218.80 30.9 Inf   7.073  <.0001
##  1 - 3      296.16 30.9 Inf   9.574  <.0001
##  1 - 4      308.25 30.9 Inf   9.965  <.0001
##  1 - 5      323.30 30.9 Inf  10.451  <.0001
##  2 - 3       77.36 30.9 Inf   2.501  0.0904
##  2 - 4       89.46 30.9 Inf   2.892  0.0314
##  2 - 5      104.50 30.9 Inf   3.378  0.0065
##  3 - 4       12.10 30.9 Inf   0.391  0.9951
##  3 - 5       27.14 30.9 Inf   0.878  0.9053
##  4 - 5       15.05 30.9 Inf   0.486  0.9886
## 
## Position = 6:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      320.36 30.9 Inf  10.356  <.0001
##  1 - 3      368.38 30.9 Inf  11.909  <.0001
##  1 - 4      384.45 30.9 Inf  12.428  <.0001
##  1 - 5      395.05 30.9 Inf  12.771  <.0001
##  2 - 3       48.02 30.9 Inf   1.552  0.5282
##  2 - 4       64.08 30.9 Inf   2.072  0.2324
##  2 - 5       74.68 30.9 Inf   2.414  0.1114
##  3 - 4       16.06 30.9 Inf   0.519  0.9855
##  3 - 5       26.66 30.9 Inf   0.862  0.9108
##  4 - 5       10.60 30.9 Inf   0.343  0.9970
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 5 estimates
lsmeans(m.MSL.position, pairwise ~ Position | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 37440' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 37440)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 37440' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 37440)' or larger];
## but be warned that this may result in large computation time and memory use.
## $lsmeans
## Block = 1:
##  Position lsmean   SE  df asymp.LCL asymp.UCL
##  1          1045 38.9 Inf       968      1121
##  2           580 38.9 Inf       504       656
##  3           533 38.9 Inf       457       610
##  4           585 38.9 Inf       509       661
##  5           597 38.9 Inf       520       673
##  6           607 38.9 Inf       531       684
## 
## Block = 2:
##  Position lsmean   SE  df asymp.LCL asymp.UCL
##  1           713 38.9 Inf       637       789
##  2           371 38.9 Inf       295       447
##  3           404 38.9 Inf       328       481
##  4           427 38.9 Inf       351       503
##  5           378 38.9 Inf       302       454
##  6           287 38.9 Inf       211       363
## 
## Block = 3:
##  Position lsmean   SE  df asymp.LCL asymp.UCL
##  1           626 38.9 Inf       550       702
##  2           325 38.9 Inf       248       401
##  3           310 38.9 Inf       234       386
##  4           340 38.9 Inf       264       416
##  5           301 38.9 Inf       224       377
##  6           239 38.9 Inf       163       315
## 
## Block = 4:
##  Position lsmean   SE  df asymp.LCL asymp.UCL
##  1           614 38.9 Inf       537       690
##  2           317 38.9 Inf       241       393
##  3           298 38.9 Inf       222       374
##  4           337 38.9 Inf       261       413
##  5           288 38.9 Inf       212       365
##  6           223 38.9 Inf       147       299
## 
## Block = 5:
##  Position lsmean   SE  df asymp.LCL asymp.UCL
##  1           645 38.9 Inf       569       721
##  2           304 38.9 Inf       227       380
##  3           277 38.9 Inf       201       353
##  4           326 38.9 Inf       250       403
##  5           273 38.9 Inf       197       350
##  6           212 38.9 Inf       136       289
## 
## Degrees-of-freedom method: asymptotic 
## Confidence level used: 0.95 
## 
## $contrasts
## Block = 1:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      464.72 30.9 Inf  15.023  <.0001
##  1 - 3      511.15 30.9 Inf  16.524  <.0001
##  1 - 4      459.54 30.9 Inf  14.855  <.0001
##  1 - 5      447.88 30.9 Inf  14.478  <.0001
##  1 - 6      437.05 30.9 Inf  14.129  <.0001
##  2 - 3       46.42 30.9 Inf   1.501  0.6639
##  2 - 4       -5.19 30.9 Inf  -0.168  1.0000
##  2 - 5      -16.85 30.9 Inf  -0.545  0.9943
##  2 - 6      -27.67 30.9 Inf  -0.894  0.9480
##  3 - 4      -51.61 30.9 Inf  -1.668  0.5528
##  3 - 5      -63.27 30.9 Inf  -2.045  0.3166
##  3 - 6      -74.09 30.9 Inf  -2.395  0.1578
##  4 - 5      -11.66 30.9 Inf  -0.377  0.9990
##  4 - 6      -22.48 30.9 Inf  -0.727  0.9787
##  5 - 6      -10.82 30.9 Inf  -0.350  0.9993
## 
## Block = 2:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      341.84 30.9 Inf  11.050  <.0001
##  1 - 3      308.32 30.9 Inf   9.967  <.0001
##  1 - 4      285.81 30.9 Inf   9.239  <.0001
##  1 - 5      334.84 30.9 Inf  10.824  <.0001
##  1 - 6      425.58 30.9 Inf  13.758  <.0001
##  2 - 3      -33.51 30.9 Inf  -1.083  0.8882
##  2 - 4      -56.03 30.9 Inf  -1.811  0.4583
##  2 - 5       -7.00 30.9 Inf  -0.226  0.9999
##  2 - 6       83.75 30.9 Inf   2.707  0.0738
##  3 - 4      -22.52 30.9 Inf  -0.728  0.9786
##  3 - 5       26.52 30.9 Inf   0.857  0.9565
##  3 - 6      117.26 30.9 Inf   3.791  0.0021
##  4 - 5       49.03 30.9 Inf   1.585  0.6085
##  4 - 6      139.78 30.9 Inf   4.519  0.0001
##  5 - 6       90.74 30.9 Inf   2.933  0.0393
## 
## Block = 3:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      301.19 30.9 Inf   9.737  <.0001
##  1 - 3      315.89 30.9 Inf  10.212  <.0001
##  1 - 4      285.73 30.9 Inf   9.237  <.0001
##  1 - 5      325.18 30.9 Inf  10.512  <.0001
##  1 - 6      386.59 30.9 Inf  12.497  <.0001
##  2 - 3       14.70 30.9 Inf   0.475  0.9970
##  2 - 4      -15.46 30.9 Inf  -0.500  0.9962
##  2 - 5       23.99 30.9 Inf   0.775  0.9717
##  2 - 6       85.39 30.9 Inf   2.760  0.0640
##  3 - 4      -30.16 30.9 Inf  -0.975  0.9260
##  3 - 5        9.29 30.9 Inf   0.300  0.9997
##  3 - 6       70.69 30.9 Inf   2.285  0.2000
##  4 - 5       39.45 30.9 Inf   1.275  0.7987
##  4 - 6      100.85 30.9 Inf   3.260  0.0142
##  5 - 6       61.40 30.9 Inf   1.985  0.3509
## 
## Block = 4:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      296.35 30.9 Inf   9.580  <.0001
##  1 - 3      315.83 30.9 Inf  10.210  <.0001
##  1 - 4      276.39 30.9 Inf   8.935  <.0001
##  1 - 5      325.19 30.9 Inf  10.512  <.0001
##  1 - 6      390.56 30.9 Inf  12.626  <.0001
##  2 - 3       19.48 30.9 Inf   0.630  0.9889
##  2 - 4      -19.96 30.9 Inf  -0.645  0.9875
##  2 - 5       28.84 30.9 Inf   0.932  0.9383
##  2 - 6       94.21 30.9 Inf   3.046  0.0281
##  3 - 4      -39.43 30.9 Inf  -1.275  0.7990
##  3 - 5        9.36 30.9 Inf   0.303  0.9997
##  3 - 6       74.73 30.9 Inf   2.416  0.1506
##  4 - 5       48.80 30.9 Inf   1.577  0.6135
##  4 - 6      114.17 30.9 Inf   3.691  0.0031
##  5 - 6       65.37 30.9 Inf   2.113  0.2803
## 
## Block = 5:
##  contrast estimate   SE  df z.ratio p.value
##  1 - 2      341.47 30.9 Inf  11.039  <.0001
##  1 - 3      368.07 30.9 Inf  11.898  <.0001
##  1 - 4      318.73 30.9 Inf  10.303  <.0001
##  1 - 5      371.69 30.9 Inf  12.016  <.0001
##  1 - 6      432.61 30.9 Inf  13.985  <.0001
##  2 - 3       26.59 30.9 Inf   0.860  0.9559
##  2 - 4      -22.75 30.9 Inf  -0.735  0.9776
##  2 - 5       30.22 30.9 Inf   0.977  0.9254
##  2 - 6       91.14 30.9 Inf   2.946  0.0379
##  3 - 4      -49.34 30.9 Inf  -1.595  0.6019
##  3 - 5        3.63 30.9 Inf   0.117  1.0000
##  3 - 6       64.55 30.9 Inf   2.087  0.2942
##  4 - 5       52.97 30.9 Inf   1.712  0.5236
##  4 - 6      113.89 30.9 Inf   3.682  0.0032
##  5 - 6       60.92 30.9 Inf   1.969  0.3600
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 6 estimates
#Quick Plots position
emmip(m.MSL.position, Block ~ Position)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 37440' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 37440)' or larger];
## but be warned that this may result in large computation time and memory use.
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'lmerTest.limit = 37440' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 37440)' or larger];
## but be warned that this may result in large computation time and memory use.

#Effects and plots

#Barplot with accuracy per block (first model)
ae.m.MSL.ACCper <- allEffects(m.MSL.ACCper)
ae.m.df.ACCper <- as.data.frame(ae.m.MSL.ACCper[[1]])

ae.ACCper <- ggplot(ae.m.df.ACCper, aes(x = Block, y = fit, fill=Block)) +
  geom_bar(stat = "identity", colour = "black") +
  geom_errorbar(aes(ymin=lower, ymax=upper), width=.1) +
  ylab("Mean Accuracy (%)")+
  xlab("Block")+
  ggtitle("Accuracy (%) over training blocks") +
  theme_classic()

print (ae.ACCper)

##m.MSL.RTACCHand model
#Need Effects lib
ae.m.MSL.RTACC <- allEffects(m.MSL.RTACC)
ae.m.df.RTACC <- as.data.frame(ae.m.MSL.RTACC[[1]])

#The main plot.
ae.RTACC<-ggplot(ae.m.df.RTACC, aes(x=Block,y=fit, group=Trial.ACC))+
  geom_ribbon(aes(ymin=lower, ymax=upper, fill=Trial.ACC), alpha = 0.2) +
  geom_line(aes(color=Trial.ACC), size = 1) +
  geom_point(aes(color=Trial.ACC, shape=Trial.ACC), size = 3.5)+
  ylab("Mean Trial RT (ms)")+
  xlab("Block")+
  ggtitle("RT ~ Block * Accuracy interactions")
  theme_classic()
## List of 93
##  $ line                      :List of 6
##   ..$ colour       : chr "black"
##   ..$ size         : num 0.5
##   ..$ linetype     : num 1
##   ..$ lineend      : chr "butt"
##   ..$ arrow        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_line" "element"
##  $ rect                      :List of 5
##   ..$ fill         : chr "white"
##   ..$ colour       : chr "black"
##   ..$ size         : num 0.5
##   ..$ linetype     : num 1
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_rect" "element"
##  $ text                      :List of 11
##   ..$ family       : chr ""
##   ..$ face         : chr "plain"
##   ..$ colour       : chr "black"
##   ..$ size         : num 11
##   ..$ hjust        : num 0.5
##   ..$ vjust        : num 0.5
##   ..$ angle        : num 0
##   ..$ lineheight   : num 0.9
##   ..$ margin       : 'margin' num [1:4] 0points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ title                     : NULL
##  $ aspect.ratio              : NULL
##  $ axis.title                : NULL
##  $ axis.title.x              :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 1
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 2.75points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.x.top          :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 0
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 2.75points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.x.bottom       : NULL
##  $ axis.title.y              :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 1
##   ..$ angle        : num 90
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 2.75points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.title.y.left         : NULL
##  $ axis.title.y.right        :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 0
##   ..$ angle        : num -90
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 0points 2.75points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text                 :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : chr "grey30"
##   ..$ size         : 'rel' num 0.8
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x               :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 1
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 2.2points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x.top           :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : num 0
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 2.2points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.x.bottom        : NULL
##  $ axis.text.y               :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 1
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 2.2points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.text.y.left          : NULL
##  $ axis.text.y.right         :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 0
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 0points 2.2points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ axis.ticks                :List of 6
##   ..$ colour       : chr "grey20"
##   ..$ size         : NULL
##   ..$ linetype     : NULL
##   ..$ lineend      : NULL
##   ..$ arrow        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_line" "element"
##  $ axis.ticks.x              : NULL
##  $ axis.ticks.x.top          : NULL
##  $ axis.ticks.x.bottom       : NULL
##  $ axis.ticks.y              : NULL
##  $ axis.ticks.y.left         : NULL
##  $ axis.ticks.y.right        : NULL
##  $ axis.ticks.length         : 'simpleUnit' num 2.75points
##   ..- attr(*, "unit")= int 8
##  $ axis.ticks.length.x       : NULL
##  $ axis.ticks.length.x.top   : NULL
##  $ axis.ticks.length.x.bottom: NULL
##  $ axis.ticks.length.y       : NULL
##  $ axis.ticks.length.y.left  : NULL
##  $ axis.ticks.length.y.right : NULL
##  $ axis.line                 :List of 6
##   ..$ colour       : chr "black"
##   ..$ size         : 'rel' num 1
##   ..$ linetype     : NULL
##   ..$ lineend      : NULL
##   ..$ arrow        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_line" "element"
##  $ axis.line.x               : NULL
##  $ axis.line.x.top           : NULL
##  $ axis.line.x.bottom        : NULL
##  $ axis.line.y               : NULL
##  $ axis.line.y.left          : NULL
##  $ axis.line.y.right         : NULL
##  $ legend.background         :List of 5
##   ..$ fill         : NULL
##   ..$ colour       : logi NA
##   ..$ size         : NULL
##   ..$ linetype     : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_rect" "element"
##  $ legend.margin             : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
##   ..- attr(*, "unit")= int 8
##  $ legend.spacing            : 'simpleUnit' num 11points
##   ..- attr(*, "unit")= int 8
##  $ legend.spacing.x          : NULL
##  $ legend.spacing.y          : NULL
##  $ legend.key                : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ legend.key.size           : 'simpleUnit' num 1.2lines
##   ..- attr(*, "unit")= int 3
##  $ legend.key.height         : NULL
##  $ legend.key.width          : NULL
##  $ legend.text               :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : 'rel' num 0.8
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.text.align         : NULL
##  $ legend.title              :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 0
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ legend.title.align        : NULL
##  $ legend.position           : chr "right"
##  $ legend.direction          : NULL
##  $ legend.justification      : chr "center"
##  $ legend.box                : NULL
##  $ legend.box.just           : NULL
##  $ legend.box.margin         : 'margin' num [1:4] 0cm 0cm 0cm 0cm
##   ..- attr(*, "unit")= int 1
##  $ legend.box.background     : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ legend.box.spacing        : 'simpleUnit' num 11points
##   ..- attr(*, "unit")= int 8
##  $ panel.background          :List of 5
##   ..$ fill         : chr "white"
##   ..$ colour       : logi NA
##   ..$ size         : NULL
##   ..$ linetype     : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_rect" "element"
##  $ panel.border              : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ panel.spacing             : 'simpleUnit' num 5.5points
##   ..- attr(*, "unit")= int 8
##  $ panel.spacing.x           : NULL
##  $ panel.spacing.y           : NULL
##  $ panel.grid                :List of 6
##   ..$ colour       : chr "grey92"
##   ..$ size         : NULL
##   ..$ linetype     : NULL
##   ..$ lineend      : NULL
##   ..$ arrow        : logi FALSE
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_line" "element"
##  $ panel.grid.major          : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ panel.grid.minor          : list()
##   ..- attr(*, "class")= chr [1:2] "element_blank" "element"
##  $ panel.grid.major.x        : NULL
##  $ panel.grid.major.y        : NULL
##  $ panel.grid.minor.x        : NULL
##  $ panel.grid.minor.y        : NULL
##  $ panel.ontop               : logi FALSE
##  $ plot.background           :List of 5
##   ..$ fill         : NULL
##   ..$ colour       : chr "white"
##   ..$ size         : NULL
##   ..$ linetype     : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_rect" "element"
##  $ plot.title                :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : 'rel' num 1.2
##   ..$ hjust        : num 0
##   ..$ vjust        : num 1
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 5.5points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ plot.title.position       : chr "panel"
##  $ plot.subtitle             :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : num 0
##   ..$ vjust        : num 1
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 0points 0points 5.5points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ plot.caption              :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : 'rel' num 0.8
##   ..$ hjust        : num 1
##   ..$ vjust        : num 1
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 5.5points 0points 0points 0points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ plot.caption.position     : chr "panel"
##  $ plot.tag                  :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : 'rel' num 1.2
##   ..$ hjust        : num 0.5
##   ..$ vjust        : num 0.5
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ plot.tag.position         : chr "topleft"
##  $ plot.margin               : 'margin' num [1:4] 5.5points 5.5points 5.5points 5.5points
##   ..- attr(*, "unit")= int 8
##  $ strip.background          :List of 5
##   ..$ fill         : chr "white"
##   ..$ colour       : chr "black"
##   ..$ size         : 'rel' num 2
##   ..$ linetype     : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_rect" "element"
##  $ strip.background.x        : NULL
##  $ strip.background.y        : NULL
##  $ strip.placement           : chr "inside"
##  $ strip.text                :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : chr "grey10"
##   ..$ size         : 'rel' num 0.8
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : NULL
##   ..$ lineheight   : NULL
##   ..$ margin       : 'margin' num [1:4] 4.4points 4.4points 4.4points 4.4points
##   .. ..- attr(*, "unit")= int 8
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ strip.text.x              : NULL
##  $ strip.text.y              :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : num -90
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  $ strip.switch.pad.grid     : 'simpleUnit' num 2.75points
##   ..- attr(*, "unit")= int 8
##  $ strip.switch.pad.wrap     : 'simpleUnit' num 2.75points
##   ..- attr(*, "unit")= int 8
##  $ strip.text.y.left         :List of 11
##   ..$ family       : NULL
##   ..$ face         : NULL
##   ..$ colour       : NULL
##   ..$ size         : NULL
##   ..$ hjust        : NULL
##   ..$ vjust        : NULL
##   ..$ angle        : num 90
##   ..$ lineheight   : NULL
##   ..$ margin       : NULL
##   ..$ debug        : NULL
##   ..$ inherit.blank: logi TRUE
##   ..- attr(*, "class")= chr [1:2] "element_text" "element"
##  - attr(*, "class")= chr [1:2] "theme" "gg"
##  - attr(*, "complete")= logi TRUE
##  - attr(*, "validate")= logi TRUE
print (ae.RTACC)

##m.MSL.RTACCHand model
#Need Effects lib
ae.m.MSL.position<-allEffects(m.MSL.position)
ae.m.df.position<-as.data.frame(ae.m.MSL.position[[1]])

#The main polot.
ae.position<-ggplot(ae.m.df.position, aes(x=Position,y=fit, color=Block))+
  geom_ribbon(aes(ymin=lower, ymax=upper, fill=Block, group=Block), alpha=0.2) +
  #geom_errorbar(aes(ymin=lower, ymax=upper), width=.1) +
  geom_line(aes(group=Block), size = 1) +
  geom_point(aes(color=Block, shape=Block), size = 3.5) +
  ylab("Mean RT (ms)") +
  xlab("Key Position") +
  ggtitle("RT ~ Position * Block interactions")+
  theme_classic()

#Printing Session effects facet
print (ae.position)