##Packages

library(tidyverse)
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(readxl)
library(dplyr)
library(purrr)
library(lme4)
## Loading required package: Matrix
## 
## Attaching package: 'Matrix'
## 
## The following objects are masked from 'package:tidyr':
## 
##     expand, pack, unpack
library(sjPlot)
## Learn more about sjPlot with 'browseVignettes("sjPlot")'.
library(lmerTest)
## 
## Attaching package: 'lmerTest'
## 
## The following object is masked from 'package:lme4':
## 
##     lmer
## 
## The following object is masked from 'package:stats':
## 
##     step
library(broom)
library(ggeffects)
library(emmeans)
library(ggsignif)
library(nlme)
## 
## Attaching package: 'nlme'
## 
## The following object is masked from 'package:lme4':
## 
##     lmList
## 
## The following object is masked from 'package:dplyr':
## 
##     collapse
library(sjPlot)
library(emmeans)
library(effects)
## Loading required package: carData
## lattice theme set by effectsTheme()
## See ?effectsTheme for details.
library(car)
## 
## Attaching package: 'car'
## 
## The following object is masked from 'package:dplyr':
## 
##     recode
## 
## The following object is masked from 'package:purrr':
## 
##     some
library(corrplot)
## corrplot 0.92 loaded
library(plotly)
## 
## Attaching package: 'plotly'
## 
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## 
## The following object is masked from 'package:stats':
## 
##     filter
## 
## The following object is masked from 'package:graphics':
## 
##     layout
#Load datasets
setwd("C:/Users/Marcel/Desktop/Bachelor Thesis/Data Analysis/Relevant R Scripts/Movement Period Data (27 - Last-Step +65)/Hurst Exponents")

# Load and filter the trial_data
execution_data <- read_excel("trial_data.xlsx") %>%
  filter(Subject != 18)  # Exclude Participant 18

# Function to filter outliers
filter_outliers <- function(data) {
  data %>%
    group_by(Subject, Block) %>%
    mutate(mean_rt = mean(trial_total_rt, na.rm = TRUE),
           sd_rt = sd(trial_total_rt, na.rm = TRUE)) %>%
    filter(abs(trial_total_rt - mean_rt) <= 2.5 * sd_rt) %>%
    dplyr::select(-mean_rt, -sd_rt)
}

# Apply the outlier filter function to the data
execution_data_filtered <- filter_outliers(execution_data)
execution_data$Block <- factor(execution_data$Block, ordered = TRUE, levels = c('1','2','3','4','5','6','7','8','9','10'))
execution_data$Trial <- as.numeric(execution_data$Trial)

# Filter data to only include accurate trials
execution_data_acc <- execution_data %>% filter(trial_acc == 1)
#Load datasets
setwd("C:/Users/Marcel/Desktop/Bachelor Thesis/Data Analysis/Relevant R Scripts/Still Period Data/Hurst Exponents")

# Load and filter the trial_data
preparation_data <- read_excel("trial_data.xlsx") %>%
  filter(Subject != 18)  # Exclude Participant 18

# Function to filter outliers
filter_outliers <- function(data) {
  data %>%
    group_by(Subject, Block) %>%
    mutate(mean_rt = mean(trial_total_rt, na.rm = TRUE),
           sd_rt = sd(trial_total_rt, na.rm = TRUE)) %>%
    filter(abs(trial_total_rt - mean_rt) <= 2.5 * sd_rt) %>%
    dplyr::select(-mean_rt, -sd_rt)
}

# Apply the outlier filter function to the data
preparation_data_filtered <- filter_outliers(preparation_data)
preparation_data$Block <- factor(preparation_data$Block, ordered = TRUE, levels = c('1','2','3','4','5','6','7','8','9','10'))
preparation_data$Trial <- as.numeric(preparation_data$Trial)

# Filter data to only include accurate trials
preparation_data_acc <- preparation_data %>% filter(trial_acc == 1)

Analysis Across All Participants: Movement Preparation Data

base_size <- 14

# Acceleration X Hurst Exponents over Blocks
model_hurst_acceleration_x <- lmer(hurst_acceleration_x ~ Block + (1|Subject) + (1|Trial), data = preparation_data)
Anova(model_hurst_acceleration_x)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: hurst_acceleration_x
##        Chisq Df Pr(>Chisq)    
## Block 85.157  9  1.518e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain effects of the model
model_effects <- allEffects(model_hurst_acceleration_x)
model_effects_df <- as.data.frame(model_effects[[1]])

# Change conf interval to 83% to match p = .05
model_effects_df$l83 <- model_effects_df$fit - 1.3722 * model_effects_df$se
model_effects_df$u83 <- model_effects_df$fit + 1.3722 * model_effects_df$se

ggplot(model_effects_df, aes(x = Block, y = fit)) +
  geom_errorbar(aes(ymin = l83, ymax = u83), width = 0.2, size = 1, color = "darkorchid4") + 
  geom_point(color = "darkorchid2", size = 4) +
  geom_vline(xintercept = 8.5, color = "red", size = 1) +  
  xlab("Block") + ylab("Hurst Exponent") +
  ggtitle("Movement Preperation Period") +  
  labs(subtitle = "Hurst Acceleration X ~ Block + (1|Subject) + (1|Trial)") +
  scale_y_continuous(limits = c(0.75, 1)) +
  theme_minimal() +
  theme(text = element_text(size = base_size),  
        axis.title = element_text(size = base_size + 2), 
        plot.title = element_text(size = base_size + 4, face = "bold"),  
        plot.subtitle = element_text(size = base_size + 2),  
        axis.text = element_text(size = base_size - 2),
        axis.text.y = element_text(face = "bold"),
        axis.text.x = element_text(face = "bold"))
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

# Post hocs
emm_blocks <- emmeans(model_hurst_acceleration_x, specs = ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 10560' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 10560)' 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 = 10560' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 10560)' or larger];
## but be warned that this may result in large computation time and memory use.
comparisons <- pairs(emm_blocks)
print(comparisons)
##  contrast         estimate      SE  df z.ratio p.value
##  Block1 - Block2   0.00158 0.00483 Inf   0.326  1.0000
##  Block1 - Block3  -0.00550 0.00483 Inf  -1.139  0.9808
##  Block1 - Block4  -0.01077 0.00483 Inf  -2.229  0.4365
##  Block1 - Block5  -0.00573 0.00483 Inf  -1.186  0.9746
##  Block1 - Block6  -0.01363 0.00483 Inf  -2.820  0.1295
##  Block1 - Block7  -0.02241 0.00483 Inf  -4.636  0.0002
##  Block1 - Block8  -0.02833 0.00483 Inf  -5.862  <.0001
##  Block1 - Block9  -0.02013 0.00483 Inf  -4.166  0.0013
##  Block1 - Block10 -0.02415 0.00483 Inf  -4.997  <.0001
##  Block2 - Block3  -0.00708 0.00483 Inf  -1.465  0.9061
##  Block2 - Block4  -0.01235 0.00483 Inf  -2.555  0.2393
##  Block2 - Block5  -0.00731 0.00483 Inf  -1.512  0.8878
##  Block2 - Block6  -0.01520 0.00483 Inf  -3.146  0.0527
##  Block2 - Block7  -0.02398 0.00483 Inf  -4.962  <.0001
##  Block2 - Block8  -0.02990 0.00483 Inf  -6.188  <.0001
##  Block2 - Block9  -0.02171 0.00483 Inf  -4.492  0.0003
##  Block2 - Block10 -0.02573 0.00483 Inf  -5.323  <.0001
##  Block3 - Block4  -0.00527 0.00483 Inf  -1.091  0.9857
##  Block3 - Block5  -0.00023 0.00483 Inf  -0.048  1.0000
##  Block3 - Block6  -0.00813 0.00483 Inf  -1.682  0.8061
##  Block3 - Block7  -0.01690 0.00483 Inf  -3.498  0.0169
##  Block3 - Block8  -0.02283 0.00483 Inf  -4.723  0.0001
##  Block3 - Block9  -0.01463 0.00483 Inf  -3.027  0.0744
##  Block3 - Block10 -0.01865 0.00483 Inf  -3.859  0.0045
##  Block4 - Block5   0.00504 0.00483 Inf   1.043  0.9896
##  Block4 - Block6  -0.00286 0.00483 Inf  -0.591  0.9999
##  Block4 - Block7  -0.01163 0.00483 Inf  -2.407  0.3212
##  Block4 - Block8  -0.01756 0.00483 Inf  -3.633  0.0105
##  Block4 - Block9  -0.00936 0.00483 Inf  -1.937  0.6436
##  Block4 - Block10 -0.01338 0.00483 Inf  -2.768  0.1473
##  Block5 - Block6  -0.00790 0.00483 Inf  -1.634  0.8315
##  Block5 - Block7  -0.01667 0.00483 Inf  -3.450  0.0199
##  Block5 - Block8  -0.02260 0.00483 Inf  -4.676  0.0001
##  Block5 - Block9  -0.01440 0.00483 Inf  -2.980  0.0850
##  Block5 - Block10 -0.01842 0.00483 Inf  -3.811  0.0054
##  Block6 - Block7  -0.00878 0.00483 Inf  -1.816  0.7252
##  Block6 - Block8  -0.01470 0.00483 Inf  -3.042  0.0715
##  Block6 - Block9  -0.00650 0.00483 Inf  -1.346  0.9429
##  Block6 - Block10 -0.01052 0.00483 Inf  -2.177  0.4727
##  Block7 - Block8  -0.00592 0.00483 Inf  -1.226  0.9685
##  Block7 - Block9   0.00227 0.00483 Inf   0.470  1.0000
##  Block7 - Block10 -0.00174 0.00483 Inf  -0.361  1.0000
##  Block8 - Block9   0.00820 0.00483 Inf   1.696  0.7982
##  Block8 - Block10  0.00418 0.00483 Inf   0.865  0.9974
##  Block9 - Block10 -0.00402 0.00483 Inf  -0.831  0.9981
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 10 estimates
# Acceleration Y Hurst Exponents over Blocks
model_hurst_acceleration_y <- lmer(hurst_acceleration_y ~ Block + (1|Subject) + (1|Trial), data = preparation_data)
Anova(model_hurst_acceleration_y)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: hurst_acceleration_y
##        Chisq Df Pr(>Chisq)    
## Block 77.683  9  4.658e-13 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain effects of the model
model_effects <- allEffects(model_hurst_acceleration_y)
model_effects_df <- as.data.frame(model_effects[[1]])

