TMS B&W_ JointAction

Giovanna Cuomo

2024-08-29

This script contains the analyses conducted on data related to participants who took part in our study “TMS B&W” for the Joint Action task

First, we load packages we need for analyses #PACKAGES

library (tidyverse) #for data handling
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
## ✔ ggplot2 3.4.0      ✔ purrr   0.3.5 
## ✔ tibble  3.1.8      ✔ dplyr   1.0.10
## ✔ tidyr   1.2.1      ✔ stringr 1.4.1 
## ✔ readr   2.1.3      ✔ forcats 0.5.2 
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(readxl) #to read excel files
library(writexl)  #to export data as excel file 
## Warning: il pacchetto 'writexl' è stato creato con R versione 4.2.3
library(lme4) 
## Caricamento del pacchetto richiesto: Matrix
## 
## Caricamento pacchetto: 'Matrix'
## 
## I seguenti oggetti sono mascherati da 'package:tidyr':
## 
##     expand, pack, unpack
library(emmeans) 
## Welcome to emmeans.
## Caution: You lose important information if you filter this package's results.
## See '? untidy'
library(ggplot2)
library(rstatix)
## Warning: il pacchetto 'rstatix' è stato creato con R versione 4.2.3
## 
## Caricamento pacchetto: 'rstatix'
## 
## Il seguente oggetto è mascherato da 'package:stats':
## 
##     filter
library(stats)
library(dplyr)
library(yarrr)
## Warning: il pacchetto 'yarrr' è stato creato con R versione 4.2.3
## Caricamento del pacchetto richiesto: jpeg
## Caricamento del pacchetto richiesto: BayesFactor
## Warning: il pacchetto 'BayesFactor' è stato creato con R versione 4.2.3
## Caricamento del pacchetto richiesto: coda
## ************
## Welcome to BayesFactor 0.9.12-4.4. If you have questions, please contact Richard Morey (richarddmorey@gmail.com).
## 
## Type BFManual() to open the manual.
## ************
## Caricamento del pacchetto richiesto: circlize
## Warning: il pacchetto 'circlize' è stato creato con R versione 4.2.3
## ========================================
## circlize version 0.4.15
## CRAN page: https://cran.r-project.org/package=circlize
## Github page: https://github.com/jokergoo/circlize
## Documentation: https://jokergoo.github.io/circlize_book/book/
## 
## If you use it in published research, please cite:
## Gu, Z. circlize implements and enhances circular visualization
##   in R. Bioinformatics 2014.
## 
## This message can be suppressed by:
##   suppressPackageStartupMessages(library(circlize))
## ========================================
## 
## yarrr v0.1.5. Citation info at citation('yarrr'). Package guide at yarrr.guide()
## Email me at Nathaniel.D.Phillips.is@gmail.com
## 
## Caricamento pacchetto: 'yarrr'
## 
## Il seguente oggetto è mascherato da 'package:ggplot2':
## 
##     diamonds
library(xlsx)
## Warning: il pacchetto 'xlsx' è stato creato con R versione 4.2.3
options(scipen=999)

##STUDIO 1 & 3

dati_tms = read.xlsx("dati_tms.xlsx", sheetIndex = 1)

Specifico i fattori

dati_tms$sito = as.factor(dati_tms$sito)
dati_tms$bw = as.factor(dati_tms$bw)
dati_tms$Movement = as.factor(dati_tms$Movement)
dati_tms$Grasp = as.factor(dati_tms$Grasp)
dati_tms$Subject = as.factor(dati_tms$Subject)

#Grasping Asynchrony

ASY_model = lmer(Asynchrony ~  Exp * bw * sito * Movement +
                            (1+ sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = dati_tms)
summary(ASY_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Asynchrony ~ Exp * bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: dati_tms
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 102650.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7291 -0.7364 -0.1646  0.5507  7.3289 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)          990.4   31.47                    
##           sitoVertex           304.5   17.45   -0.07            
##           bwWhite              317.9   17.83    0.01  0.31      
##           sitoVertex:bwWhite   476.4   21.83    0.09  0.06 -0.35
##  Residual                    12524.8  111.91                    
## Number of obs: 8356, groups:  Subject, 40
## 
## Fixed effects:
##                                           Estimate Std. Error t value
## (Intercept)                                169.541      9.648  17.573
## Exp3                                       -20.120     12.420  -1.620
## bwWhite                                     -4.599      9.017  -0.510
## sitoVertex                                 -13.803      8.938  -1.544
## MovementImitative                          -14.893      7.778  -1.915
## Exp3:bwWhite                                 1.815     11.601   0.156
## Exp3:sitoVertex                             11.244     11.568   0.972
## bwWhite:sitoVertex                           7.650     12.284   0.623
## Exp3:MovementImitative                       2.804     10.023   0.280
## bwWhite:MovementImitative                   -2.507     11.005  -0.228
## sitoVertex:MovementImitative                -3.650     10.926  -0.334
## Exp3:bwWhite:sitoVertex                      5.431     15.871   0.342
## Exp3:bwWhite:MovementImitative               5.742     14.170   0.405
## Exp3:sitoVertex:MovementImitative            8.799     14.179   0.621
## bwWhite:sitoVertex:MovementImitative         1.259     15.491   0.081
## Exp3:bwWhite:sitoVertex:MovementImitative   -3.908     20.004  -0.195
## 
## Correlation matrix not shown by default, as p = 16 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
isSingular(ASY_model)
## [1] FALSE
Anova(ASY_model)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: Asynchrony
##                        Chisq Df   Pr(>Chisq)    
## Exp                   1.7769  1      0.18253    
## bw                    0.1392  1      0.70911    
## sito                  0.5381  1      0.46320    
## Movement             24.8172  1 0.0000006303 ***
## Exp:bw                0.6884  1      0.40670    
## Exp:sito              4.2156  1      0.04005 *  
## bw:sito               2.9614  1      0.08528 .  
## Exp:Movement          3.3220  1      0.06836 .  
## bw:Movement           0.0067  1      0.93494    
## sito:Movement         0.0475  1      0.82747    
## Exp:bw:sito           0.0797  1      0.77767    
## Exp:bw:Movement       0.1429  1      0.70546    
## Exp:sito:Movement     0.4671  1      0.49434    
## bw:sito:Movement      0.0122  1      0.91189    
## Exp:bw:sito:Movement  0.0382  1      0.84510    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(ASY_model)
plot(density(res))

plot(ASY_model)

qqnorm(residuals(ASY_model))
qqline(residuals(ASY_model))

Svolgo i posthoc delle interazioni significative o quasi

#emmeans/posthoc
emmeans_interaction <- emmeans(ASY_model, ~ Exp * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 8356' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 8356)' 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 = 8356' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 8356)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(ASY_model, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 8356' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 8356)' 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 = 8356' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 8356)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(ASY_model, ~ Movement * Exp)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 8356' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 8356)' 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 = 8356' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 8356)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                  estimate    SE  df z.ratio p.value
##  Exp1 MPFC - Exp3 MPFC        16.37 11.17 Inf   1.467  0.8549
##  Exp1 MPFC - Exp1 Vertex      11.49  6.56 Inf   1.752  0.4783
##  Exp1 MPFC - Exp3 Vertex      10.48 12.00 Inf   0.873  1.0000
##  Exp3 MPFC - Exp1 Vertex      -4.89 12.38 Inf  -0.395  1.0000
##  Exp3 MPFC - Exp3 Vertex      -5.89  5.36 Inf  -1.099  1.0000
##  Exp1 Vertex - Exp3 Vertex    -1.01 13.14 Inf  -0.077  1.0000
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black MPFC - White MPFC         3.51 4.57 Inf   0.769  1.0000
##  Black MPFC - Black Vertex       7.81 4.54 Inf   1.720  0.5127
##  Black MPFC - White Vertex       1.30 6.35 Inf   0.204  1.0000
##  White MPFC - Black Vertex       4.30 4.88 Inf   0.881  1.0000
##  White MPFC - White Vertex      -2.21 5.84 Inf  -0.379  1.0000
##  Black Vertex - White Vertex    -6.51 5.12 Inf  -1.271  1.0000
## 
## Results are averaged over the levels of: Exp, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                estimate    SE  df z.ratio p.value
##  Complementary Exp1 - Imitative Exp1        17.66  3.87 Inf   4.559  <.0001
##  Complementary Exp1 - Complementary Exp3    12.23 11.71 Inf   1.045  1.0000
##  Complementary Exp1 - Imitative Exp3        20.79 11.71 Inf   1.776  0.4545
##  Imitative Exp1 - Complementary Exp3        -5.42 11.70 Inf  -0.463  1.0000
##  Imitative Exp1 - Imitative Exp3             3.14 11.70 Inf   0.268  1.0000
##  Complementary Exp3 - Imitative Exp3         8.56  3.16 Inf   2.705  0.0410
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests

plotto i dati completi

pirateplot(formula = Asynchrony ~ bw + sito + Exp, #dependent variable ~ independent
           data = dati_tms,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "",#titles for x and y axes
)

plotto solo il main effect di Movement

pirateplot(formula = Asynchrony ~ Movement, #dependent variable ~ independent
           data = dati_tms,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "",#titles for x and y axes
)

##Alternativa

medie_TMS_BW = dati_tms%>%
  group_by(Subject, sito, bw, Movement, Exp)%>%
  summarise(Asynchrony = mean(Asynchrony, na.rm=T), MovTime = mean(MovTime, na.rm=T), Start = mean(Start, na.rm = T)) # factors means
## `summarise()` has grouped output by 'Subject', 'sito', 'bw', 'Movement'. You
## can override using the `.groups` argument.
media_ds = medie_TMS_BW %>%
  group_by(Subject)%>%
  summarise(media = mean(Asynchrony),
            devst = sd(Asynchrony))

medie_TMS_BW_2 = merge(medie_TMS_BW, media_ds, all=T)

medie_TMS_BW_2 = medie_TMS_BW_2 %>%
  mutate(Asy_z = (Asynchrony - media)/devst)

check_z = medie_TMS_BW_2 %>%
  group_by(bw, sito, Movement) %>%
  shapiro_test(Asy_z)

view(check_z)

runno LMM con punteggi z