# Change conf interval to 83% to match p = .05
model_effects_df$l83 <- model_effects_df$fit - 1.3722 * model_effects_df$se
model_effects_df$u83 <- model_effects_df$fit + 1.3722 * model_effects_df$se

ggplot(model_effects_df, aes(x = Block, y = fit)) +
  geom_errorbar(aes(ymin = l83, ymax = u83), width = 0.2, size = 1, color = "darkorchid4") + 
  geom_point(color = "darkorchid2", size = 4) +
  geom_vline(xintercept = 8.5, color = "red", size = 1) +  
  xlab("Block") + ylab("Hurst Exponent") +
  labs(subtitle = "Hurst Acceleration Y ~ Block + (1|Subject) + (1|Trial)") +
  scale_y_continuous(limits = c(0.75, 1)) +
  theme_minimal() +
  theme(text = element_text(size = base_size),  
        axis.title = element_text(size = base_size + 2), 
        plot.title = element_text(size = base_size + 4, face = "bold", colour = NA),  
        plot.subtitle = element_text(size = base_size + 2),
        axis.text = element_text(size = base_size - 2),
        axis.text.y = element_text(face = "bold"),  
        axis.text.x = element_text(face = "bold"))

# Post hocs
emm_blocks <- emmeans(model_hurst_acceleration_y, specs = ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 10560' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 10560)' 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 = 10560' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 10560)' or larger];
## but be warned that this may result in large computation time and memory use.
comparisons <- pairs(emm_blocks)
print(comparisons)
##  contrast          estimate      SE  df z.ratio p.value
##  Block1 - Block2   0.005256 0.00558 Inf   0.941  0.9951
##  Block1 - Block3   0.004658 0.00558 Inf   0.834  0.9981
##  Block1 - Block4   0.001261 0.00558 Inf   0.226  1.0000
##  Block1 - Block5   0.002059 0.00558 Inf   0.369  1.0000
##  Block1 - Block6  -0.015102 0.00558 Inf  -2.705  0.1715
##  Block1 - Block7  -0.018289 0.00558 Inf  -3.276  0.0354
##  Block1 - Block8  -0.025410 0.00558 Inf  -4.551  0.0002
##  Block1 - Block9  -0.013695 0.00558 Inf  -2.453  0.2945
##  Block1 - Block10 -0.019502 0.00558 Inf  -3.493  0.0172
##  Block2 - Block3  -0.000598 0.00558 Inf  -0.107  1.0000
##  Block2 - Block4  -0.003994 0.00558 Inf  -0.715  0.9994
##  Block2 - Block5  -0.003197 0.00558 Inf  -0.573  0.9999
##  Block2 - Block6  -0.020358 0.00558 Inf  -3.646  0.0100
##  Block2 - Block7  -0.023545 0.00558 Inf  -4.217  0.0010
##  Block2 - Block8  -0.030666 0.00558 Inf  -5.492  <.0001
##  Block2 - Block9  -0.018951 0.00558 Inf  -3.394  0.0241
##  Block2 - Block10 -0.024758 0.00558 Inf  -4.434  0.0004
##  Block3 - Block4  -0.003397 0.00558 Inf  -0.608  0.9998
##  Block3 - Block5  -0.002599 0.00558 Inf  -0.465  1.0000
##  Block3 - Block6  -0.019760 0.00558 Inf  -3.539  0.0147
##  Block3 - Block7  -0.022947 0.00558 Inf  -4.110  0.0016
##  Block3 - Block8  -0.030068 0.00558 Inf  -5.385  <.0001
##  Block3 - Block9  -0.018353 0.00558 Inf  -3.287  0.0341
##  Block3 - Block10 -0.024160 0.00558 Inf  -4.327  0.0006
##  Block4 - Block5   0.000798 0.00558 Inf   0.143  1.0000
##  Block4 - Block6  -0.016363 0.00558 Inf  -2.931  0.0972
##  Block4 - Block7  -0.019550 0.00558 Inf  -3.501  0.0167
##  Block4 - Block8  -0.026672 0.00558 Inf  -4.777  0.0001
##  Block4 - Block9  -0.014956 0.00558 Inf  -2.679  0.1822
##  Block4 - Block10 -0.020763 0.00558 Inf  -3.719  0.0077
##  Block5 - Block6  -0.017161 0.00558 Inf  -3.074  0.0652
##  Block5 - Block7  -0.020348 0.00558 Inf  -3.644  0.0101
##  Block5 - Block8  -0.027469 0.00558 Inf  -4.920  <.0001
##  Block5 - Block9  -0.015754 0.00558 Inf  -2.822  0.1291
##  Block5 - Block10 -0.021561 0.00558 Inf  -3.862  0.0044
##  Block6 - Block7  -0.003187 0.00558 Inf  -0.571  0.9999
##  Block6 - Block8  -0.010308 0.00558 Inf  -1.846  0.7055
##  Block6 - Block9   0.001407 0.00558 Inf   0.252  1.0000
##  Block6 - Block10 -0.004400 0.00558 Inf  -0.788  0.9988
##  Block7 - Block8  -0.007121 0.00558 Inf  -1.275  0.9592
##  Block7 - Block9   0.004594 0.00558 Inf   0.823  0.9983
##  Block7 - Block10 -0.001213 0.00558 Inf  -0.217  1.0000
##  Block8 - Block9   0.011715 0.00558 Inf   2.098  0.5287
##  Block8 - Block10  0.005909 0.00558 Inf   1.058  0.9885
##  Block9 - Block10 -0.005807 0.00558 Inf  -1.040  0.9898
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 10 estimates
# Acceleration Z Hurst Exponents over Blocks
model_hurst_acceleration_z <- lmer(hurst_acceleration_z ~ Block + (1|Subject) + (1|Trial), data = preparation_data)
Anova(model_hurst_acceleration_z)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: hurst_acceleration_z
##        Chisq Df Pr(>Chisq)    
## Block 54.696  9  1.392e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain effects of the model
model_effects <- allEffects(model_hurst_acceleration_z)
model_effects_df <- as.data.frame(model_effects[[1]])

# Change conf interval to 83% to match p = .05
model_effects_df$l83 <- model_effects_df$fit - 1.3722 * model_effects_df$se
model_effects_df$u83 <- model_effects_df$fit + 1.3722 * model_effects_df$se

ggplot(model_effects_df, aes(x = Block, y = fit)) +
  geom_errorbar(aes(ymin = l83, ymax = u83), width = 0.2, size = 1, color = "darkorchid4") + 
  geom_point(color = "darkorchid2", size = 4) +
  geom_vline(xintercept = 8.5, color = "red", size = 1) +  
  xlab("Block") + ylab("Hurst Exponent") +
  labs(subtitle = "Hurst Acceleration Z ~ Block + (1|Subject) + (1|Trial)") +
  scale_y_continuous(limits = c(0.75, 1)) +
  theme_minimal() +
  theme(text = element_text(size = base_size),  
        axis.title = element_text(size = base_size + 2), 
        plot.title = element_text(size = base_size + 4, face = "bold", colour = NA),  
        plot.subtitle = element_text(size = base_size + 2),
        axis.text = element_text(size = base_size - 2),
        axis.text.y = element_text(face = "bold"),  
        axis.text.x = element_text(face = "bold"))

# Post hocs
emm_blocks <- emmeans(model_hurst_acceleration_z, specs = ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 10560' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 10560)' 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 = 10560' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 10560)' or larger];
## but be warned that this may result in large computation time and memory use.
comparisons <- pairs(emm_blocks)
print(comparisons)
##  contrast         estimate     SE  df z.ratio p.value
##  Block1 - Block2   0.00904 0.0064 Inf   1.412  0.9238
##  Block1 - Block3   0.00505 0.0064 Inf   0.789  0.9987
##  Block1 - Block4   0.00642 0.0064 Inf   1.003  0.9922
##  Block1 - Block5   0.01571 0.0064 Inf   2.454  0.2937
##  Block1 - Block6  -0.00191 0.0064 Inf  -0.298  1.0000
##  Block1 - Block7  -0.00611 0.0064 Inf  -0.955  0.9946
##  Block1 - Block8  -0.01878 0.0064 Inf  -2.935  0.0961
##  Block1 - Block9  -0.00794 0.0064 Inf  -1.241  0.9657
##  Block1 - Block10 -0.01711 0.0064 Inf  -2.673  0.1847
##  Block2 - Block3  -0.00399 0.0064 Inf  -0.623  0.9998
##  Block2 - Block4  -0.00262 0.0064 Inf  -0.410  1.0000
##  Block2 - Block5   0.00667 0.0064 Inf   1.042  0.9897
##  Block2 - Block6  -0.01095 0.0064 Inf  -1.711  0.7898
##  Block2 - Block7  -0.01515 0.0064 Inf  -2.367  0.3457
##  Block2 - Block8  -0.02782 0.0064 Inf  -4.347  0.0006
##  Block2 - Block9  -0.01698 0.0064 Inf  -2.654  0.1930
##  Block2 - Block10 -0.02614 0.0064 Inf  -4.085  0.0018
##  Block3 - Block4   0.00137 0.0064 Inf   0.214  1.0000
##  Block3 - Block5   0.01066 0.0064 Inf   1.665  0.8153
##  Block3 - Block6  -0.00696 0.0064 Inf  -1.087  0.9860
##  Block3 - Block7  -0.01116 0.0064 Inf  -1.744  0.7701
##  Block3 - Block8  -0.02383 0.0064 Inf  -3.724  0.0075
##  Block3 - Block9  -0.01300 0.0064 Inf  -2.031  0.5772
##  Block3 - Block10 -0.02216 0.0064 Inf  -3.462  0.0192
##  Block4 - Block5   0.00929 0.0064 Inf   1.451  0.9108
##  Block4 - Block6  -0.00833 0.0064 Inf  -1.301  0.9537
##  Block4 - Block7  -0.01253 0.0064 Inf  -1.958  0.6290
##  Block4 - Block8  -0.02520 0.0064 Inf  -3.938  0.0033
##  Block4 - Block9  -0.01436 0.0064 Inf  -2.244  0.4263
##  Block4 - Block10 -0.02352 0.0064 Inf  -3.676  0.0090
##  Block5 - Block6  -0.01762 0.0064 Inf  -2.752  0.1531
##  Block5 - Block7  -0.02182 0.0064 Inf  -3.409  0.0229
##  Block5 - Block8  -0.03449 0.0064 Inf  -5.389  <.0001
##  Block5 - Block9  -0.02365 0.0064 Inf  -3.696  0.0083
##  Block5 - Block10 -0.03281 0.0064 Inf  -5.127  <.0001
##  Block6 - Block7  -0.00420 0.0064 Inf  -0.657  0.9997
##  Block6 - Block8  -0.01687 0.0064 Inf  -2.637  0.2005
##  Block6 - Block9  -0.00604 0.0064 Inf  -0.943  0.9950
##  Block6 - Block10 -0.01520 0.0064 Inf  -2.375  0.3412
##  Block7 - Block8  -0.01267 0.0064 Inf  -1.980  0.6133
##  Block7 - Block9  -0.00183 0.0064 Inf  -0.286  1.0000
##  Block7 - Block10 -0.01099 0.0064 Inf  -1.718  0.7856
##  Block8 - Block9   0.01084 0.0064 Inf   1.694  0.7995
##  Block8 - Block10  0.00168 0.0064 Inf   0.262  1.0000
##  Block9 - Block10 -0.00916 0.0064 Inf  -1.432  0.9176
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 10 estimates