ASY_model2 = lmer(Asy_z ~  Exp * bw * sito * Movement +
                            (1|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = medie_TMS_BW_2)
## boundary (singular) fit: see help('isSingular')
summary(ASY_model2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Asy_z ~ Exp * bw * sito * Movement + (1 | Subject)
##    Data: medie_TMS_BW_2
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 845
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.34931 -0.71981 -0.05213  0.65433  2.49708 
## 
## Random effects:
##  Groups   Name        Variance                             
##  Subject  (Intercept) 0.00000000000000000000000000000009078
##  Residual             0.82102512640444746949697218951769173
##  Std.Dev.             
##  0.0000000000000003013
##  0.9061043683839337115
## Number of obs: 318, groups:  Subject, 40
## 
## Fixed effects:
##                                           Estimate Std. Error t value
## (Intercept)                                0.69819    0.22653   3.082
## Exp3                                      -0.50367    0.29244  -1.722
## bwWhite                                   -0.38170    0.32036  -1.191
## sitoVertex                                -0.70643    0.32036  -2.205
## MovementImitative                         -0.56265    0.32036  -1.756
## Exp3:bwWhite                               0.16080    0.41358   0.389
## Exp3:sitoVertex                            0.71164    0.41537   1.713
## bwWhite:sitoVertex                         0.54256    0.45305   1.198
## Exp3:MovementImitative                     0.05984    0.41358   0.145
## bwWhite:MovementImitative                 -0.08985    0.45305  -0.198
## sitoVertex:MovementImitative               0.00526    0.45305   0.012
## Exp3:bwWhite:sitoVertex                   -0.12493    0.58616  -0.213
## Exp3:bwWhite:MovementImitative             0.38272    0.58489   0.654
## Exp3:sitoVertex:MovementImitative          0.05657    0.58742   0.096
## bwWhite:sitoVertex:MovementImitative       0.10161    0.64071   0.159
## Exp3:bwWhite:sitoVertex:MovementImitative -0.33023    0.82895  -0.398
## 
## Correlation matrix not shown by default, as p = 16 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
isSingular(ASY_model2)
## [1] TRUE
Anova(ASY_model2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: Asy_z
##                        Chisq Df  Pr(>Chisq)    
## Exp                   0.0002  1    0.989532    
## bw                    0.0050  1    0.943789    
## sito                  0.2491  1    0.617680    
## Movement             20.6242  1 0.000005589 ***
## Exp:bw                1.0051  1    0.316081    
## Exp:sito              8.2233  1    0.004136 ** 
## bw:sito               4.2711  1    0.038765 *  
## Exp:Movement          0.9062  1    0.341127    
## bw:Movement           0.2035  1    0.651924    
## sito:Movement         0.0022  1    0.962637    
## Exp:bw:sito           0.4897  1    0.484059    
## Exp:bw:Movement       0.2774  1    0.598382    
## Exp:sito:Movement     0.0695  1    0.792076    
## bw:sito:Movement      0.0554  1    0.813938    
## Exp:bw:sito:Movement  0.1587  1    0.690354    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(ASY_model2)
plot(density(res))

plot(ASY_model2)

qqnorm(residuals(ASY_model2))
qqline(residuals(ASY_model2))

#Movement Time

MT_model = lmer(MovTime ~  Exp * bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = dati_tms)
summary(MT_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: MovTime ~ Exp * bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: dati_tms
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 112493.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0744 -0.6967 -0.0999  0.6334  5.6873 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)        14791    121.62                    
##           sitoVertex          6987     83.59   -0.44            
##           bwWhite             2820     53.10   -0.13  0.59      
##           sitoVertex:bwWhite  7247     85.13    0.41 -0.66 -0.71
##  Residual                    36526    191.12                    
## Number of obs: 8415, groups:  Subject, 40
## 
## Fixed effects:
##                                            Estimate Std. Error t value
## (Intercept)                               1281.4345    31.8410  40.245
## Exp3                                       -69.6006    41.0854  -1.694
## bwWhite                                    -19.7585    18.7861  -1.052
## sitoVertex                                  -4.2750    24.7532  -0.173
## MovementImitative                          -23.7644    13.2235  -1.797
## Exp3:bwWhite                                28.5220    24.2157   1.178
## Exp3:sitoVertex                              0.3497    32.0491   0.011
## bwWhite:sitoVertex                          37.8366    28.3325   1.335
## Exp3:MovementImitative                       8.2832    17.0579   0.486
## bwWhite:MovementImitative                    6.3111    18.6848   0.338
## sitoVertex:MovementImitative                14.3453    18.5935   0.772
## Exp3:bwWhite:sitoVertex                    -44.5937    36.6565  -1.217
## Exp3:bwWhite:MovementImitative               1.9502    24.0864   0.081
## Exp3:sitoVertex:MovementImitative           -6.1128    24.1637  -0.253
## bwWhite:sitoVertex:MovementImitative        -8.6684    26.3108  -0.329
## Exp3:bwWhite:sitoVertex:MovementImitative   -0.7008    34.0238  -0.021
## 
## Correlation matrix not shown by default, as p = 16 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
isSingular(MT_model)
## [1] FALSE
Anova(MT_model)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: MovTime
##                       Chisq Df Pr(>Chisq)   
## Exp                  3.3224  1   0.068341 . 
## bw                   0.3259  1   0.568096   
## sito                 0.2354  1   0.627531   
## Movement             8.2647  1   0.004042 **
## Exp:bw               0.3626  1   0.547069   
## Exp:sito             1.8662  1   0.171910   
## bw:sito              0.1763  1   0.674577   
## Exp:Movement         0.5018  1   0.478726   
## bw:Movement          0.1241  1   0.724625   
## sito:Movement        0.5317  1   0.465878   
## Exp:bw:sito          1.9240  1   0.165418   
## Exp:bw:Movement      0.0088  1   0.925112   
## Exp:sito:Movement    0.1445  1   0.703851   
## bw:sito:Movement     0.2968  1   0.585925   
## Exp:bw:sito:Movement 0.0004  1   0.983567   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(MT_model)
plot(density(res))

plot(MT_model)

qqnorm(residuals(MT_model))
qqline(residuals(MT_model))

Non ci sono post-hoc da svolgere, quindi plotto i dati completi

pirateplot(formula = MovTime ~ bw + sito + Movement, #dependent variable ~ independent
           data = dati_tms,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "",#titles for x and y axes
)

plotto i dati del main effect

pirateplot(formula = MovTime ~ Movement, #dependent variable ~ independent
           data = dati_tms,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "",#titles for x and y axes
)

Calcolo medie e ds

library(dplyr)

summary_stats <- dati_tms %>%
  group_by(Movement) %>%
  summarise(
    mean_MovTime = mean(MovTime, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(MovTime, na.rm = TRUE)           # Calcola la deviazione standard
  )

#Start - RT

RT_model = lmer(Start ~  Exp * bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = dati_tms)
summary(RT_model)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Start ~ Exp * bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: dati_tms
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 103746
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6279 -0.6037 -0.0732  0.5382  5.1626 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)        10971    104.74                    
##           sitoVertex          6497     80.60   -0.35            
##           bwWhite             2913     53.97   -0.25  0.48      
##           sitoVertex:bwWhite  5080     71.27    0.03 -0.40 -0.57
##  Residual                    14541    120.58                    
## Number of obs: 8324, groups:  Subject, 40
## 
## Fixed effects:
##                                           Estimate Std. Error t value
## (Intercept)                               395.3584    26.8647  14.717
## Exp3                                       -5.4322    34.6725  -0.157
## bwWhite                                   -24.4025    15.9225  -1.533
## sitoVertex                                 -6.5585    21.8341  -0.300
## MovementImitative                         -12.5495     8.3804  -1.497
## Exp3:bwWhite                                0.2307    20.5363   0.011
## Exp3:sitoVertex                            -3.3633    28.2844  -0.119
## bwWhite:sitoVertex                        -17.8724    21.4117  -0.835
## Exp3:MovementImitative                     16.9921    10.8140   1.571
## bwWhite:MovementImitative                  14.8005    11.8656   1.247
## sitoVertex:MovementImitative               -3.7189    11.7818  -0.316
## Exp3:bwWhite:sitoVertex                    38.7627    27.7364   1.398
## Exp3:bwWhite:MovementImitative            -18.7756    15.2894  -1.228
## Exp3:sitoVertex:MovementImitative           8.8443    15.3182   0.577
## bwWhite:sitoVertex:MovementImitative        2.7282    16.6904   0.163
## Exp3:bwWhite:sitoVertex:MovementImitative  -6.8240    21.5863  -0.316
## 
## Correlation matrix not shown by default, as p = 16 > 12.
## Use print(x, correlation=TRUE)  or
##     vcov(x)        if you need it
isSingular(RT_model)
## [1] FALSE
Anova(RT_model)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: Start
##                       Chisq Df Pr(>Chisq)   
## Exp                  0.1131  1   0.736630   
## bw                   7.3784  1   0.006601 **
## sito                 0.2118  1   0.645338   
## Movement             0.0075  1   0.930968   
## Exp:bw               0.1641  1   0.685370   
## Exp:sito             0.5092  1   0.475499   
## bw:sito              0.1305  1   0.717898   
## Exp:Movement         3.5998  1   0.057786 . 
## bw:Movement          0.3036  1   0.581622   
## sito:Movement        0.0266  1   0.870349   
## Exp:bw:sito          1.9170  1   0.166191   
## Exp:bw:Movement      4.2304  1   0.039707 * 
## Exp:sito:Movement    0.2511  1   0.616320   
## bw:sito:Movement     0.0163  1   0.898407   
## Exp:bw:sito:Movement 0.0999  1   0.751908   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(RT_model)
plot(density(res))

plot(RT_model)

qqnorm(residuals(RT_model))
qqline(residuals(RT_model))

Svolgo i posthoc per le interazioni significative o quasi

#emmeans/posthoc
emmeans_interaction1 <- emmeans(RT_model, ~ Exp * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 8324' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 8324)' 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 = 8324' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 8324)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(RT_model, ~ Movement * Exp * bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 8324' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 8324)' 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 = 8324' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 8324)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")

summary(posthoc_interaction1)
##  contrast                                estimate    SE  df z.ratio p.value
##  Exp1 Complementary - Exp3 Complementary    -2.69 31.48 Inf  -0.086  1.0000
##  Exp1 Complementary - Exp1 Imitative         6.33  4.17 Inf   1.516  0.7767
##  Exp1 Complementary - Exp3 Imitative        -6.69 31.47 Inf  -0.212  1.0000
##  Exp3 Complementary - Exp1 Imitative         9.02 31.47 Inf   0.287  1.0000
##  Exp3 Complementary - Exp3 Imitative        -3.99  3.42 Inf  -1.167  1.0000
##  Exp1 Imitative - Exp3 Imitative           -13.01 31.47 Inf  -0.413  1.0000
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                            estimate    SE  df z.ratio
##  Complementary Exp1 Black - Imitative Exp1 Black       14.409  5.89 Inf   2.446
##  Complementary Exp1 Black - Complementary Exp3 Black    7.114 32.21 Inf   0.221
##  Complementary Exp1 Black - Imitative Exp3 Black        0.109 32.21 Inf   0.003
##  Complementary Exp1 Black - Complementary Exp1 White   33.339 12.68 Inf   2.629
##  Complementary Exp1 Black - Imitative Exp1 White       31.583 12.67 Inf   2.492
##  Complementary Exp1 Black - Complementary Exp3 White   20.840 32.45 Inf   0.642
##  Complementary Exp1 Black - Imitative Exp3 White       19.858 32.45 Inf   0.612
##  Imitative Exp1 Black - Complementary Exp3 Black       -7.295 32.20 Inf  -0.227
##  Imitative Exp1 Black - Imitative Exp3 Black          -14.300 32.20 Inf  -0.444
##  Imitative Exp1 Black - Complementary Exp1 White       18.930 12.66 Inf   1.496
##  Imitative Exp1 Black - Imitative Exp1 White           17.174 12.65 Inf   1.358
##  Imitative Exp1 Black - Complementary Exp3 White        6.431 32.44 Inf   0.198
##  Imitative Exp1 Black - Imitative Exp3 White            5.449 32.44 Inf   0.168
##  Complementary Exp3 Black - Imitative Exp3 Black       -7.005  4.89 Inf  -1.431
##  Complementary Exp3 Black - Complementary Exp1 White   26.225 32.60 Inf   0.804
##  Complementary Exp3 Black - Imitative Exp1 White       24.469 32.60 Inf   0.751
##  Complementary Exp3 Black - Complementary Exp3 White   13.727 10.42 Inf   1.318
##  Complementary Exp3 Black - Imitative Exp3 White       12.744 10.41 Inf   1.224
##  Imitative Exp3 Black - Complementary Exp1 White       33.230 32.60 Inf   1.019
##  Imitative Exp3 Black - Imitative Exp1 White           31.475 32.60 Inf   0.965
##  Imitative Exp3 Black - Complementary Exp3 White       20.732 10.41 Inf   1.991
##  Imitative Exp3 Black - Imitative Exp3 White           19.750 10.41 Inf   1.898
##  Complementary Exp1 White - Imitative Exp1 White       -1.756  5.91 Inf  -0.297
##  Complementary Exp1 White - Complementary Exp3 White  -12.498 32.84 Inf  -0.381
##  Complementary Exp1 White - Imitative Exp3 White      -13.480 32.84 Inf  -0.411
##  Imitative Exp1 White - Complementary Exp3 White      -10.743 32.84 Inf  -0.327
##  Imitative Exp1 White - Imitative Exp3 White          -11.725 32.83 Inf  -0.357
##  Complementary Exp3 White - Imitative Exp3 White       -0.982  4.78 Inf  -0.205
##  p.value
##   0.4045
##   1.0000
##   1.0000
##   0.2396
##   0.3553
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 28 tests

Calcolo medie e ds

summary_statsRT <- dati_tms %>%
  group_by(bw) %>%
  summarise(
    mean_MovTime = mean(Start, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(Start, na.rm = TRUE)           # Calcola la deviazione standard
  )

plotto i dati completi

pirateplot(formula = Start ~ bw + sito + Movement, #dependent variable ~ independent
           data = dati_tms,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Times", xlab = "",#titles for x and y axes
)

plotto il main effect significativo

pirateplot(formula = Start ~ bw , #dependent variable ~ independent
           data = dati_tms,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Times", xlab = "",#titles for x and y axes
)

##TUTTI gli STUDI

dataset_2 = read.xlsx("dataset_2.xlsx", sheetIndex = 1)

Specifico i fattori

dataset_2$sito = as.factor(dataset_2$sito)
dataset_2$bw = as.factor(dataset_2$bw)
dataset_2$Movement = as.factor(dataset_2$Movement)
dataset_2$Grasp = as.factor(dataset_2$Grasp)
dataset_2$Subject = as.factor(dataset_2$Subject)

#Grasping Asynchrony

ASY_model_3studi = lmer (Asynchrony ~  Exp + bw * sito * Movement +
                               (1+bw+sito|Subject), control = lmerControl(optimizer = "bobyqa"),
                             data = dataset_2)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, : Model is nearly unidentifiable: large eigenvalue ratio
##  - Rescale variables?
#summary(ASY_model_3studi)
isSingular(ASY_model_3studi)
## [1] FALSE
anova(ASY_model_3studi)
## Analysis of Variance Table
##                  npar Sum Sq Mean Sq F value
## Exp                 2  35419   17709  1.3942
## bw                  1    274     274  0.0216
## sito                2  10412    5206  0.4099
## Movement            1 587096  587096 46.2205
## bw:sito             2  29297   14649  1.1532
## bw:Movement         1   4164    4164  0.3278
## sito:Movement       2   9642    4821  0.3795
## bw:sito:Movement    2   3905    1952  0.1537

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(ASY_model_3studi, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11516' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11516)' 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 = 11516' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11516)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(ASY_model_3studi, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11516' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11516)' 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 = 11516' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11516)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(ASY_model_3studi, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11516' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11516)' 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 = 11516' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11516)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(ASY_model_3studi, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11516' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11516)' 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 = 11516' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11516)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(ASY_model_3studi, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11516' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11516)' 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 = 11516' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11516)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(ASY_model_3studi, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11516' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11516)' 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 = 11516' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11516)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate    SE  df z.ratio p.value
##  Black MPFC - White MPFC         4.45  4.14 Inf   1.074  1.0000
##  Black MPFC - Black Vertex       5.47  4.88 Inf   1.120  1.0000
##  Black MPFC - White Vertex       2.96  5.73 Inf   0.516  1.0000
##  Black MPFC - Black VPM         -6.46 13.53 Inf  -0.477  1.0000
##  Black MPFC - White VPM         -4.65 13.82 Inf  -0.337  1.0000
##  White MPFC - Black Vertex       1.02  4.57 Inf   0.223  1.0000
##  White MPFC - White Vertex      -1.49  4.71 Inf  -0.316  1.0000
##  White MPFC - Black VPM        -10.91 13.31 Inf  -0.820  1.0000
##  White MPFC - White VPM         -9.10 13.51 Inf  -0.673  1.0000
##  Black Vertex - White Vertex    -2.51  3.59 Inf  -0.699  1.0000
##  Black Vertex - Black VPM      -11.93 12.69 Inf  -0.940  1.0000
##  Black Vertex - White VPM      -10.12 13.04 Inf  -0.776  1.0000
##  White Vertex - Black VPM       -9.42 12.77 Inf  -0.737  1.0000
##  White Vertex - White VPM       -7.61 12.82 Inf  -0.594  1.0000
##  Black VPM - White VPM           1.81  6.58 Inf   0.275  1.0000
## 
## Results are averaged over the levels of: Exp, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 15 tests
summary(posthoc_interaction1)
##  contrast                                  estimate   SE  df z.ratio p.value
##  Black Complementary - White Complementary    1.885 4.01 Inf   0.470  1.0000
##  Black Complementary - Black Imitative       15.816 3.43 Inf   4.607  <.0001
##  Black Complementary - White Imitative       16.430 4.00 Inf   4.104  0.0002
##  White Complementary - Black Imitative       13.931 4.01 Inf   3.471  0.0031
##  White Complementary - White Imitative       14.545 3.44 Inf   4.228  0.0001
##  Black Imitative - White Imitative            0.614 4.00 Inf   0.153  1.0000
## 
## Results are averaged over the levels of: Exp, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Complementary MPFC - Imitative MPFC          12.72  3.49 Inf   3.645  0.0040
##  Complementary MPFC - Complementary Vertex     1.21  4.77 Inf   0.253  1.0000
##  Complementary MPFC - Imitative Vertex        15.49  4.77 Inf   3.251  0.0173
##  Complementary MPFC - Complementary VPM      -10.69 13.40 Inf  -0.798  1.0000
##  Complementary MPFC - Imitative VPM            7.85 13.40 Inf   0.586  1.0000
##  Imitative MPFC - Complementary Vertex       -11.51  4.76 Inf  -2.419  0.2337
##  Imitative MPFC - Imitative Vertex             2.77  4.75 Inf   0.582  1.0000
##  Imitative MPFC - Complementary VPM          -23.41 13.40 Inf  -1.748  1.0000
##  Imitative MPFC - Imitative VPM               -4.87 13.39 Inf  -0.364  1.0000
##  Complementary Vertex - Imitative Vertex      14.28  2.97 Inf   4.807  <.0001
##  Complementary Vertex - Complementary VPM    -11.90 12.68 Inf  -0.938  1.0000
##  Complementary Vertex - Imitative VPM          6.64 12.68 Inf   0.524  1.0000
##  Imitative Vertex - Complementary VPM        -26.18 12.68 Inf  -2.064  0.5850
##  Imitative Vertex - Imitative VPM             -7.64 12.68 Inf  -0.603  1.0000
##  Complementary VPM - Imitative VPM            18.54  5.67 Inf   3.270  0.0161
## 
## Results are averaged over the levels of: Exp, bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 15 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  MPFC effect      -1.93 4.96 Inf  -0.390  1.0000
##  Vertex effect    -3.92 4.32 Inf  -0.908  1.0000
##  VPM effect        5.85 8.30 Inf   0.705  1.0000
## 
## Results are averaged over the levels of: Exp, bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 3 tests
summary(posthoc_bw)
##  contrast     estimate   SE  df z.ratio p.value
##  Black effect    0.625 1.59 Inf   0.392  1.0000
##  White effect   -0.625 1.59 Inf  -0.392  1.0000
## 
## Results are averaged over the levels of: Exp, sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate   SE  df z.ratio p.value
##  Complementary effect     7.59 1.22 Inf   6.247  <.0001
##  Imitative effect        -7.59 1.22 Inf  -6.247  <.0001
## 
## Results are averaged over the levels of: Exp, bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = Asynchrony ~ bw + sito + Movement, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "",#titles for x and y axes
)