Analysis Across All Participants: Sequence Execution Data

base_size <- 14

# Acceleration X Hurst Exponents over Blocks
model_hurst_acceleration_x <- lmer(hurst_acceleration_x ~ Block + (1|Subject) + (1|Trial), data = execution_data)
Anova(model_hurst_acceleration_x)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: hurst_acceleration_x
##        Chisq Df Pr(>Chisq)    
## Block 316.73  9  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain effects of the model
model_effects <- allEffects(model_hurst_acceleration_x)
model_effects_df <- as.data.frame(model_effects[[1]])

# Change conf interval to 83% to match p = .05
model_effects_df$l83 <- model_effects_df$fit - 1.3722 * model_effects_df$se
model_effects_df$u83 <- model_effects_df$fit + 1.3722 * model_effects_df$se

ggplot(model_effects_df, aes(x = Block, y = fit)) +
  geom_errorbar(aes(ymin = l83, ymax = u83), width = 0.2, size = 1, color = "aquamarine4") + 
  geom_point(color = "aquamarine3", size = 4) +
  geom_vline(xintercept = 8.5, color = "red", size = 1) +  
  xlab("Block") + ylab("Hurst Exponent") +
  labs(subtitle = "Hurst Acceleration X ~ Block + (1|Subject) + (1|Trial)") +  
  scale_y_continuous(limits = c(0.75, 1)) +
  theme_minimal() +
  theme(text = element_text(size = base_size),  
        axis.title = element_text(size = base_size + 2), 
        plot.title = element_text(size = base_size + 4, face = "bold"),  
        plot.subtitle = element_text(size = base_size + 2),  
        axis.text = element_text(size = base_size - 2),
        axis.text.y = element_text(face = "bold"),
        axis.text.x = element_text(face = "bold"))

# Post hocs
emm_blocks <- emmeans(model_hurst_acceleration_x, specs = ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 10560' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 10560)' 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 = 10560' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 10560)' or larger];
## but be warned that this may result in large computation time and memory use.
comparisons <- pairs(emm_blocks)
print(comparisons)
##  contrast          estimate      SE  df z.ratio p.value
##  Block1 - Block2   8.24e-03 0.00307 Inf   2.684  0.1798
##  Block1 - Block3   1.56e-02 0.00307 Inf   5.094  <.0001
##  Block1 - Block4   2.77e-02 0.00307 Inf   9.032  <.0001
##  Block1 - Block5   2.70e-02 0.00307 Inf   8.784  <.0001
##  Block1 - Block6   2.77e-02 0.00307 Inf   9.037  <.0001
##  Block1 - Block7   3.51e-02 0.00307 Inf  11.429  <.0001
##  Block1 - Block8   3.14e-02 0.00307 Inf  10.214  <.0001
##  Block1 - Block9   3.59e-02 0.00307 Inf  11.681  <.0001
##  Block1 - Block10  3.98e-02 0.00307 Inf  12.978  <.0001
##  Block2 - Block3   7.40e-03 0.00307 Inf   2.409  0.3200
##  Block2 - Block4   1.95e-02 0.00307 Inf   6.348  <.0001
##  Block2 - Block5   1.87e-02 0.00307 Inf   6.100  <.0001
##  Block2 - Block6   1.95e-02 0.00307 Inf   6.353  <.0001
##  Block2 - Block7   2.68e-02 0.00307 Inf   8.745  <.0001
##  Block2 - Block8   2.31e-02 0.00307 Inf   7.529  <.0001
##  Block2 - Block9   2.76e-02 0.00307 Inf   8.997  <.0001
##  Block2 - Block10  3.16e-02 0.00307 Inf  10.294  <.0001
##  Block3 - Block4   1.21e-02 0.00307 Inf   3.938  0.0033
##  Block3 - Block5   1.13e-02 0.00307 Inf   3.691  0.0085
##  Block3 - Block6   1.21e-02 0.00307 Inf   3.943  0.0032
##  Block3 - Block7   1.94e-02 0.00307 Inf   6.336  <.0001
##  Block3 - Block8   1.57e-02 0.00307 Inf   5.120  <.0001
##  Block3 - Block9   2.02e-02 0.00307 Inf   6.587  <.0001
##  Block3 - Block10  2.42e-02 0.00307 Inf   7.884  <.0001
##  Block4 - Block5  -7.60e-04 0.00307 Inf  -0.248  1.0000
##  Block4 - Block6   1.59e-05 0.00307 Inf   0.005  1.0000
##  Block4 - Block7   7.36e-03 0.00307 Inf   2.397  0.3271
##  Block4 - Block8   3.63e-03 0.00307 Inf   1.182  0.9752
##  Block4 - Block9   8.13e-03 0.00307 Inf   2.649  0.1949
##  Block4 - Block10  1.21e-02 0.00307 Inf   3.946  0.0032
##  Block5 - Block6   7.76e-04 0.00307 Inf   0.253  1.0000
##  Block5 - Block7   8.12e-03 0.00307 Inf   2.645  0.1967
##  Block5 - Block8   4.39e-03 0.00307 Inf   1.429  0.9183
##  Block5 - Block9   8.89e-03 0.00307 Inf   2.897  0.1063
##  Block5 - Block10  1.29e-02 0.00307 Inf   4.194  0.0011
##  Block6 - Block7   7.34e-03 0.00307 Inf   2.392  0.3303
##  Block6 - Block8   3.61e-03 0.00307 Inf   1.176  0.9760
##  Block6 - Block9   8.12e-03 0.00307 Inf   2.644  0.1972
##  Block6 - Block10  1.21e-02 0.00307 Inf   3.941  0.0032
##  Block7 - Block8  -3.73e-03 0.00307 Inf  -1.216  0.9701
##  Block7 - Block9   7.73e-04 0.00307 Inf   0.252  1.0000
##  Block7 - Block10  4.75e-03 0.00307 Inf   1.549  0.8724
##  Block8 - Block9   4.50e-03 0.00307 Inf   1.468  0.9050
##  Block8 - Block10  8.49e-03 0.00307 Inf   2.764  0.1487
##  Block9 - Block10  3.98e-03 0.00307 Inf   1.297  0.9546
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 10 estimates
# Acceleration Y Hurst Exponents over Blocks
model_hurst_acceleration_y <- lmer(hurst_acceleration_y ~ Block + (1|Subject) + (1|Trial), data = execution_data)
Anova(model_hurst_acceleration_y)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: hurst_acceleration_y
##        Chisq Df Pr(>Chisq)    
## Block 170.86  9  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain effects of the model
model_effects <- allEffects(model_hurst_acceleration_y)
model_effects_df <- as.data.frame(model_effects[[1]])

# Change conf interval to 83% to match p = .05
model_effects_df$l83 <- model_effects_df$fit - 1.3722 * model_effects_df$se
model_effects_df$u83 <- model_effects_df$fit + 1.3722 * model_effects_df$se

ggplot(model_effects_df, aes(x = Block, y = fit)) +
  geom_errorbar(aes(ymin = l83, ymax = u83), width = 0.2, size = 1, color = "aquamarine4") + 
  geom_point(color = "aquamarine3", size = 4) +
  geom_vline(xintercept = 8.5, color = "red", size = 1) +  
  xlab("Block") + ylab("Hurst Exponent") +
  labs(subtitle = "Hurst Acceleration Y ~ Block + (1|Subject) + (1|Trial)") +  
  scale_y_continuous(limits = c(0.75, 1)) +
  theme_minimal() +
  theme(text = element_text(size = base_size),  
        axis.title = element_text(size = base_size + 2), 
        plot.title = element_text(size = base_size + 4, face = "bold", colour = NA),  
        plot.subtitle = element_text(size = base_size + 2),  
        axis.text = element_text(size = base_size - 2),
        axis.text.y = element_text(face = "bold"),
        axis.text.x = element_text(face = "bold"))  