#Movement Time

MT_model_3studi = lmer(MovTime ~  Exp * bw * Movement +
                            (1+bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = dataset_2)
#summary(MT_model_3studi)
isSingular(MT_model_3studi)
## [1] FALSE
Anova(MT_model_3studi)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: MovTime
##                  Chisq Df Pr(>Chisq)  
## Exp             8.1235  2    0.01722 *
## bw              0.1436  1    0.70470  
## Movement        5.3885  1    0.02027 *
## Exp:bw          0.5771  2    0.74936  
## Exp:Movement    3.1673  2    0.20522  
## bw:Movement     0.1746  1    0.67608  
## Exp:bw:Movement 0.0105  2    0.99476  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(MT_model_3studi)
plot(density(res))

plot(MT_model_3studi)

qqnorm(residuals(MT_model_3studi))
qqline(residuals(MT_model_3studi))

Calcolo medie e ds

summary_statsMT_Exp <- dataset_2 %>%
  group_by(Exp) %>%
  summarise(
    mean_MovTime = mean(MovTime, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(MovTime, na.rm = TRUE)           # Calcola la deviazione standard
  )

summary_statsMT <- dataset_2 %>%
  group_by(Movement) %>%
  summarise(
    mean_MovTime = mean(MovTime, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(MovTime, na.rm = TRUE)           # Calcola la deviazione standard
  )

Svolgo i posthoc

#emmeans/posthoc
emmeans_Experiment <- emmeans(MT_model_3studi, ~ Exp)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11575' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11575)' 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 = 11575' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11575)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_Experiment <- contrast(emmeans_Experiment, adjust = "bonferroni")

summary(posthoc_Experiment)
##  contrast    estimate   SE  df z.ratio p.value
##  Exp1 effect      9.6 24.6 Inf   0.389  1.0000
##  Exp2 effect     44.6 25.1 Inf   1.778  0.2263
##  Exp3 effect    -54.2 22.4 Inf  -2.419  0.0467
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 3 tests

plotto i dati dei main effect

pirateplot(formula = MovTime ~ Movement, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "",#titles for x and y axes
)

pirateplot(formula = MovTime ~ Exp, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "",#titles for x and y axes
)

#Start - RT

RT_model_3studi = lmer(Start ~  Exp * bw * Movement +
                            (1+bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = dataset_2)
#summary(RT_model_3studi)
isSingular(RT_model_3studi)
## [1] FALSE
Anova(RT_model_3studi)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: Start
##                   Chisq Df Pr(>Chisq)   
## Exp             12.9470  2   0.001544 **
## bw               7.2134  1   0.007236 **
## Movement         3.8781  1   0.048919 * 
## Exp:bw           2.5901  2   0.273891   
## Exp:Movement    13.0285  2   0.001482 **
## bw:Movement      0.0809  1   0.776099   
## Exp:bw:Movement  4.2210  2   0.121176   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(RT_model_3studi)
plot(density(res))

plot(RT_model_3studi)

qqnorm(residuals(RT_model_3studi))
qqline(residuals(RT_model_3studi))

Svolgo i posthoc

#emmeans/posthoc
RT_emmeans_interaction <- emmeans(RT_model_3studi, ~ Exp * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11438' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11438)' 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 = 11438' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11438)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
RT_emmeans_Experiment <- emmeans(MT_model_3studi, ~ Exp)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 11575' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 11575)' 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 = 11575' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 11575)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(RT_emmeans_interaction, adjust = "bonferroni")
posthoc_Experiment <- contrast(RT_emmeans_Experiment, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                                estimate    SE  df z.ratio p.value
##  Exp1 Complementary - Exp2 Complementary    90.34 33.90 Inf   2.664  0.1157
##  Exp1 Complementary - Exp3 Complementary    -2.67 30.45 Inf  -0.088  1.0000
##  Exp1 Complementary - Exp1 Imitative         6.39  4.24 Inf   1.506  1.0000
##  Exp1 Complementary - Exp2 Imitative       106.42 33.90 Inf   3.139  0.0254
##  Exp1 Complementary - Exp3 Imitative        -6.71 30.45 Inf  -0.220  1.0000
##  Exp2 Complementary - Exp3 Complementary   -93.01 31.05 Inf  -2.995  0.0411
##  Exp2 Complementary - Exp1 Imitative       -83.94 33.90 Inf  -2.476  0.1992
##  Exp2 Complementary - Exp2 Imitative        16.08  4.40 Inf   3.655  0.0039
##  Exp2 Complementary - Exp3 Imitative       -97.05 31.05 Inf  -3.126  0.0266
##  Exp3 Complementary - Exp1 Imitative         9.06 30.44 Inf   0.298  1.0000
##  Exp3 Complementary - Exp2 Imitative       109.09 31.05 Inf   3.514  0.0066
##  Exp3 Complementary - Exp3 Imitative        -4.04  3.48 Inf  -1.161  1.0000
##  Exp1 Imitative - Exp2 Imitative           100.03 33.90 Inf   2.951  0.0476
##  Exp1 Imitative - Exp3 Imitative           -13.11 30.44 Inf  -0.431  1.0000
##  Exp2 Imitative - Exp3 Imitative          -113.13 31.05 Inf  -3.644  0.0040
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 15 tests
summary(posthoc_Experiment)
##  contrast    estimate   SE  df z.ratio p.value
##  Exp1 effect      9.6 24.6 Inf   0.389  1.0000
##  Exp2 effect     44.6 25.1 Inf   1.778  0.2263
##  Exp3 effect    -54.2 22.4 Inf  -2.419  0.0467
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 3 tests

Calcolo medie e ds

statsRT_Exp <- dataset_2 %>%
  group_by(Exp) %>%
  summarise(
    mean_MovTime = mean(Start, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(Start, na.rm = TRUE)           # Calcola la deviazione standard
  )

statsRT_Mov <- dataset_2 %>%
  group_by(Movement) %>%
  summarise(
    mean_MovTime = mean(Start, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(Start, na.rm = TRUE)           # Calcola la deviazione standard
  )

statsRT_bw <- dataset_2 %>%
  group_by(bw) %>%
  summarise(
    mean_MovTime = mean(Start, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(Start, na.rm = TRUE)           # Calcola la deviazione standard
  )

statsRT_interaction <- dataset_2 %>%
  group_by(Exp, Movement) %>%
  summarise(
    mean_MovTime = mean(Start, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(Start, na.rm = TRUE)           # Calcola la deviazione standard
  )
## `summarise()` has grouped output by 'Exp'. You can override using the `.groups`
## argument.

plotto i dati dei significant effects

pirateplot(formula = Start ~ Movement, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Times", xlab = "",#titles for x and y axes
)

pirateplot(formula = Start ~ Exp, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Times", xlab = "",#titles for x and y axes
)

pirateplot(formula = Start ~ bw, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Times", xlab = "",#titles for x and y axes
)

pirateplot(formula = Start ~ Exp + Movement, #dependent variable ~ independent
           data = dataset_2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Times", xlab = "",#titles for x and y axes
)

##STUDIO 1

EXP1 = read.xlsx("dati_tms_EXP1.xlsx", sheetIndex = 1)

Specifico i fattori

EXP1$sito = as.factor(EXP1$sito)
EXP1$bw = as.factor(EXP1$bw)
EXP1$Grasp= as.factor(EXP1$Grasp)
EXP1$Movement = as.factor(EXP1$Movement)
EXP1$Subject = as.factor (EXP1$Subject)

#Grasping Asynchrony

ASY_EXP1 = lmer (Asynchrony ~  bw * sito * Movement +
                               (1+bw+sito|Subject), control = lmerControl(optimizer = "bobyqa"),
                             data = EXP1)
isSingular(ASY_EXP1)
## [1] FALSE
summary(ASY_EXP1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Asynchrony ~ bw * sito * Movement + (1 + bw + sito | Subject)
##    Data: EXP1
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 41534.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0542 -0.7233 -0.1689  0.5170  6.8739 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr       
##  Subject  (Intercept)  1183.8   34.41              
##           bwWhite       187.1   13.68    0.17      
##           sitoVertex    401.3   20.03   -0.46  0.11
##  Residual             14464.6  120.27              
## Number of obs: 3344, groups:  Subject, 16
## 
## Fixed effects:
##                                      Estimate Std. Error t value
## (Intercept)                           169.624     10.487  16.174
## bwWhite                                -4.722      9.090  -0.520
## sitoVertex                            -13.919      9.765  -1.425
## MovementImitative                     -14.917      8.358  -1.785
## bwWhite:sitoVertex                      7.722     11.825   0.653
## bwWhite:MovementImitative              -2.448     11.826  -0.207
## sitoVertex:MovementImitative           -3.614     11.741  -0.308
## bwWhite:sitoVertex:MovementImitative    1.383     16.647   0.083
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit stVrtx MvmntI bwWh:V bwW:MI stV:MI
## bwWhite     -0.326                                          
## sitoVertex  -0.545  0.426                                   
## MovmntImttv -0.410  0.473  0.441                            
## bwWht:stVrt  0.290 -0.660 -0.608 -0.364                     
## bwWht:MvmnI  0.290 -0.660 -0.311 -0.707  0.507              
## stVrtx:MvmI  0.292 -0.337 -0.613 -0.712  0.506  0.503       
## bwWht:sV:MI -0.206  0.469  0.432  0.502 -0.710 -0.710 -0.705

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(ASY_EXP1, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3344' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3344)' 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 = 3344' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3344)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(ASY_EXP1, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3344' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3344)' 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 = 3344' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3344)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(ASY_EXP1, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3344' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3344)' 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 = 3344' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3344)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(ASY_EXP1, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3344' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3344)' 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 = 3344' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3344)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(ASY_EXP1, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3344' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3344)' 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 = 3344' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3344)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(ASY_EXP1, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3344' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3344)' 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 = 3344' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3344)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black MPFC - White MPFC         5.95 6.83 Inf   0.870  1.0000
##  Black MPFC - Black Vertex      15.73 7.72 Inf   2.038  0.2495
##  Black MPFC - White Vertex      13.26 8.67 Inf   1.528  0.7585
##  White MPFC - Black Vertex       9.78 8.22 Inf   1.189  1.0000
##  White MPFC - White Vertex       7.31 7.74 Inf   0.945  1.0000
##  Black Vertex - White Vertex    -2.47 6.78 Inf  -0.364  1.0000
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate   SE  df z.ratio p.value
##  Black Complementary - White Complementary    0.861 6.83 Inf   0.126  1.0000
##  Black Complementary - Black Imitative       16.724 5.87 Inf   2.848  0.0264
##  Black Complementary - White Imitative       19.342 6.83 Inf   2.831  0.0279
##  White Complementary - Black Imitative       15.863 6.78 Inf   2.339  0.1160
##  White Complementary - White Imitative       18.480 5.90 Inf   3.132  0.0104
##  Black Imitative - White Imitative            2.618 6.78 Inf   0.386  1.0000
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate   SE  df z.ratio p.value
##  Complementary MPFC - Imitative MPFC          16.14 5.91 Inf   2.730  0.0380
##  Complementary MPFC - Complementary Vertex    10.06 7.75 Inf   1.298  1.0000
##  Complementary MPFC - Imitative Vertex        29.12 7.74 Inf   3.762  0.0010
##  Imitative MPFC - Complementary Vertex        -6.08 7.72 Inf  -0.788  1.0000
##  Imitative MPFC - Imitative Vertex            12.98 7.71 Inf   1.684  0.5529
##  Complementary Vertex - Imitative Vertex      19.06 5.86 Inf   3.254  0.0068
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  MPFC effect       5.76 3.26 Inf   1.769  0.1539
##  Vertex effect    -5.76 3.26 Inf  -1.769  0.1539
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_bw)
##  contrast     estimate   SE  df z.ratio p.value
##  Black effect     0.87 2.69 Inf   0.323  1.0000
##  White effect    -0.87 2.69 Inf  -0.323  1.0000
## 
## Results are averaged over the levels of: sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate   SE  df z.ratio p.value
##  Complementary effect      8.8 2.08 Inf   4.229  <.0001
##  Imitative effect         -8.8 2.08 Inf  -4.229  <.0001
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = Asynchrony ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP1,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "Experiment 1",#titles for x and y axes
)

#Movement Time

MT_EXP1 = lmer(MovTime ~  bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = EXP1)
summary(MT_EXP1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: MovTime ~ bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: EXP1
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 45479.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9061 -0.6882 -0.0853  0.6300  5.3459 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)        13895    117.88                    
##           sitoVertex          4375     66.15   -0.63            
##           bwWhite             1855     43.07   -0.36  0.23      
##           sitoVertex:bwWhite  8527     92.34    0.47 -0.60 -0.77
##  Residual                    39909    199.77                    
## Number of obs: 3382, groups:  Subject, 16
## 
## Fixed effects:
##                                      Estimate Std. Error t value
## (Intercept)                          1281.888     31.080  41.245
## bwWhite                               -20.251     17.572  -1.152
## sitoVertex                             -4.756     21.579  -0.220
## MovementImitative                     -24.061     13.818  -1.741
## bwWhite:sitoVertex                     38.344     30.247   1.268
## bwWhite:MovementImitative               6.474     19.528   0.332
## sitoVertex:MovementImitative           14.590     19.432   0.751
## bwWhite:sitoVertex:MovementImitative   -8.886     27.499  -0.323
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit stVrtx MvmntI bwWh:V bwW:MI stV:MI
## bwWhite     -0.388                                          
## sitoVertex  -0.600  0.366                                   
## MovmntImttv -0.227  0.401  0.327                            
## bwWht:stVrt  0.443 -0.722 -0.647 -0.233                     
## bwWht:MvmnI  0.161 -0.562 -0.231 -0.708  0.326              
## stVrtx:MvmI  0.161 -0.285 -0.458 -0.711  0.327  0.503       
## bwWht:sV:MI -0.114  0.399  0.324  0.502 -0.459 -0.710 -0.707
isSingular(MT_EXP1)
## [1] FALSE

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(MT_EXP1, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3382' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3382)' 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 = 3382' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3382)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(MT_EXP1, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3382' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3382)' 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 = 3382' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3382)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(MT_EXP1, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3382' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3382)' 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 = 3382' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3382)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(MT_EXP1, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3382' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3382)' 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 = 3382' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3382)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(MT_EXP1, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3382' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3382)' 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 = 3382' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3382)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(MT_EXP1, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3382' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3382)' 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 = 3382' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3382)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black MPFC - White MPFC        17.01 14.5 Inf   1.170  1.0000
##  Black MPFC - Black Vertex      -2.54 19.2 Inf  -0.132  1.0000
##  Black MPFC - White Vertex     -19.43 16.1 Inf  -1.210  1.0000
##  White MPFC - Black Vertex     -19.55 20.0 Inf  -0.977  1.0000
##  White MPFC - White Vertex     -36.44 21.0 Inf  -1.736  0.4958
##  Black Vertex - White Vertex   -16.89 19.0 Inf  -0.889  1.0000
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Black Complementary - White Complementary    1.079 12.40 Inf   0.087  1.0000
##  Black Complementary - Black Imitative       16.767  9.72 Inf   1.726  0.5065
##  Black Complementary - White Imitative       15.815 12.39 Inf   1.277  1.0000
##  White Complementary - Black Imitative       15.688 12.33 Inf   1.272  1.0000
##  White Complementary - White Imitative       14.736  9.73 Inf   1.515  0.7791
##  Black Imitative - White Imitative           -0.952 12.32 Inf  -0.077  1.0000
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Complementary MPFC - Imitative MPFC          20.82  9.76 Inf   2.133  0.1976
##  Complementary MPFC - Complementary Vertex   -14.42 16.49 Inf  -0.874  1.0000
##  Complementary MPFC - Imitative Vertex        -3.74 16.47 Inf  -0.227  1.0000
##  Imitative MPFC - Complementary Vertex       -35.24 16.46 Inf  -2.141  0.1937
##  Imitative MPFC - Imitative Vertex           -24.56 16.44 Inf  -1.494  0.8104
##  Complementary Vertex - Imitative Vertex      10.68  9.68 Inf   1.103  1.0000
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  MPFC effect      -9.74 7.48 Inf  -1.303  0.3854
##  Vertex effect     9.74 7.48 Inf   1.303  0.3854
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_bw)
##  contrast     estimate   SE  df z.ratio p.value
##  Black effect   0.0316 5.13 Inf   0.006  1.0000
##  White effect  -0.0316 5.13 Inf  -0.006  1.0000
## 
## Results are averaged over the levels of: sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate   SE  df z.ratio p.value
##  Complementary effect     7.88 3.44 Inf   2.291  0.0439
##  Imitative effect        -7.88 3.44 Inf  -2.291  0.0439
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = MovTime ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP1,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "Experiment 1",#titles for x and y axes
)

#Start - RT

RT_EXP1 = lmer(Start ~ bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = EXP1)
summary(RT_EXP1)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Start ~ bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: EXP1
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 42331.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2862 -0.6013 -0.0558  0.5439  4.6925 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)        10228    101.13                    
##           sitoVertex          6010     77.53   -0.57            
##           bwWhite             3189     56.47   -0.42  0.43      
##           sitoVertex:bwWhite  6903     83.08    0.46 -0.56 -0.72
##  Residual                    17650    132.85                    
## Number of obs: 3347, groups:  Subject, 16
## 
## Fixed effects:
##                                      Estimate Std. Error t value
## (Intercept)                           395.318     26.133  15.127
## bwWhite                               -24.387     16.912  -1.442
## sitoVertex                             -6.504     21.480  -0.303
## MovementImitative                     -12.505      9.233  -1.354
## bwWhite:sitoVertex                    -17.874     24.546  -0.728
## bwWhite:MovementImitative              14.794     13.073   1.132
## sitoVertex:MovementImitative           -3.782     12.980  -0.291
## bwWhite:sitoVertex:MovementImitative    2.738     18.388   0.149
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit stVrtx MvmntI bwWh:V bwW:MI stV:MI
## bwWhite     -0.440                                          
## sitoVertex  -0.578  0.446                                   
## MovmntImttv -0.181  0.279  0.220                            
## bwWht:stVrt  0.444 -0.719 -0.593 -0.192                     
## bwWht:MvmnI  0.128 -0.392 -0.155 -0.706  0.270              
## stVrtx:MvmI  0.129 -0.199 -0.307 -0.711  0.269  0.502       
## bwWht:sV:MI -0.091  0.279  0.217  0.502 -0.379 -0.711 -0.706
isSingular(RT_EXP1)
## [1] FALSE

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(RT_EXP1, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3347' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3347)' 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 = 3347' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3347)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(RT_EXP1, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3347' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3347)' 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 = 3347' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3347)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(RT_EXP1, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3347' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3347)' 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 = 3347' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3347)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(RT_EXP1, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3347' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3347)' 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 = 3347' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3347)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(RT_EXP1, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3347' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3347)' 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 = 3347' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3347)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(RT_EXP1, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3347' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3347)' 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 = 3347' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3347)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black MPFC - White MPFC        16.99 15.6 Inf   1.092  1.0000
##  Black MPFC - Black Vertex       8.39 20.4 Inf   0.411  1.0000
##  Black MPFC - White Vertex      41.89 20.2 Inf   2.074  0.2287
##  White MPFC - Black Vertex      -8.60 19.5 Inf  -0.440  1.0000
##  White MPFC - White Vertex      24.90 19.9 Inf   1.251  1.0000
##  Black Vertex - White Vertex    33.50 15.8 Inf   2.123  0.2026
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Black Complementary - White Complementary    33.32 11.75 Inf   2.835  0.0275
##  Black Complementary - Black Imitative        14.40  6.49 Inf   2.218  0.1593
##  Black Complementary - White Imitative        31.56 11.74 Inf   2.687  0.0432
##  White Complementary - Black Imitative       -18.93 11.72 Inf  -1.615  0.6383
##  White Complementary - White Imitative        -1.77  6.51 Inf  -0.271  1.0000
##  Black Imitative - White Imitative            17.16 11.71 Inf   1.465  0.8572
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Complementary MPFC - Imitative MPFC           5.11  6.54 Inf   0.781  1.0000
##  Complementary MPFC - Complementary Vertex    15.44 17.31 Inf   0.892  1.0000
##  Complementary MPFC - Imitative Vertex        22.96 17.30 Inf   1.328  1.0000
##  Imitative MPFC - Complementary Vertex        10.33 17.29 Inf   0.598  1.0000
##  Imitative MPFC - Imitative Vertex            17.85 17.28 Inf   1.033  1.0000
##  Complementary Vertex - Imitative Vertex       7.52  6.47 Inf   1.163  1.0000
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  MPFC effect       8.32 8.34 Inf   0.999  0.6360
##  Vertex effect    -8.32 8.34 Inf  -0.999  0.6360
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_bw)
##  contrast     estimate  SE  df z.ratio p.value
##  Black effect     12.6 5.4 Inf   2.338  0.0387
##  White effect    -12.6 5.4 Inf  -2.338  0.0387
## 
## Results are averaged over the levels of: sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate  SE  df z.ratio p.value
##  Complementary effect     3.16 2.3 Inf   1.374  0.3392
##  Imitative effect        -3.16 2.3 Inf  -1.374  0.3392
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = Start ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP1,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Time", xlab = "Experiment 1",#titles for x and y axes
)