# Post hocs
emm_blocks <- emmeans(model_hurst_acceleration_y, specs = ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 10560' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 10560)' 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 = 10560' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 10560)' or larger];
## but be warned that this may result in large computation time and memory use.
comparisons <- pairs(emm_blocks)
print(comparisons)
##  contrast          estimate      SE  df z.ratio p.value
##  Block1 - Block2  -0.001647 0.00295 Inf  -0.558  0.9999
##  Block1 - Block3   0.007527 0.00295 Inf   2.551  0.2414
##  Block1 - Block4   0.005733 0.00295 Inf   1.943  0.6393
##  Block1 - Block5   0.010603 0.00295 Inf   3.594  0.0121
##  Block1 - Block6   0.010351 0.00295 Inf   3.508  0.0163
##  Block1 - Block7   0.021067 0.00295 Inf   7.140  <.0001
##  Block1 - Block8   0.021634 0.00295 Inf   7.332  <.0001
##  Block1 - Block9   0.024060 0.00295 Inf   8.154  <.0001
##  Block1 - Block10  0.017490 0.00295 Inf   5.928  <.0001
##  Block2 - Block3   0.009175 0.00295 Inf   3.109  0.0588
##  Block2 - Block4   0.007380 0.00295 Inf   2.501  0.2675
##  Block2 - Block5   0.012251 0.00295 Inf   4.152  0.0014
##  Block2 - Block6   0.011998 0.00295 Inf   4.066  0.0019
##  Block2 - Block7   0.022714 0.00295 Inf   7.698  <.0001
##  Block2 - Block8   0.023281 0.00295 Inf   7.890  <.0001
##  Block2 - Block9   0.025707 0.00295 Inf   8.712  <.0001
##  Block2 - Block10  0.019137 0.00295 Inf   6.486  <.0001
##  Block3 - Block4  -0.001794 0.00295 Inf  -0.608  0.9999
##  Block3 - Block5   0.003076 0.00295 Inf   1.042  0.9896
##  Block3 - Block6   0.002824 0.00295 Inf   0.957  0.9945
##  Block3 - Block7   0.013540 0.00295 Inf   4.589  0.0002
##  Block3 - Block8   0.014107 0.00295 Inf   4.781  0.0001
##  Block3 - Block9   0.016532 0.00295 Inf   5.603  <.0001
##  Block3 - Block10  0.009963 0.00295 Inf   3.377  0.0255
##  Block4 - Block5   0.004870 0.00295 Inf   1.651  0.8230
##  Block4 - Block6   0.004618 0.00295 Inf   1.565  0.8651
##  Block4 - Block7   0.015334 0.00295 Inf   5.197  <.0001
##  Block4 - Block8   0.015901 0.00295 Inf   5.389  <.0001
##  Block4 - Block9   0.018326 0.00295 Inf   6.211  <.0001
##  Block4 - Block10  0.011757 0.00295 Inf   3.985  0.0027
##  Block5 - Block6  -0.000252 0.00295 Inf  -0.085  1.0000
##  Block5 - Block7   0.010464 0.00295 Inf   3.546  0.0143
##  Block5 - Block8   0.011031 0.00295 Inf   3.738  0.0071
##  Block5 - Block9   0.013456 0.00295 Inf   4.560  0.0002
##  Block5 - Block10  0.006887 0.00295 Inf   2.334  0.3667
##  Block6 - Block7   0.010716 0.00295 Inf   3.632  0.0105
##  Block6 - Block8   0.011283 0.00295 Inf   3.824  0.0051
##  Block6 - Block9   0.013708 0.00295 Inf   4.646  0.0001
##  Block6 - Block10  0.007139 0.00295 Inf   2.420  0.3139
##  Block7 - Block8   0.000567 0.00295 Inf   0.192  1.0000
##  Block7 - Block9   0.002992 0.00295 Inf   1.014  0.9915
##  Block7 - Block10 -0.003577 0.00295 Inf  -1.212  0.9706
##  Block8 - Block9   0.002426 0.00295 Inf   0.822  0.9983
##  Block8 - Block10 -0.004144 0.00295 Inf  -1.404  0.9263
##  Block9 - Block10 -0.006569 0.00295 Inf  -2.226  0.4384
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 10 estimates
# Acceleration Z Hurst Exponents over Blocks
model_hurst_acceleration_z <- lmer(hurst_acceleration_z ~ Block + (1|Subject) + (1|Trial), data = execution_data)
## boundary (singular) fit: see help('isSingular')
Anova(model_hurst_acceleration_z)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: hurst_acceleration_z
##        Chisq Df Pr(>Chisq)   
## Block 26.039  9   0.002013 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Obtain effects of the model
model_effects <- allEffects(model_hurst_acceleration_z)
model_effects_df <- as.data.frame(model_effects[[1]])

# Change conf interval to 83% to match p = .05
model_effects_df$l83 <- model_effects_df$fit - 1.3722 * model_effects_df$se
model_effects_df$u83 <- model_effects_df$fit + 1.3722 * model_effects_df$se

ggplot(model_effects_df, aes(x = Block, y = fit)) +
  geom_errorbar(aes(ymin = l83, ymax = u83), width = 0.2, size = 1, color = "aquamarine4") + 
  geom_point(color = "aquamarine3", size = 4) +
  geom_vline(xintercept = 8.5, color = "red", size = 1) +  
  xlab("Block") + ylab("Hurst Exponent") +
  labs(subtitle = "Hurst Acceleration Z ~ Block + (1|Subject) + (1|Trial)") +
  scale_y_continuous(limits = c(0.98, 1)) +
  theme_minimal() +
  theme(text = element_text(size = base_size),  
        axis.title = element_text(size = base_size + 2), 
        plot.title = element_text(size = base_size + 4, face = "bold", colour = NA),  
        plot.subtitle = element_text(size = base_size + 2),
        axis.text = element_text(size = base_size - 2),
        axis.text.y = element_text(face = "bold", color = "red"),  
        axis.text.x = element_text(face = "bold"))

# Post hocs
emm_blocks <- emmeans(model_hurst_acceleration_z, specs = ~ Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 10560' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 10560)' 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 = 10560' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 10560)' or larger];
## but be warned that this may result in large computation time and memory use.
comparisons <- pairs(emm_blocks)
print(comparisons)
##  contrast          estimate      SE  df z.ratio p.value
##  Block1 - Block2  -0.003981 0.00126 Inf  -3.157  0.0510
##  Block1 - Block3  -0.003472 0.00126 Inf  -2.753  0.1528
##  Block1 - Block4  -0.001417 0.00126 Inf  -1.123  0.9824
##  Block1 - Block5   0.000530 0.00126 Inf   0.421  1.0000
##  Block1 - Block6  -0.000695 0.00126 Inf  -0.551  0.9999
##  Block1 - Block7  -0.000852 0.00126 Inf  -0.676  0.9996
##  Block1 - Block8  -0.001033 0.00126 Inf  -0.819  0.9983
##  Block1 - Block9  -0.000135 0.00126 Inf  -0.107  1.0000
##  Block1 - Block10  0.000185 0.00126 Inf   0.147  1.0000
##  Block2 - Block3   0.000509 0.00126 Inf   0.404  1.0000
##  Block2 - Block4   0.002564 0.00126 Inf   2.033  0.5752
##  Block2 - Block5   0.004512 0.00126 Inf   3.577  0.0128
##  Block2 - Block6   0.003286 0.00126 Inf   2.606  0.2147
##  Block2 - Block7   0.003129 0.00126 Inf   2.481  0.2785
##  Block2 - Block8   0.002948 0.00126 Inf   2.338  0.3644
##  Block2 - Block9   0.003846 0.00126 Inf   3.050  0.0698
##  Block2 - Block10  0.004166 0.00126 Inf   3.303  0.0324
##  Block3 - Block4   0.002055 0.00126 Inf   1.630  0.8338
##  Block3 - Block5   0.004002 0.00126 Inf   3.174  0.0485
##  Block3 - Block6   0.002777 0.00126 Inf   2.202  0.4553
##  Block3 - Block7   0.002620 0.00126 Inf   2.077  0.5436
##  Block3 - Block8   0.002439 0.00126 Inf   1.934  0.6457
##  Block3 - Block9   0.003337 0.00126 Inf   2.646  0.1962
##  Block3 - Block10  0.003657 0.00126 Inf   2.900  0.1055
##  Block4 - Block5   0.001947 0.00126 Inf   1.544  0.8744
##  Block4 - Block6   0.000722 0.00126 Inf   0.572  0.9999
##  Block4 - Block7   0.000565 0.00126 Inf   0.448  1.0000
##  Block4 - Block8   0.000384 0.00126 Inf   0.304  1.0000
##  Block4 - Block9   0.001282 0.00126 Inf   1.017  0.9914
##  Block4 - Block10  0.001602 0.00126 Inf   1.270  0.9603
##  Block5 - Block6  -0.001226 0.00126 Inf  -0.972  0.9938
##  Block5 - Block7  -0.001383 0.00126 Inf  -1.096  0.9852
##  Block5 - Block8  -0.001564 0.00126 Inf  -1.240  0.9660
##  Block5 - Block9  -0.000665 0.00126 Inf  -0.528  1.0000
##  Block5 - Block10 -0.000346 0.00126 Inf  -0.274  1.0000
##  Block6 - Block7  -0.000157 0.00126 Inf  -0.125  1.0000
##  Block6 - Block8  -0.000338 0.00126 Inf  -0.268  1.0000
##  Block6 - Block9   0.000560 0.00126 Inf   0.444  1.0000
##  Block6 - Block10  0.000880 0.00126 Inf   0.698  0.9995
##  Block7 - Block8  -0.000181 0.00126 Inf  -0.143  1.0000
##  Block7 - Block9   0.000717 0.00126 Inf   0.569  0.9999
##  Block7 - Block10  0.001037 0.00126 Inf   0.822  0.9983
##  Block8 - Block9   0.000898 0.00126 Inf   0.712  0.9994
##  Block8 - Block10  0.001218 0.00126 Inf   0.966  0.9941
##  Block9 - Block10  0.000320 0.00126 Inf   0.254  1.0000
## 
## Degrees-of-freedom method: asymptotic 
## P value adjustment: tukey method for comparing a family of 10 estimates

Fastest: 6, 15, 28 Slowest: 26, 23, 35

block_10_data <- execution_data_acc %>% filter(Block ==10)