##STUDIO 2

EXP2 = read.xlsx("dati_tms_EXP2.xlsx", sheetIndex = 1)

Specifico i fattori

EXP2$sito = as.factor(EXP2$sito)
EXP2$bw = as.factor(EXP2$bw)
EXP2$Grasp= as.factor(EXP2$Grasp)
EXP2$Movement = as.factor(EXP2$Movement)
EXP2$Subject = as.factor (EXP2$Subject)

#Grasping Asynchrony

ASY_EXP2 = lmer (Asynchrony ~  bw * sito * Movement +
                               (1|Subject), control = lmerControl(optimizer = "bobyqa"),
                             data = EXP2)
isSingular(ASY_EXP2)
## [1] FALSE
summary(ASY_EXP2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Asynchrony ~ bw * sito * Movement + (1 | Subject)
##    Data: EXP2
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 39010.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8506 -0.7425 -0.1798  0.5811  7.1245 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept)   821.8   28.67  
##  Residual             13518.8  116.27  
## Number of obs: 3160, groups:  Subject, 15
## 
## Fixed effects:
##                                   Estimate Std. Error t value
## (Intercept)                        171.829      9.426  18.230
## bwWhite                            -17.747      8.295  -2.139
## sitovpm                              1.320      8.238   0.160
## MovementImitative                  -28.946      8.270  -3.500
## bwWhite:sitovpm                     12.457     11.721   1.063
## bwWhite:MovementImitative           15.445     11.710   1.319
## sitovpm:MovementImitative           10.838     11.673   0.928
## bwWhite:sitovpm:MovementImitative  -16.648     16.549  -1.006
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit sitvpm MvmntI bwWht: bwW:MI stv:MI
## bwWhite     -0.436                                          
## sitovpm     -0.439  0.498                                   
## MovmntImttv -0.437  0.496  0.500                            
## bwWht:stvpm  0.308 -0.708 -0.703 -0.351                     
## bwWht:MvmnI  0.308 -0.708 -0.353 -0.706  0.501              
## stvpm:MvmnI  0.310 -0.352 -0.706 -0.708  0.496  0.500       
## bwWht:st:MI -0.218  0.501  0.498  0.500 -0.708 -0.708 -0.705
Anova(ASY_EXP2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: Asynchrony
##                    Chisq Df  Pr(>Chisq)    
## bw                3.6852  1     0.05490 .  
## sito              4.4940  1     0.03401 *  
## Movement         23.3007  1 0.000001385 ***
## bw:sito           0.2462  1     0.61975    
## bw:Movement       0.7383  1     0.39020    
## sito:Movement     0.0954  1     0.75740    
## bw:sito:Movement  1.0120  1     0.31441    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

non ci sono interazioni significative, quindi plotto i dati

pirateplot(formula = Asynchrony ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "Experiment 2",#titles for x and y axes
)

Guardo main effect sito

pirateplot(formula = Asynchrony ~ sito, #dependent variable ~ independent
           data = EXP2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "Experiment 2",#titles for x and y axes
)

Guardo main effect Movement

pirateplot(formula = Asynchrony ~ Movement, #dependent variable ~ independent
           data = EXP2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "Experiment 2",#titles for x and y axes
)

#Movement Time

MT_EXP2 = lmer(MovTime ~  bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = EXP2)
summary(MT_EXP2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: MovTime ~ bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: EXP2
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 41817.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.6970 -0.6989 -0.0768  0.6399  4.5265 
## 
## Random effects:
##  Groups   Name            Variance Std.Dev. Corr             
##  Subject  (Intercept)     29141    170.71                    
##           sitovpm         13913    117.95   -0.68            
##           bwWhite          1661     40.75   -0.67  0.56      
##           sitovpm:bwWhite  6872     82.90    0.67 -0.94 -0.44
##  Residual                 32035    178.98                    
## Number of obs: 3160, groups:  Subject, 15
## 
## Fixed effects:
##                                   Estimate Std. Error t value
## (Intercept)                       1304.871     44.992  29.002
## bwWhite                              9.786     16.567   0.591
## sitovpm                              5.373     33.007   0.163
## MovementImitative                    7.162     12.766   0.561
## bwWhite:sitovpm                    -28.003     28.021  -0.999
## bwWhite:MovementImitative          -10.326     18.042  -0.572
## sitovpm:MovementImitative          -12.379     17.986  -0.688
## bwWhite:sitovpm:MovementImitative   23.157     25.484   0.909
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit sitvpm MvmntI bwWht: bwW:MI stv:MI
## bwWhite     -0.523                                          
## sitovpm     -0.666  0.479                                   
## MovmntImttv -0.142  0.386  0.194                            
## bwWht:stvpm  0.568 -0.565 -0.837 -0.228                     
## bwWht:MvmnI  0.100 -0.548 -0.137 -0.707  0.324              
## stvpm:MvmnI  0.101 -0.274 -0.273 -0.710  0.321  0.502       
## bwWht:st:MI -0.071  0.388  0.192  0.501 -0.458 -0.708 -0.706
isSingular(MT_EXP2)
## [1] FALSE
Anova(MT_EXP2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: MovTime
##                   Chisq Df Pr(>Chisq)
## bw               0.0001  1     0.9903
## sito             1.5579  1     0.2120
## Movement         0.0604  1     0.8059
## bw:sito          0.4304  1     0.5118
## bw:Movement      0.0101  1     0.9200
## sito:Movement    0.0044  1     0.9472
## bw:sito:Movement 0.8257  1     0.3635

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(MT_EXP2, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3160' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3160)' 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 = 3160' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3160)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(MT_EXP2, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3160' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3160)' 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 = 3160' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3160)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(MT_EXP2, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3160' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3160)' 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 = 3160' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3160)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")


summary(posthoc_interaction)
##  contrast              estimate   SE  df z.ratio p.value
##  Black v - White v       -4.623 13.9 Inf  -0.334  1.0000
##  Black v - Black vpm      0.816 31.8 Inf   0.026  1.0000
##  Black v - White vpm     12.618 22.7 Inf   0.555  1.0000
##  White v - Black vpm      5.439 27.5 Inf   0.197  1.0000
##  White v - White vpm     17.241 15.6 Inf   1.107  1.0000
##  Black vpm - White vpm   11.802 21.3 Inf   0.555  1.0000
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Black Complementary - White Complementary    4.216 14.44 Inf   0.292  1.0000
##  Black Complementary - Black Imitative       -0.973  8.99 Inf  -0.108  1.0000
##  Black Complementary - White Imitative        1.991 14.41 Inf   0.138  1.0000
##  White Complementary - Black Imitative       -5.188 14.44 Inf  -0.359  1.0000
##  White Complementary - White Imitative       -2.225  9.03 Inf  -0.246  1.0000
##  Black Imitative - White Imitative            2.964 14.40 Inf   0.206  1.0000
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                            estimate    SE  df z.ratio p.value
##  Complementary v - Imitative v          -2.00  9.02 Inf  -0.222  1.0000
##  Complementary v - Complementary vpm     8.63 22.62 Inf   0.382  1.0000
##  Complementary v - Imitative vpm         7.43 22.60 Inf   0.329  1.0000
##  Imitative v - Complementary vpm        10.63 22.60 Inf   0.470  1.0000
##  Imitative v - Imitative vpm             9.43 22.59 Inf   0.417  1.0000
##  Complementary vpm - Imitative vpm      -1.20  9.00 Inf  -0.133  1.0000
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests

controllo la distribuzione dei residui del modello

res = residuals(MT_EXP2)
plot(density(res))

plot(MT_EXP2)

qqnorm(residuals(MT_EXP2))
qqline(residuals(MT_EXP2))

plotto i dati

pirateplot(formula = MovTime ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "Experiment 2",#titles for x and y axes
)

#Start - RT

RT_EXP2 = lmer(Start ~ bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = EXP2)
summary(RT_EXP2)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Start ~ bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: EXP2
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 37649.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8586 -0.6389 -0.0617  0.5418  4.9565 
## 
## Random effects:
##  Groups   Name            Variance Std.Dev. Corr             
##  Subject  (Intercept)     12071.8  109.87                    
##           sitovpm          9977.2   99.89   -0.69            
##           bwWhite           763.7   27.64   -0.23  0.55      
##           sitovpm:bwWhite  6082.0   77.99    0.29 -0.71 -0.83
##  Residual                 10081.8  100.41                    
## Number of obs: 3114, groups:  Subject, 15
## 
## Fixed effects:
##                                   Estimate Std. Error t value
## (Intercept)                        274.408     28.821   9.521
## bwWhite                             -7.326     10.163  -0.721
## sitovpm                             21.584     26.771   0.806
## MovementImitative                  -18.340      7.197  -2.548
## bwWhite:sitovpm                     16.362     22.583   0.725
## bwWhite:MovementImitative           10.445     10.200   1.024
## sitovpm:MovementImitative            5.852     10.153   0.576
## bwWhite:sitovpm:MovementImitative  -27.739     14.406  -1.926
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit sitvpm MvmntI bwWht: bwW:MI stv:MI
## bwWhite     -0.244                                          
## sitovpm     -0.687  0.467                                   
## MovmntImttv -0.125  0.354  0.134                            
## bwWht:stvpm  0.293 -0.749 -0.695 -0.159                     
## bwWht:MvmnI  0.088 -0.505 -0.095 -0.706  0.227              
## stvpm:MvmnI  0.088 -0.251 -0.190 -0.709  0.225  0.500       
## bwWht:st:MI -0.062  0.358  0.134  0.500 -0.321 -0.708 -0.705
isSingular(RT_EXP2)
## [1] FALSE
Anova(RT_EXP2)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: Start
##                    Chisq Df  Pr(>Chisq)    
## bw                0.0558  1     0.81327    
## sito              2.0054  1     0.15674    
## Movement         22.5716  1 0.000002025 ***
## bw:sito           0.0125  1     0.91104    
## bw:Movement       0.2308  1     0.63092    
## sito:Movement     1.2110  1     0.27114    
## bw:sito:Movement  3.7078  1     0.05416 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

controllo la distribuzione dei residui del modello

res = residuals(RT_EXP2)
plot(density(res))

plot(RT_EXP2)

qqnorm(residuals(RT_EXP2))
qqline(residuals(RT_EXP2))

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(RT_EXP2, ~ bw * sito * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3114' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3114)' 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 = 3114' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3114)' or larger];
## but be warned that this may result in large computation time and memory use.
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                                          estimate    SE  df z.ratio
##  Black v Complementary - White v Complementary        7.326 10.16 Inf   0.721
##  Black v Complementary - Black vpm Complementary    -21.584 26.77 Inf  -0.806
##  Black v Complementary - White vpm Complementary    -30.620 19.99 Inf  -1.532
##  Black v Complementary - Black v Imitative           18.340  7.20 Inf   2.548
##  Black v Complementary - White v Imitative           15.220 10.13 Inf   1.503
##  Black v Complementary - Black vpm Imitative         -9.096 26.77 Inf  -0.340
##  Black v Complementary - White vpm Imitative         -0.839 19.97 Inf  -0.042
##  White v Complementary - Black vpm Complementary    -28.909 23.79 Inf  -1.215
##  White v Complementary - White vpm Complementary    -37.946 19.66 Inf  -1.931
##  White v Complementary - Black v Imitative           11.014 10.16 Inf   1.084
##  White v Complementary - White v Imitative            7.895  7.23 Inf   1.092
##  White v Complementary - Black vpm Imitative        -16.422 23.79 Inf  -0.690
##  White v Complementary - White vpm Imitative         -8.164 19.64 Inf  -0.416
##  Black vpm Complementary - White vpm Complementary   -9.037 16.41 Inf  -0.551
##  Black vpm Complementary - Black v Imitative         39.924 26.77 Inf   1.491
##  Black vpm Complementary - White v Imitative         36.804 23.77 Inf   1.548
##  Black vpm Complementary - Black vpm Imitative       12.488  7.16 Inf   1.744
##  Black vpm Complementary - White vpm Imitative       20.745 16.39 Inf   1.266
##  White vpm Complementary - Black v Imitative         48.960 19.99 Inf   2.449
##  White vpm Complementary - White v Imitative         45.841 19.64 Inf   2.335
##  White vpm Complementary - Black vpm Imitative       21.524 16.41 Inf   1.312
##  White vpm Complementary - White vpm Imitative       29.782  7.22 Inf   4.122
##  Black v Imitative - White v Imitative               -3.120 10.13 Inf  -0.308
##  Black v Imitative - Black vpm Imitative            -27.436 26.77 Inf  -1.025
##  Black v Imitative - White vpm Imitative            -19.179 19.97 Inf  -0.960
##  White v Imitative - Black vpm Imitative            -24.316 23.77 Inf  -1.023
##  White v Imitative - White vpm Imitative            -16.059 19.62 Inf  -0.819
##  Black vpm Imitative - White vpm Imitative            8.257 16.39 Inf   0.504
##  p.value
##   1.0000
##   1.0000
##   1.0000
##   0.3031
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   0.4011
##   0.5479
##   1.0000
##   0.0011
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
##   1.0000
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 28 tests

Calcolo medie e ds

summary_statsRT_EXP2 <- EXP2 %>%
  group_by(Movement) %>%
  summarise(
    mean_MovTime = mean(Start, na.rm = TRUE),      # Calcola la media
    sd_MovTime = sd(Start, na.rm = TRUE)           # Calcola la deviazione standard
  )

plotto i dati

pirateplot(formula = Start ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Time", xlab = "Experiment 2",#titles for x and y axes
)

plotto il main effect

pirateplot(formula = Start ~ Movement, #dependent variable ~ independent
           data = EXP2,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Time", xlab = "Experiment 2",#titles for x and y axes
)

##STUDIO 3

EXP3 = read.xlsx("dati_tms_EXP3.xlsx", sheetIndex = 1)

Specifico i fattori

EXP3$sito = as.factor(EXP3$sito)
EXP3$bw = as.factor(EXP3$bw)
EXP3$Grasp= as.factor(EXP3$Grasp)
EXP3$Movement = as.factor(EXP3$Movement)
EXP3$Subject = as.factor (EXP3$Subject)

#Grasping Asynchrony

ASY_EXP3 = lmer (Asynchrony ~  bw * sito * Movement +
                               (1+bw * sito|Subject), control = lmerControl(optimizer = "bobyqa"),
                             data = EXP3)
isSingular(ASY_EXP3)
## [1] FALSE
summary(ASY_EXP3)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Asynchrony ~ bw * sito * Movement + (1 + bw * sito | Subject)
##    Data: EXP3
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 61041.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9298 -0.7579 -0.1685  0.5869  7.4976 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)         1088.2   32.99                    
##           bwWhite              322.7   17.97   -0.41            
##           sitovertex           559.8   23.66   -0.18  0.58      
##           bwWhite:sitovertex  1131.8   33.64    0.51 -0.37 -0.43
##  Residual                    11209.6  105.88                    
## Number of obs: 5012, groups:  Subject, 24
## 
## Fixed effects:
##                                      Estimate Std. Error t value
## (Intercept)                           149.519      7.948  18.812
## bwWhite                                -2.986      7.019  -0.425
## sitovertex                             -2.733      7.786  -0.351
## MovementImitative                     -12.137      5.981  -2.029
## bwWhite:sitovertex                     13.503     10.961   1.232
## bwWhite:MovementImitative               3.288      8.445   0.389
## sitovertex:MovementImitative            5.284      8.551   0.618
## bwWhite:sitovertex:MovementImitative   -2.876     11.974  -0.240
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit stvrtx MvmntI bwWht: bwW:MI stv:MI
## bwWhite     -0.500                                          
## sitovertex  -0.383  0.514                                   
## MovmntImttv -0.374  0.424  0.382                            
## bwWht:stvrt  0.473 -0.588 -0.604 -0.272                     
## bwWht:MvmnI  0.265 -0.604 -0.271 -0.708  0.386              
## stvrtx:MvmI  0.262 -0.297 -0.549 -0.700  0.390  0.495       
## bwWht:st:MI -0.187  0.426  0.392  0.500 -0.548 -0.705 -0.714

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(ASY_EXP3, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5012' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5012)' 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 = 5012' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5012)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(ASY_EXP3, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5012' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5012)' 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 = 5012' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5012)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(ASY_EXP3, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5012' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5012)' 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 = 5012' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5012)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(ASY_EXP3, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5012' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5012)' 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 = 5012' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5012)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(ASY_EXP3, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5012' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5012)' 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 = 5012' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5012)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(ASY_EXP3, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5012' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5012)' 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 = 5012' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5012)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black mpfc - White mpfc       1.3414 5.60 Inf   0.240  1.0000
##  Black mpfc - Black vertex     0.0913 6.51 Inf   0.014  1.0000
##  Black mpfc - White vertex   -10.6319 8.66 Inf  -1.227  1.0000
##  White mpfc - Black vertex    -1.2501 5.93 Inf  -0.211  1.0000
##  White mpfc - White vertex   -11.9733 7.73 Inf  -1.549  0.7286
##  Black vertex - White vertex -10.7232 7.80 Inf  -1.375  1.0000
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate   SE  df z.ratio p.value
##  Black Complementary - White Complementary    -3.77 5.84 Inf  -0.645  1.0000
##  Black Complementary - Black Imitative         9.49 4.28 Inf   2.221  0.1582
##  Black Complementary - White Imitative         3.88 5.83 Inf   0.665  1.0000
##  White Complementary - Black Imitative        13.26 5.84 Inf   2.271  0.1388
##  White Complementary - White Imitative         7.64 4.19 Inf   1.824  0.4090
##  Black Imitative - White Imitative            -5.62 5.83 Inf  -0.964  1.0000
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate   SE  df z.ratio p.value
##  Complementary mpfc - Imitative mpfc          10.49 4.22 Inf   2.485  0.0777
##  Complementary mpfc - Complementary vertex    -4.02 6.25 Inf  -0.643  1.0000
##  Complementary mpfc - Imitative vertex         2.63 6.24 Inf   0.421  1.0000
##  Imitative mpfc - Complementary vertex       -14.51 6.25 Inf  -2.323  0.1211
##  Imitative mpfc - Imitative vertex            -7.86 6.24 Inf  -1.260  1.0000
##  Complementary vertex - Imitative vertex       6.65 4.24 Inf   1.566  0.7041
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  mpfc effect      -2.97 2.74 Inf  -1.084  0.5569
##  vertex effect     2.97 2.74 Inf   1.084  0.5569
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_bw)
##  contrast     estimate  SE  df z.ratio p.value
##  Black effect    -2.35 2.5 Inf  -0.937  0.6976
##  White effect     2.35 2.5 Inf   0.937  0.6976
## 
## Results are averaged over the levels of: sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate  SE  df z.ratio p.value
##  Complementary effect     4.28 1.5 Inf   2.863  0.0084
##  Imitative effect        -4.28 1.5 Inf  -2.863  0.0084
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = Asynchrony ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP3,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Grasping Asynchrony", xlab = "Experiment 3",#titles for x and y axes
)

#Movement Time

MT_EXP3 = lmer(MovTime ~  bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = EXP3)
summary(MT_EXP3)
## Linear mixed model fit by REML ['lmerMod']
## Formula: MovTime ~ bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: EXP3
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 66980.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0898 -0.7053 -0.1120  0.6362  5.8623 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)        15368    123.97                    
##           sitovertex          8719     93.37   -0.37            
##           bwWhite             3480     58.99   -0.03  0.72      
##           sitovertex:bwWhite  6423     80.14    0.36 -0.72 -0.71
##  Residual                    34252    185.07                    
## Number of obs: 5033, groups:  Subject, 24
## 
## Fixed effects:
##                                      Estimate Std. Error t value
## (Intercept)                          1211.803     26.355  45.980
## bwWhite                                 8.849     15.930   0.556
## sitovertex                             -3.914     21.878  -0.179
## MovementImitative                     -15.514     10.435  -1.487
## bwWhite:sitovertex                     -6.802     22.169  -0.307
## bwWhite:MovementImitative               8.317     14.719   0.565
## sitovertex:MovementImitative            8.291     14.945   0.555
## bwWhite:sitovertex:MovementImitative   -9.453     20.890  -0.453
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit stvrtx MvmntI bwWht: bwW:MI stv:MI
## bwWhite     -0.149                                          
## sitovertex  -0.403  0.629                                   
## MovmntImttv -0.197  0.326  0.237                            
## bwWht:stvrt  0.351 -0.705 -0.701 -0.234                     
## bwWht:MvmnI  0.139 -0.463 -0.168 -0.709  0.333              
## stvrtx:MvmI  0.137 -0.227 -0.341 -0.698  0.337  0.495       
## bwWht:st:MI -0.098  0.326  0.244  0.500 -0.473 -0.705 -0.715
isSingular(MT_EXP3)
## [1] FALSE

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(MT_EXP3, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5033' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5033)' 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 = 5033' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5033)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(MT_EXP3, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5033' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5033)' 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 = 5033' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5033)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(MT_EXP3, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5033' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5033)' 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 = 5033' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5033)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(MT_EXP3, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5033' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5033)' 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 = 5033' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5033)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(MT_EXP3, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5033' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5033)' 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 = 5033' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5033)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(MT_EXP3, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 5033' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 5033)' 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 = 5033' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 5033)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black mpfc - White mpfc      -13.007 14.1 Inf  -0.921  1.0000
##  Black mpfc - Black vertex     -0.232 20.6 Inf  -0.011  1.0000
##  Black mpfc - White vertex     -1.711 20.7 Inf  -0.082  1.0000
##  White mpfc - Black vertex     12.776 15.4 Inf   0.828  1.0000
##  White mpfc - White vertex     11.297 15.4 Inf   0.736  1.0000
##  Black vertex - White vertex   -1.479 13.9 Inf  -0.107  1.0000
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Black Complementary - White Complementary    -5.45 11.30 Inf  -0.482  1.0000
##  Black Complementary - Black Imitative        11.37  7.47 Inf   1.521  0.7690
##  Black Complementary - White Imitative         2.33 11.28 Inf   0.206  1.0000
##  White Complementary - Black Imitative        16.82 11.30 Inf   1.488  0.8204
##  White Complementary - White Imitative         7.78  7.30 Inf   1.066  1.0000
##  Black Imitative - White Imitative            -9.04 11.29 Inf  -0.801  1.0000
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Complementary mpfc - Imitative mpfc          11.36  7.36 Inf   1.543  0.7370
##  Complementary mpfc - Complementary vertex     7.31 16.17 Inf   0.452  1.0000
##  Complementary mpfc - Imitative vertex        15.11 16.16 Inf   0.935  1.0000
##  Imitative mpfc - Complementary vertex        -4.04 16.16 Inf  -0.250  1.0000
##  Imitative mpfc - Imitative vertex             3.75 16.15 Inf   0.232  1.0000
##  Complementary vertex - Imitative vertex       7.79  7.41 Inf   1.051  1.0000
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  mpfc effect       2.77 7.65 Inf   0.362  1.0000
##  vertex effect    -2.77 7.65 Inf  -0.362  1.0000
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_bw)
##  contrast     estimate   SE  df z.ratio p.value
##  Black effect    -3.62 5.01 Inf  -0.723  0.9389
##  White effect     3.62 5.01 Inf   0.723  0.9389
## 
## Results are averaged over the levels of: sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate   SE  df z.ratio p.value
##  Complementary effect     4.79 2.61 Inf   1.833  0.1336
##  Imitative effect        -4.79 2.61 Inf  -1.833  0.1336
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = MovTime ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP3,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Movement Time", xlab = "Experiment 3",#titles for x and y axes
)