# Calculate mean trial_total_rt and mean trial_acc for each participant
summary_stats <- block_10_data %>%
  group_by(Subject) %>%
  summarise(mean_total_rt = mean(trial_total_rt, na.rm = TRUE),
            mean_trial_acc = mean(trial_acc, na.rm = TRUE))

# Rank participants by mean_total_rt
ranked_by_rt <- summary_stats %>%
  arrange(mean_total_rt) %>%
  mutate(rank_by_rt = row_number())

# Print the ranked list by response time
print(ranked_by_rt)
## # A tibble: 22 × 4
##    Subject mean_total_rt mean_trial_acc rank_by_rt
##    <chr>           <dbl>          <dbl>      <int>
##  1 6                913.              1          1
##  2 15              1343.              1          2
##  3 28              1352.              1          3
##  4 16              1512.              1          4
##  5 27              1535.              1          5
##  6 11              1636               1          6
##  7 24              1683.              1          7
##  8 19              1709.              1          8
##  9 34              2116.              1          9
## 10 22              2219.              1         10
## # ℹ 12 more rows
# Rank participants by mean_trial_acc
ranked_by_acc <- summary_stats %>%
  arrange(desc(mean_trial_acc)) %>%
  mutate(rank_by_acc = row_number())

# Print the ranked list by accuracy
print(ranked_by_acc)
## # A tibble: 22 × 4
##    Subject mean_total_rt mean_trial_acc rank_by_acc
##    <chr>           <dbl>          <dbl>       <int>
##  1 11              1636               1           1
##  2 12              2660.              1           2
##  3 13              3048.              1           3
##  4 14              3314.              1           4
##  5 15              1343.              1           5
##  6 16              1512.              1           6
##  7 19              1709.              1           7
##  8 22              2219.              1           8
##  9 23              3897.              1           9
## 10 24              1683.              1          10
## # ℹ 12 more rows
# Create the data frame
data <- data.frame(
  Participant = factor(c("Subject 6", "Subject 15", "Subject 28", "Subject 26", "Subject 23", "Subject 35"), 
                       levels = c("Subject 6", "Subject 15", "Subject 28", "Subject 26", "Subject 23", "Subject 35")),
  Mean_Total_RT = c(913.07, 1342.83, 1352.37, 3708.68, 3896.67, 4534.33),
  Group = c("Fastest", "Fastest", "Fastest", "Slowest", "Slowest", "Slowest")
)

# Create the plot
plot <- ggplot(data, aes(x = Participant, y = Mean_Total_RT, fill = Group)) +
  geom_bar(stat = "identity", position = position_dodge()) +
  geom_text(aes(label = paste(Mean_Total_RT, "ms"), fontface="bold"), vjust = -0.3, size = 3.5) +
  labs(x = "Participant",
       y = "Mean Total Trial RT (ms)") +
  scale_fill_manual(values = c("Fastest" = "aquamarine4", "Slowest" = "darkorchid4")) +
  theme_minimal() +
  theme(
    plot.title = element_blank(),
    axis.title.x = element_text(face = "bold"),
    axis.title.y = element_text(face = "bold")
  )

# Print the plot
print(plot)

Accuracy of those Participants

# Filter data for subjects
filtered_data <- execution_data %>%
  filter(Subject %in% c(6, 15, 28, 26, 23, 35))

# Compute accuracy as the proportion of successful trials (trial_acc == 1) by Subject and Block
accuracy_data <- filtered_data %>%
  group_by(Subject, Block) %>%
  summarise(
    Total_Trials = n(),
    Success_Trials = sum(trial_acc == 1),
    Accuracy = Success_Trials / Total_Trials * 100
  )
## `summarise()` has grouped output by 'Subject'. You can override using the
## `.groups` argument.
# View the computed accuracies
print(accuracy_data)
## # A tibble: 60 × 5
## # Groups:   Subject [6]
##    Subject Block Total_Trials Success_Trials Accuracy
##    <chr>   <ord>        <int>          <int>    <dbl>
##  1 15      1               48             37     77.1
##  2 15      2               48             43     89.6
##  3 15      3               48             43     89.6
##  4 15      4               48             46     95.8
##  5 15      5               48             40     83.3
##  6 15      6               48             41     85.4
##  7 15      7               48             39     81.2
##  8 15      8               48             41     85.4
##  9 15      9               48             40     83.3
## 10 15      10              48             46     95.8
## # ℹ 50 more rows
# Compute average accuracy across all blocks for each participant
average_accuracy <- accuracy_data %>%
  group_by(Subject) %>%
  summarise(
    Average_Accuracy = mean(Accuracy)
  )

# View the average accuracies
print(average_accuracy)
## # A tibble: 6 × 2
##   Subject Average_Accuracy
##   <chr>              <dbl>
## 1 15                  86.7
## 2 23                  95.6
## 3 26                  92.9
## 4 28                  96.0
## 5 35                  87.1
## 6 6                   84.2
filtered_data <- execution_data %>%
  filter(Subject %in% c(6, 15, 28, 35, 26, 23)) %>%
  filter(Block == 1) %>%
  mutate(Group = ifelse(Subject %in% c(6, 15, 28), "Fast", "Slow"))

filtered_data2 <- execution_data %>%
  filter(Subject %in% c(6, 15, 28, 35, 26, 23)) %>%
  filter(Block == 9) %>%
  mutate(Group = ifelse(Subject %in% c(6, 15, 28), "Fast", "Slow"))

filtered_data3 <- execution_data %>%
  filter(Subject %in% c(6, 15, 28, 35, 26, 23)) %>%
  filter(Block == 10) %>%
  mutate(Group = ifelse(Subject %in% c(6, 15, 28), "Fast", "Slow"))

filtered_data4 <- preparation_data %>%
  filter(Subject %in% c(6, 15, 28, 35, 26, 23)) %>%
  filter(Block == 1) %>%
  mutate(Group = ifelse(Subject %in% c(6, 15, 28), "Fast", "Slow"))

filtered_data5 <- preparation_data %>%
  filter(Subject %in% c(6, 15, 28, 35, 26, 23)) %>%
  filter(Block == 9) %>%
  mutate(Group = ifelse(Subject %in% c(6, 15, 28), "Fast", "Slow"))

filtered_data6 <- preparation_data %>%
  filter(Subject %in% c(6, 15, 28, 35, 26, 23)) %>%
  filter(Block == 10) %>%
  mutate(Group = ifelse(Subject %in% c(6, 15, 28), "Fast", "Slow"))