#Start - RT

RT_EXP3 = lmer(Start ~ bw * sito * Movement +
                            (1+sito*bw|Subject), control = lmerControl(optimizer = "bobyqa"),
                          data = EXP3)
summary(RT_EXP3)
## Linear mixed model fit by REML ['lmerMod']
## Formula: Start ~ bw * sito * Movement + (1 + sito * bw | Subject)
##    Data: EXP3
## Control: lmerControl(optimizer = "bobyqa")
## 
## REML criterion at convergence: 61284.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9067 -0.6195 -0.0898  0.5406  4.8416 
## 
## Random effects:
##  Groups   Name               Variance Std.Dev. Corr             
##  Subject  (Intercept)        11442    106.97                    
##           sitovertex          6791     82.41   -0.21            
##           bwWhite             2726     52.21   -0.13  0.52      
##           sitovertex:bwWhite  3861     62.13   -0.33 -0.27 -0.42
##  Residual                    12450    111.58                    
## Number of obs: 4977, groups:  Subject, 24
## 
## Fixed effects:
##                                      Estimate Std. Error t value
## (Intercept)                           389.944     22.287  17.496
## bwWhite                               -24.178     12.396  -1.950
## sitovertex                             -9.828     18.107  -0.543
## MovementImitative                       4.427      6.324   0.700
## bwWhite:sitovertex                     20.760     15.675   1.324
## bwWhite:MovementImitative              -3.962      8.922  -0.444
## sitovertex:MovementImitative            5.207      9.059   0.575
## bwWhite:sitovertex:MovementImitative   -4.162     12.667  -0.329
## 
## Correlation of Fixed Effects:
##             (Intr) bwWhit stvrtx MvmntI bwWht: bwW:MI stv:MI
## bwWhite     -0.181                                          
## sitovertex  -0.245  0.502                                   
## MovmntImttv -0.141  0.254  0.174                            
## bwWht:stvrt -0.201 -0.499 -0.362 -0.201                     
## bwWht:MvmnI  0.100 -0.362 -0.123 -0.709  0.286              
## stvrtx:MvmI  0.099 -0.177 -0.251 -0.698  0.290  0.495       
## bwWht:st:MI -0.071  0.255  0.179  0.499 -0.406 -0.704 -0.715
isSingular(RT_EXP3)
## [1] FALSE

Svolgo i posthoc

#emmeans/posthoc
emmeans_interaction <- emmeans(RT_EXP3, ~ bw * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 4977' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 4977)' 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 = 4977' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 4977)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction1 <- emmeans(RT_EXP3, ~ bw * Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 4977' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 4977)' 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 = 4977' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 4977)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_interaction2 <- emmeans(RT_EXP3, ~ Movement * sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 4977' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 4977)' 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 = 4977' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 4977)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_sito <- emmeans(RT_EXP3, ~ sito)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 4977' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 4977)' 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 = 4977' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 4977)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_bw <- emmeans(RT_EXP3, ~ bw)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 4977' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 4977)' 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 = 4977' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 4977)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
emmeans_Movement <- emmeans(RT_EXP3, ~ Movement)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 4977' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 4977)' 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 = 4977' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 4977)' or larger];
## but be warned that this may result in large computation time and memory use.
## NOTE: Results may be misleading due to involvement in interactions
posthoc_interaction <- pairs(emmeans_interaction, adjust = "bonferroni")
posthoc_interaction1 <- pairs(emmeans_interaction1, adjust = "bonferroni")
posthoc_interaction2 <- pairs(emmeans_interaction2, adjust = "bonferroni")
posthoc_sito <- contrast(emmeans_sito, adjust = "bonferroni")
posthoc_bw <- contrast(emmeans_bw, adjust = "bonferroni")
posthoc_Movement <- contrast(emmeans_Movement, adjust = "bonferroni")