# Sequence Execution Period - Block 1
model <- lmer(hurst_acceleration_x ~ Group + (1 | Subject), data = filtered_data)
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##          Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.0037696 0.0037696     1     4  0.8172 0.4171
model <- lmer(hurst_acceleration_y ~ Group + (1 | Subject), data = filtered_data)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group + (1 | Subject)
##    Data: filtered_data
## 
## REML criterion at convergence: -589.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.7015  0.0055  0.0178  0.0297  3.9292 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.017834 0.13354 
##  Residual             0.006719 0.08197 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   0.8863     0.0774 4.0000  11.451 0.000332 ***
## GroupSlow     0.1047     0.1095 4.0000   0.957 0.392865    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##          Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.0061508 0.0061508     1     4  0.9154 0.3929
model <- lmer(hurst_acceleration_z ~ Group + (1 | Subject), data = filtered_data)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group + (1 | Subject)
##    Data: filtered_data
## 
## REML criterion at convergence: -1031.7
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -13.2161   0.0126   0.0474   0.0835   0.4660 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Subject  (Intercept) 5.726e-05 0.007567
##  Residual             1.512e-03 0.038881
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  0.994768   0.005439  4.000000 182.887 5.36e-09 ***
## GroupSlow   -0.005979   0.007692  4.000000  -0.777     0.48    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##           Sum Sq    Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.00091338 0.00091338     1     4  0.6042 0.4804
# Sequence Execution Period - Block 9
model <- lmer(hurst_acceleration_x ~ Group + (1 | Subject), data = filtered_data2)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group + (1 | Subject)
##    Data: filtered_data2
## 
## REML criterion at convergence: -659.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.1809 -0.0048  0.0049  0.0840  3.3631 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.012518 0.1119  
##  Residual             0.005271 0.0726  
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  0.81572    0.06488 4.00000  12.573  0.00023 ***
## GroupSlow    0.17847    0.09175 4.00000   1.945  0.12364    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##         Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.019945 0.019945     1     4  3.7836 0.1236
model <- lmer(hurst_acceleration_y ~ Group + (1 | Subject), data = filtered_data2)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group + (1 | Subject)
##    Data: filtered_data2
## 
## REML criterion at convergence: -612.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8535 -0.0038  0.0106  0.0288  3.1364 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.013895 0.11788 
##  Residual             0.006216 0.07884 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  0.80293    0.06837 4.00000  11.744 0.000301 ***
## GroupSlow    0.19285    0.09669 4.00000   1.994 0.116851    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##         Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.024727 0.024727     1     4   3.978 0.1169
model <- lmer(hurst_acceleration_z ~ Group + (1 | Subject), data = filtered_data2)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group + (1 | Subject)
##    Data: filtered_data2
## 
## REML criterion at convergence: -1252.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -9.5784 -0.0018  0.0287  0.0559  2.0123 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Subject  (Intercept) 0.0004699 0.02168 
##  Residual             0.0006739 0.02596 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  0.96842    0.01270 4.00000  76.250 1.77e-07 ***
## GroupSlow    0.02764    0.01796 4.00000   1.539    0.199    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##          Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.0015961 0.0015961     1     4  2.3686 0.1986
# Sequence Execution Period - Block 10
model <- lmer(hurst_acceleration_x ~ Group + (1 | Subject), data = filtered_data3)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group + (1 | Subject)
##    Data: filtered_data3
## 
## REML criterion at convergence: -684.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.0970 -0.0134  0.0207  0.1979  3.2837 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.006801 0.08247 
##  Residual             0.004865 0.06975 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  0.85909    0.04797 4.00000  17.910 5.71e-05 ***
## GroupSlow    0.13255    0.06784 4.00000   1.954    0.122    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##         Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.018574 0.018574     1     4  3.8179 0.1224
model <- lmer(hurst_acceleration_y ~ Group + (1 | Subject), data = filtered_data3)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group + (1 | Subject)
##    Data: filtered_data3
## 
## REML criterion at convergence: -704.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.5938 -0.0034  0.0075  0.1555  4.7329 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.01343  0.11588 
##  Residual             0.00449  0.06701 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  0.85650    0.06714 4.00000  12.757 0.000218 ***
## GroupSlow    0.13645    0.09495 4.00000   1.437 0.224043    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##         Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.009274 0.009274     1     4  2.0654  0.224
model <- lmer(hurst_acceleration_z ~ Group + (1 | Subject), data = filtered_data3)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group + (1 | Subject)
##    Data: filtered_data3
## 
## REML criterion at convergence: -1154.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -9.5483  0.0054  0.0603  0.4014  1.1018 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Subject  (Intercept) 0.0001969 0.01403 
##  Residual             0.0009648 0.03106 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept) 0.975087   0.008505 4.000000 114.648 3.47e-08 ***
## GroupSlow   0.016889   0.012028 4.000000   1.404    0.233    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##          Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.0019021 0.0019021     1     4  1.9716  0.233
# Movement Preparation Period - Block 1
model <- lmer(hurst_acceleration_x ~ Group + (1 | Subject), data = filtered_data4)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group + (1 | Subject)
##    Data: filtered_data4
## 
## REML criterion at convergence: -375.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8495 -0.6289  0.3521  0.6333  2.1973 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.007256 0.08518 
##  Residual             0.014535 0.12056 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.87354    0.05019  4.00000  17.403  6.4e-05 ***
## GroupSlow   -0.03789    0.07099  4.00000  -0.534    0.622    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##         Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.004141 0.004141     1     4  0.2849 0.6218
model <- lmer(hurst_acceleration_y ~ Group + (1 | Subject), data = filtered_data4)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group + (1 | Subject)
##    Data: filtered_data4
## 
## REML criterion at convergence: -291.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.5275 -0.6136  0.2329  0.5544  2.2016 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.01078  0.1038  
##  Residual             0.01948  0.1396  
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.83383    0.06105  4.00000  13.658 0.000166 ***
## GroupSlow   -0.02882    0.08634  4.00000  -0.334 0.755293    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##          Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.0021707 0.0021707     1     4  0.1114 0.7553
model <- lmer(hurst_acceleration_z ~ Group + (1 | Subject), data = filtered_data4)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group + (1 | Subject)
##    Data: filtered_data4
## 
## REML criterion at convergence: -222.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9767 -0.6007  0.3586  0.5930  1.7903 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.01060  0.1030  
##  Residual             0.02486  0.1577  
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.83587    0.06089  4.00000  13.728 0.000163 ***
## GroupSlow   -0.04014    0.08611  4.00000  -0.466 0.665368    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##          Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
## Group 0.0054024 0.0054024     1     4  0.2173 0.6654
# Movement Preparation Period - Block 9
model <- lmer(hurst_acceleration_x ~ Group + (1 | Subject), data = filtered_data5)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group + (1 | Subject)
##    Data: filtered_data5
## 
## REML criterion at convergence: -457.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2435 -0.6456  0.2152  0.6517  2.4547 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.002552 0.05052 
##  Residual             0.011038 0.10506 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.91648    0.03045  4.00000  30.095 7.26e-06 ***
## GroupSlow   -0.12646    0.04307  4.00000  -2.936   0.0425 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##         Sum Sq  Mean Sq NumDF DenDF F value  Pr(>F)  
## Group 0.095171 0.095171     1     4  8.6224 0.04254 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model <- lmer(hurst_acceleration_y ~ Group + (1 | Subject), data = filtered_data5)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group + (1 | Subject)
##    Data: filtered_data5
## 
## REML criterion at convergence: -383.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9054 -0.6378  0.1432  0.6196  2.2454 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.002463 0.04963 
##  Residual             0.014345 0.11977 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.90182    0.03034  4.00000  29.724 7.63e-06 ***
## GroupSlow   -0.17326    0.04291  4.00000  -4.038   0.0156 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##       Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
## Group 0.2339  0.2339     1     4  16.305 0.01563 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model <- lmer(hurst_acceleration_z ~ Group + (1 | Subject), data = filtered_data5)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group + (1 | Subject)
##    Data: filtered_data5
## 
## REML criterion at convergence: -270.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2150 -0.6143  0.1575  0.4678  2.0743 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.005819 0.07628 
##  Residual             0.021172 0.14551 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.89652    0.04568  4.00000  19.626 3.98e-05 ***
## GroupSlow   -0.19257    0.06460  4.00000  -2.981   0.0407 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##        Sum Sq Mean Sq NumDF DenDF F value Pr(>F)  
## Group 0.18812 0.18812     1     4  8.8856 0.0407 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# Movement Preparation Period - Block 10
model <- lmer(hurst_acceleration_x ~ Group + (1 | Subject), data = filtered_data6)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group + (1 | Subject)
##    Data: filtered_data6
## 
## REML criterion at convergence: -436.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.9092 -0.5828  0.1531  0.5359  2.4489 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.002738 0.05232 
##  Residual             0.011876 0.10898 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.93090    0.03154  4.00000  29.512 7.85e-06 ***
## GroupSlow   -0.14290    0.04461  4.00000  -3.203   0.0328 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##        Sum Sq Mean Sq NumDF DenDF F value Pr(>F)  
## Group 0.12186 0.12186     1     4  10.261 0.0328 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model <- lmer(hurst_acceleration_y ~ Group + (1 | Subject), data = filtered_data6)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group + (1 | Subject)
##    Data: filtered_data6
## 
## REML criterion at convergence: -342.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.6091 -0.6421  0.1276  0.5117  2.3976 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.002039 0.04515 
##  Residual             0.016615 0.12890 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.90962    0.02819  4.00000  32.263  5.5e-06 ***
## GroupSlow   -0.18697    0.03987  4.00000  -4.689  0.00938 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##        Sum Sq Mean Sq NumDF DenDF F value   Pr(>F)   
## Group 0.36534 0.36534     1     4  21.989 0.009383 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model <- lmer(hurst_acceleration_z ~ Group + (1 | Subject), data = filtered_data6)
summary(model)  
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group + (1 | Subject)
##    Data: filtered_data6
## 
## REML criterion at convergence: -234.8
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.93995 -0.65482  0.09468  0.35049  2.17322 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.006358 0.07974 
##  Residual             0.023990 0.15489 
## Number of obs: 288, groups:  Subject, 6
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)  0.90593    0.04781  4.00000  18.948 4.57e-05 ***
## GroupSlow   -0.22457    0.06762  4.00000  -3.321   0.0293 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## GroupSlow -0.707
anova(model)
## Type III Analysis of Variance Table with Satterthwaite's method
##        Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
## Group 0.26463 0.26463     1     4  11.031 0.02934 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

‘Fast’ vs. ‘Slow’ Group Differences Plots

# Add a block identifier to each dataset
filtered_data <- filtered_data %>% mutate(Block = "Block 1")
filtered_data2 <- filtered_data2 %>% mutate(Block = "Block 9")
filtered_data3 <- filtered_data3 %>% mutate(Block = "Block 10")

# Combine the data into one data frame
combined_data <- bind_rows(filtered_data, filtered_data2, filtered_data3)

# Adjust the factor levels to control plot order
combined_data$Block <- factor(combined_data$Block, levels = c("Block 1", "Block 9", "Block 10"))

# Adjust the plot with larger and bold fonts
plot1 <- ggplot(combined_data, aes(x = Group, y = hurst_acceleration_x, fill = Group)) +
  geom_boxplot() +
  labs(subtitle = "Hurst Acceleration X",
       x = "Group",
       y = "Hurst Exponent") +
  theme_minimal() +
  scale_fill_manual(values = c("Fast" = "aquamarine4", "Slow" = "darkorchid4")) +
  facet_wrap(~Block) +
  theme(
    axis.text = element_text(size = 14, face = "bold"), 
    axis.text.x = element_text(angle = 45, hjust = 1, size = 14, face = "bold"), 
    axis.text.y = element_text(size = 14, face = "bold"),  
    axis.title = element_text(size = 16, face = "bold"), 
    plot.title = element_text(size = 24, face = "bold", hjust = 0.5),  
    plot.subtitle = element_text(size = 22, face = "bold", hjust = 0.5), 
    strip.text = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 18, face = "bold"),  
    legend.title = element_text(size = 20, face = "bold"),  
    legend.key.size = unit(3.5, "lines") 
  )

# Print the updated plot
print(plot1)

# Add a block identifier to each dataset
filtered_data <- filtered_data %>% mutate(Block = "Block 1")
filtered_data2 <- filtered_data2 %>% mutate(Block = "Block 9")
filtered_data3 <- filtered_data3 %>% mutate(Block = "Block 10")

# Combine the data into one data frame
combined_data <- bind_rows(filtered_data, filtered_data2, filtered_data3)

# Adjust the factor levels to control plot order
combined_data$Block <- factor(combined_data$Block, levels = c("Block 1", "Block 9", "Block 10"))

# Create the combined boxplot with the corrected order and larger font sizes
plot2 <- ggplot(combined_data, aes(x = Group, y = hurst_acceleration_y, fill = Group)) +
  geom_boxplot() +
  labs(subtitle = "Hurst Acceleration Y",
       x = "Group",
       y = "Hurst Exponent") +
  theme_minimal() +
  scale_fill_manual(values = c("Fast" = "aquamarine4", "Slow" = "darkorchid4")) +
  facet_wrap(~Block) +
  theme(
    axis.text = element_text(size = 14, face = "bold"), 
    axis.text.x = element_text(angle = 45, hjust = 1, size = 14, face = "bold"), 
    axis.text.y = element_text(size = 14, face = "bold"),  
    axis.title = element_text(size = 16, face = "bold"), 
    plot.title = element_text(size = 24, face = "bold", hjust = 0.5),  
    plot.subtitle = element_text(size = 22, face = "bold", hjust = 0.5), 
    strip.text = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 18, face = "bold"),  
    legend.title = element_text(size = 20, face = "bold"),  
    legend.key.size = unit(3.5, "lines") 
  )