summary(posthoc_interaction)
##  contrast                    estimate   SE  df z.ratio p.value
##  Black mpfc - White mpfc        26.16 11.6 Inf   2.263  0.1417
##  Black mpfc - Black vertex       7.22 17.5 Inf   0.412  1.0000
##  Black mpfc - White vertex      14.70 23.1 Inf   0.636  1.0000
##  White mpfc - Black vertex     -18.93 15.3 Inf  -1.234  1.0000
##  White mpfc - White vertex     -11.45 18.7 Inf  -0.614  1.0000
##  Black vertex - White vertex     7.48 13.6 Inf   0.550  1.0000
## 
## Results are averaged over the levels of: Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction1)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Black Complementary - White Complementary   13.798 10.87 Inf   1.269  1.0000
##  Black Complementary - Black Imitative       -7.031  4.53 Inf  -1.552  0.7235
##  Black Complementary - White Imitative       12.810 10.87 Inf   1.179  1.0000
##  White Complementary - Black Imitative      -20.829 10.87 Inf  -1.916  0.3319
##  White Complementary - White Imitative       -0.988  4.43 Inf  -0.223  1.0000
##  Black Imitative - White Imitative           19.841 10.86 Inf   1.826  0.4069
## 
## Results are averaged over the levels of: sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_interaction2)
##  contrast                                  estimate    SE  df z.ratio p.value
##  Complementary mpfc - Imitative mpfc         -2.446  4.46 Inf  -0.548  1.0000
##  Complementary mpfc - Complementary vertex   -0.552 16.93 Inf  -0.033  1.0000
##  Complementary mpfc - Imitative vertex       -6.124 16.93 Inf  -0.362  1.0000
##  Imitative mpfc - Complementary vertex        1.895 16.93 Inf   0.112  1.0000
##  Imitative mpfc - Imitative vertex           -3.678 16.93 Inf  -0.217  1.0000
##  Complementary vertex - Imitative vertex     -5.573  4.50 Inf  -1.240  1.0000
## 
## Results are averaged over the levels of: bw 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 6 tests
summary(posthoc_sito)
##  contrast      estimate   SE  df z.ratio p.value
##  mpfc effect      -1.06 8.31 Inf  -0.127  1.0000
##  vertex effect     1.06 8.31 Inf   0.127  1.0000
## 
## Results are averaged over the levels of: bw, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_bw)
##  contrast     estimate  SE  df z.ratio p.value
##  Black effect     8.41 5.2 Inf   1.618  0.2114
##  White effect    -8.41 5.2 Inf  -1.618  0.2114
## 
## Results are averaged over the levels of: sito, Movement 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests
summary(posthoc_Movement)
##  contrast             estimate   SE  df z.ratio p.value
##  Complementary effect       -2 1.58 Inf  -1.266  0.4109
##  Imitative effect            2 1.58 Inf   1.266  0.4109
## 
## Results are averaged over the levels of: bw, sito 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: bonferroni method for 2 tests

plotto i dati

pirateplot(formula = Start ~ bw + sito + Movement, #dependent variable ~ independent
           data = EXP3,  #data
           theme = 3, #set theme
           gl.col = "white",
           ylab = "Reaction Time", xlab = "Experiment 3",#titles for x and y axes
)