print(plot2)

# Add a block identifier to each dataset
filtered_data <- filtered_data %>% mutate(Block = "Block 1")
filtered_data2 <- filtered_data2 %>% mutate(Block = "Block 9")
filtered_data3 <- filtered_data3 %>% mutate(Block = "Block 10")

# Combine the data into one data frame
combined_data <- bind_rows(filtered_data, filtered_data2, filtered_data3)

# Adjust the factor levels to control plot order
combined_data$Block <- factor(combined_data$Block, levels = c("Block 1", "Block 9", "Block 10"))

# Create the combined boxplot with the corrected order and larger font sizes
plot3 <- ggplot(combined_data, aes(x = Group, y = hurst_acceleration_z, fill = Group)) +
  geom_boxplot() +
  labs(subtitle = "Hurst Acceleration Z",
       x = "Group",
       y = "Hurst Exponent") +
  theme_minimal() +
  scale_fill_manual(values = c("Fast" = "aquamarine4", "Slow" = "darkorchid4")) +
  facet_wrap(~Block) +
  theme(
    axis.text = element_text(size = 14, face = "bold"), 
    axis.text.x = element_text(angle = 45, hjust = 1, size = 14, face = "bold"), 
    axis.text.y = element_text(size = 14, face = "bold"),  
    axis.title = element_text(size = 16, face = "bold"), 
    plot.title = element_text(size = 24, face = "bold", hjust = 0.5),  
    plot.subtitle = element_text(size = 22, face = "bold", hjust = 0.5), 
    strip.text = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 18, face = "bold"),  
    legend.title = element_text(size = 20, face = "bold"),  
    legend.key.size = unit(3.5, "lines") 
  )
print(plot3)

# Add a block identifier to each dataset
filtered_data4 <- filtered_data4 %>% mutate(Block = "Block 1")
filtered_data5 <- filtered_data5 %>% mutate(Block = "Block 9**")
filtered_data6 <- filtered_data6 %>% mutate(Block = "Block 10**")

# Combine the data into one data frame
combined_data <- bind_rows(filtered_data4, filtered_data5, filtered_data6)

# Adjust the factor levels to control plot order
combined_data$Block <- factor(combined_data$Block, levels = c("Block 1", "Block 9**", "Block 10**"))

# Create the combined boxplot with the corrected order and larger font sizes
plot4 <- ggplot(combined_data, aes(x = Group, y = hurst_acceleration_x, fill = Group)) +
  geom_boxplot() +
  labs(subtitle = "Hurst Acceleration X",
       x = "Group",
       y = "Hurst Exponent") +
  theme_minimal() +
  scale_fill_manual(values = c("Fast" = "aquamarine4", "Slow" = "darkorchid4")) +
  facet_wrap(~Block) +
  theme(
    axis.text = element_text(size = 14, face = "bold"), 
    axis.text.x = element_text(angle = 45, hjust = 1, size = 14, face = "bold"), 
    axis.text.y = element_text(size = 14, face = "bold"),  
    axis.title = element_text(size = 16, face = "bold"), 
    plot.title = element_text(size = 24, face = "bold", hjust = 0.5),  
    plot.subtitle = element_text(size = 22, face = "bold", hjust = 0.5), 
    strip.text = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 18, face = "bold"),  
    legend.title = element_text(size = 20, face = "bold"),  
    legend.key.size = unit(3.5, "lines") 
  )
print(plot4)

# Add a block identifier to each dataset
filtered_data4 <- filtered_data4 %>% mutate(Block = "Block 1")
filtered_data5 <- filtered_data5 %>% mutate(Block = "Block 9**")
filtered_data6 <- filtered_data6 %>% mutate(Block = "Block 10**")

# Combine the data into one data frame
combined_data <- bind_rows(filtered_data4, filtered_data5, filtered_data6)

# Adjust the factor levels to control plot order
combined_data$Block <- factor(combined_data$Block, levels = c("Block 1", "Block 9**", "Block 10**"))

# Create the combined boxplot with the corrected order and larger font sizes
plot5 <- ggplot(combined_data, aes(x = Group, y = hurst_acceleration_y, fill = Group)) +
  geom_boxplot() +
  labs(subtitle = "Hurst Acceleration Y",
       x = "Group",
       y = "Hurst Exponent") +
  theme_minimal() +
  scale_fill_manual(values = c("Fast" = "aquamarine4", "Slow" = "darkorchid4")) +
  facet_wrap(~Block) +
   theme(
    axis.text = element_text(size = 14, face = "bold"), 
    axis.text.x = element_text(angle = 45, hjust = 1, size = 14, face = "bold"), 
    axis.text.y = element_text(size = 14, face = "bold"),  
    axis.title = element_text(size = 16, face = "bold"), 
    plot.title = element_text(size = 24, face = "bold", hjust = 0.5),  
    plot.subtitle = element_text(size = 22, face = "bold", hjust = 0.5), 
    strip.text = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 18, face = "bold"),  
    legend.title = element_text(size = 20, face = "bold"),  
    legend.key.size = unit(3.5, "lines") 
  )
print(plot5)

# Add a block identifier to each dataset
filtered_data4 <- filtered_data4 %>% mutate(Block = "Block 1")
filtered_data5 <- filtered_data5 %>% mutate(Block = "Block 9**")
filtered_data6 <- filtered_data6 %>% mutate(Block = "Block 10**")

# Combine the data into one data frame
combined_data <- bind_rows(filtered_data4, filtered_data5, filtered_data6)

# Adjust the factor levels to control plot order
combined_data$Block <- factor(combined_data$Block, levels = c("Block 1", "Block 9**", "Block 10**"))

# Create the combined boxplot with the corrected order and larger font sizes
plot6 <- ggplot(combined_data, aes(x = Group, y = hurst_acceleration_z, fill = Group)) +
  geom_boxplot() +
  labs(subtitle = "Hurst Acceleration Z",
       x = "Group",
       y = "Hurst Exponent") +
  theme_minimal() +
  scale_fill_manual(values = c("Fast" = "aquamarine4", "Slow" = "darkorchid4")) +
  facet_wrap(~Block) +
  theme(
    axis.text = element_text(size = 14, face = "bold"), 
    axis.text.x = element_text(angle = 45, hjust = 1, size = 14, face = "bold"), 
    axis.text.y = element_text(size = 14, face = "bold"),  
    axis.title = element_text(size = 16, face = "bold"), 
    plot.title = element_text(size = 24, face = "bold", hjust = 0.5),  
    plot.subtitle = element_text(size = 22, face = "bold", hjust = 0.5), 
    strip.text = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 18, face = "bold"),  
    legend.title = element_text(size = 20, face = "bold"),  
    legend.key.size = unit(3.5, "lines") 
  )
print(plot6)

RT Trajectory Plot

# Filter data for subjects 6, 15, 28, 26, 23, and 35
filtered_data <- execution_data %>%
  filter(Subject %in% c(6, 15, 28, 26, 23, 35))

# Calculate the mean of trial_total_rt for each subject within each block
mean_rt_data <- filtered_data %>%
  group_by(Subject, Block) %>%
  summarise(
    Mean_RT = mean(trial_total_rt, na.rm = TRUE),
    .groups = 'drop'
  )

# Plotting the trajectory of response times across blocks
rt_plot <- ggplot(mean_rt_data, aes(x = Block, y = Mean_RT, group = Subject, color = as.factor(Subject))) +
  geom_smooth(se = FALSE, size = 2) +
  labs(title = "Trajectory of Response Times Across Blocks",
       x = "Block",
       y = "Mean Response Time (ms)",
       color = "Participant") +
  theme_minimal() +
  scale_color_manual(values = c("brown3", "cornflowerblue", "chartreuse3", "darkmagenta", "darkorange", "aquamarine2"))

# Print the plot
print(rt_plot)
## `geom_smooth()` using method = 'loess' and formula = 'y ~ x'

# Specify the participants
participants <- c(6, 15, 28, 26, 23, 35)

# Filter trial_data for sequence execution period
filtered_execution <- execution_data %>%
  filter(Subject %in% participants) %>%
  group_by(Subject, Block) %>%
  summarise(
    Mean_Hurst_X = mean(hurst_acceleration_x, na.rm = TRUE),
    Mean_Hurst_Y = mean(hurst_acceleration_y, na.rm = TRUE),
    Mean_Hurst_Z = mean(hurst_acceleration_z, na.rm = TRUE),
    .groups = 'drop'
  )

# Filter trial_data2 for movement preparation period
filtered_preparation <- preparation_data %>%
  filter(Subject %in% participants) %>%
  group_by(Subject, Block) %>%
  summarise(
    Mean_Hurst_X = mean(hurst_acceleration_x, na.rm = TRUE),
    Mean_Hurst_Y = mean(hurst_acceleration_y, na.rm = TRUE),
    Mean_Hurst_Z = mean(hurst_acceleration_z, na.rm = TRUE),
    .groups = 'drop'
  )

# Plotting trajectory for each axis in the execution period
for(axis in c("X", "Y", "Z")) {
  plot <- ggplot(filtered_execution, aes(x = Block, y = get(paste0("Mean_Hurst_", axis)), group = Subject, color = as.factor(Subject))) +
    geom_smooth(se = TRUE, method = "loess", size = 2) +
    labs(title = paste("Execution Period -", axis, "Axis"),
         x = "Block",
         y = "Mean Hurst Exponent",
         color = "Participant") +
    theme_minimal() +
    scale_color_manual(values = c("brown3", "cornflowerblue", "chartreuse3", "darkmagenta", "darkorange", "aquamarine2")) +
    theme(
      text = element_text(size = 14, face = "bold"),
      axis.title = element_text(size = 16, face = "bold"),
      plot.title = element_text(size = 20, face = "bold"),
      legend.text = element_text(size = 14, face = "bold"),
      legend.title = element_text(size = 16, face = "bold"),
      strip.text = element_text(size = 16, face = "bold")
    )
  
  print(plot)
}
## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

# Plotting trajectory for each axis in the preparation period
for(axis in c("X", "Y", "Z")) {
  plot <- ggplot(filtered_preparation, aes(x = Block, y = get(paste0("Mean_Hurst_", axis)), group = Subject, color = as.factor(Subject))) +
    geom_smooth(se = TRUE, method = "loess", size = 2) +
    labs(title = paste("Preparation Period -", axis, "Axis"),
         x = "Block",
         y = "Mean Hurst Exponent",
         color = "Participant") +
    theme_minimal() +
    scale_color_manual(values = c("brown3", "cornflowerblue", "chartreuse3", "darkmagenta", "darkorange", "aquamarine2")) +
    theme(
      text = element_text(size = 14, face = "bold"),
      axis.title = element_text(size = 16, face = "bold"),
      plot.title = element_text(size = 20, face = "bold"),
      legend.text = element_text(size = 14, face = "bold"),
      legend.title = element_text(size = 16, face = "bold"),
      strip.text = element_text(size = 16, face = "bold")
    )
  
  print(plot)
}
## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

## `geom_smooth()` using formula = 'y ~ x'

Comparison between Mean Hurst Exponents in Sequence Execution Phase for Top 50% of Accurate Performers and Bottom 50% of Accurate Performers

# Calculate overall accuracy
overall_accuracy <- execution_data %>%
  group_by(Subject) %>%
  summarize(Accuracy = mean(trial_acc, na.rm = TRUE))

mean_hurst <- execution_data %>%
  group_by(Subject) %>%
  summarize(
    Mean_Hurst_X = mean(hurst_acceleration_x, na.rm = TRUE),
    Mean_Hurst_Y = mean(hurst_acceleration_y, na.rm = TRUE),
    Mean_Hurst_Z = mean(hurst_acceleration_z, na.rm = TRUE)
  )

# Merge the two data frames
participant_data <- merge(overall_accuracy, mean_hurst, by = "Subject")

# Sort and find the median accuracy
sorted_data <- participant_data %>%
  arrange(desc(Accuracy))

# Split into top 50% and bottom 50%
top_50 <- sorted_data[1:11, ]
bottom_50 <- sorted_data[12:22, ]

# Prepare data for plotting
plot_data <- bind_rows(
  mutate(top_50, Group = "Top 50%"),
  mutate(bottom_50, Group = "Bottom 50%")
)
# Plot for Hurst Exponent X
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_X, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent X during Sequence Execution - Accuracy", y = "Hurst Exponent X", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Y
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Y, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Y during Sequence Execution - Accuracy", y = "Hurst Exponent Y", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Z
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Z, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Z during Sequence Execution - Accuracy", y = "Hurst Exponent Z", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

Comparison between Mean Hurst Exponents in Sequence Execution Phase for Top 50% of the fastest Performers and Bottom 50%

# Calculate overall speed
overall_speed <- execution_data_filtered %>%
  group_by(Subject) %>%
  summarize(Speed = mean(trial_total_rt, na.rm = TRUE))

mean_hurst <- preparation_data %>%
  group_by(Subject) %>%
  summarize(
    Mean_Hurst_X = mean(hurst_acceleration_x, na.rm = TRUE),
    Mean_Hurst_Y = mean(hurst_acceleration_y, na.rm = TRUE),
    Mean_Hurst_Z = mean(hurst_acceleration_z, na.rm = TRUE)
  )

# Merge the two data frames
participant_data <- merge(overall_speed, mean_hurst, by = "Subject")

# Sort and find the median accuracy
sorted_data <- participant_data %>%
  arrange(desc(Speed))

# Split into top 50% and bottom 50%
top_50 <- sorted_data[1:11, ]
bottom_50 <- sorted_data[12:22, ]

# Prepare data for plotting
plot_data <- bind_rows(
  mutate(top_50, Group = "Top 50%"),
  mutate(bottom_50, Group = "Bottom 50%")
)

# Plot for Hurst Exponent X
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_X, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent X during Sequence Execution - Speed", y = "Hurst Exponent X", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Y
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Y, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Y during Sequence Execution - Speed", y = "Hurst Exponent Y", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Z
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Z, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Z during Sequence Execution - Speed", y = "Hurst Exponent Z", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

shapiro.test(top_50$Mean_Hurst_X)
## 
##  Shapiro-Wilk normality test
## 
## data:  top_50$Mean_Hurst_X
## W = 0.96794, p-value = 0.865
shapiro.test(bottom_50$Mean_Hurst_X)
## 
##  Shapiro-Wilk normality test
## 
## data:  bottom_50$Mean_Hurst_X
## W = 0.87221, p-value = 0.08275
shapiro.test(top_50$Mean_Hurst_Y)
## 
##  Shapiro-Wilk normality test
## 
## data:  top_50$Mean_Hurst_Y
## W = 0.96188, p-value = 0.7949
shapiro.test(bottom_50$Mean_Hurst_Y)
## 
##  Shapiro-Wilk normality test
## 
## data:  bottom_50$Mean_Hurst_Y
## W = 0.96222, p-value = 0.7991
shapiro.test(top_50$Mean_Hurst_Z)
## 
##  Shapiro-Wilk normality test
## 
## data:  top_50$Mean_Hurst_Z
## W = 0.9308, p-value = 0.419
shapiro.test(bottom_50$Mean_Hurst_Z)
## 
##  Shapiro-Wilk normality test
## 
## data:  bottom_50$Mean_Hurst_Z
## W = 0.91863, p-value = 0.3074
# Mann-Whitney U Test for Hurst Exponent X
wilcox.test(top_50$Mean_Hurst_X, bottom_50$Mean_Hurst_X)
## 
##  Wilcoxon rank sum exact test
## 
## data:  top_50$Mean_Hurst_X and bottom_50$Mean_Hurst_X
## W = 31, p-value = 0.05567
## alternative hypothesis: true location shift is not equal to 0
# Mann-Whitney U Test for Hurst Exponent Y
wilcox.test(top_50$Mean_Hurst_Y, bottom_50$Mean_Hurst_Y)
## 
##  Wilcoxon rank sum exact test
## 
## data:  top_50$Mean_Hurst_Y and bottom_50$Mean_Hurst_Y
## W = 31, p-value = 0.05567
## alternative hypothesis: true location shift is not equal to 0
# Mann-Whitney U Test for Hurst Exponent Z
wilcox.test(top_50$Mean_Hurst_Z, bottom_50$Mean_Hurst_Z)
## 
##  Wilcoxon rank sum exact test
## 
## data:  top_50$Mean_Hurst_Z and bottom_50$Mean_Hurst_Z
## W = 25, p-value = 0.01923
## alternative hypothesis: true location shift is not equal to 0

Comparison between Mean Hurst Exponents in Movement Preparation Phase for Top 50% of Accurate Performers and Bottom 50% of Accurate Performers

# Calculate overall accuracy
overall_accuracy <- preparation_data %>%
  group_by(Subject) %>%
  summarize(Accuracy = mean(trial_acc, na.rm = TRUE))

mean_hurst <- preparation_data %>%
  group_by(Subject) %>%
  summarize(
    Mean_Hurst_X = mean(hurst_acceleration_x, na.rm = TRUE),
    Mean_Hurst_Y = mean(hurst_acceleration_y, na.rm = TRUE),
    Mean_Hurst_Z = mean(hurst_acceleration_z, na.rm = TRUE)
  )

# Merge the two data frames
participant_data <- merge(overall_accuracy, mean_hurst, by = "Subject")

# Sort and find the median accuracy
sorted_data <- participant_data %>%
  arrange(desc(Accuracy))

# Split into top 50% and bottom 50%
top_50 <- sorted_data[1:11, ]
bottom_50 <- sorted_data[12:22, ]

# Prepare data for plotting
plot_data <- bind_rows(
  mutate(top_50, Group = "Top 50%"),
  mutate(bottom_50, Group = "Bottom 50%")
)

# Plot for Hurst Exponent X
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_X, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent X during Movement Preparation - Accuracy", y = "Hurst Exponent X", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Y
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Y, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Y during Movement Preparation - Accuracy", y = "Hurst Exponent Y", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Z
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Z, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Z during Movement Preparation - Accuracy", y = "Hurst Exponent Z", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

Comparison between Mean Hurst Exponents in Movement Preparation Phase for Top 50% of the fastest Performers and Bottom 50%

# Calculate overall Speed
overall_speed <- preparation_data_filtered %>%
  group_by(Subject) %>%
  summarize(Speed = mean(trial_total_rt, na.rm = TRUE))

mean_hurst <- preparation_data %>%
  group_by(Subject) %>%
  summarize(
    Mean_Hurst_X = mean(hurst_acceleration_x, na.rm = TRUE),
    Mean_Hurst_Y = mean(hurst_acceleration_y, na.rm = TRUE),
    Mean_Hurst_Z = mean(hurst_acceleration_z, na.rm = TRUE)
  )

# Merge the two data frames
participant_data <- merge(overall_speed, mean_hurst, by = "Subject")

# Sort and find the median accuracy
sorted_data <- participant_data %>%
  arrange(desc(Speed))

# Split into top 50% and bottom 50%
top_50 <- sorted_data[1:11, ]
bottom_50 <- sorted_data[12:22, ]

# Prepare data for plotting
plot_data <- bind_rows(
  mutate(top_50, Group = "Top 50%"),
  mutate(bottom_50, Group = "Bottom 50%")
)

# Plot for Hurst Exponent X
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_X, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent X during Movement Preparation - Speed", y = "Hurst Exponent X", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Y
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Y, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Y during Movement Preparation - Speed", y = "Hurst Exponent Y", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()

# Plot for Hurst Exponent Z
ggplot(plot_data, aes(x = Group, y = Mean_Hurst_Z, fill = Group)) +
  geom_boxplot() +
  labs(title = "Comparison of Hurst Exponent Z during Movement Preparation - Speed", y = "Hurst Exponent Z", x = "") +
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "darkorchid4")) +
  theme_minimal()