##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(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(emmeans)
library(ggsignif)
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(ggtext)
library(ggplot2)
#Load datasets
setwd("C:/Users/Marcel/Desktop/R Scripts Thesis/Sequence Execution Period")

# Load the trial_data
execution_data <- read_excel("trial_data_execution.xlsx")

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)

# Create subset with only accurate trials
execution_data_acc <- execution_data %>% filter(trial_acc == 1)
#Load datasets
setwd("C:/Users/Marcel/Desktop/R Scripts Thesis/Movement Preparation Period")

# Load the trial_data
preparation_data <- read_excel("trial_data_preparation.xlsx")

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)

# Create subset with only include accurate trials
preparation_data_acc <- preparation_data %>% filter(trial_acc == 1)

Grouped by Speed and Accuracy - Preparation Phase Stats

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

# Calculate average response time per participant and rank them
top_50_rt_accurate_and_fast <- block_10_accurate_and_fast %>%
  group_by(Subject) %>%
  summarise(avg_rt = mean(trial_total_rt)) %>%
  mutate(rank = rank(avg_rt, ties.method = "first")) %>%  # Lower avg_rt gets lower rank (better)
  mutate(Group = ifelse(rank <= n() * 0.5, "Top 50%", "Bottom 50%"))

# Extract list of top 50% subjects
top_50_speed_acc_subjects <- top_50_rt_accurate_and_fast %>%
  filter(Group == "Top 50%") %>%
  pull(Subject)

# Apply speed/accuracy labels to execution_data_grouped_by_speed_and_accuracy
execution_data_grouped_by_speed_and_accuracy <- execution_data %>%
  mutate(Group = ifelse(Subject %in% top_50_speed_acc_subjects, "Top 50%", "Bottom 50%"))

# Apply speed/accuracy labels to preparation_data_grouped_by_speed_and_accuracy
preparation_data_grouped_by_speed_and_accuracy <- preparation_data %>%
  mutate(Group = ifelse(Subject %in% top_50_speed_acc_subjects, "Top 50%", "Bottom 50%"))



preparation_data_grouped_by_speed_and_accuracy$Block <- factor(preparation_data_grouped_by_speed_and_accuracy$Block, 
                                                levels = c("1", "9", "10"), 
                                                ordered = FALSE)

model_x <- lmer(hurst_acceleration_x ~ Group * Block + (1 | Subject), 
                data = preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))

summary(model_x)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group * Block + (1 | Subject)
##    Data: preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in%  
##     c(1, 9, 10))
## 
## REML criterion at convergence: -4578.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.8732 -0.5402  0.2554  0.6752  2.3404 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.003584 0.05987 
##  Residual             0.013286 0.11526 
## Number of obs: 3168, groups:  Subject, 22
## 
## Fixed effects:
##                       Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)          8.461e-01  1.873e-02 2.206e+01  45.162  < 2e-16 ***
## GroupTop 50%         4.203e-02  2.649e-02 2.206e+01   1.586  0.12691    
## Block9               8.661e-03  7.094e-03 3.142e+03   1.221  0.22221    
## Block10              1.000e-02  7.094e-03 3.142e+03   1.410  0.15874    
## GroupTop 50%:Block9  2.321e-02  1.003e-02 3.142e+03   2.314  0.02075 *  
## GroupTop 50%:Block10 2.858e-02  1.003e-02 3.142e+03   2.849  0.00441 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) GrT50% Block9 Blck10 GT50%:B9
## GroupTop50% -0.707                              
## Block9      -0.189  0.134                       
## Block10     -0.189  0.134  0.500                
## GrpT50%:Bl9  0.134 -0.189 -0.707 -0.354         
## GrpT50%:B10  0.134 -0.189 -0.354 -0.707  0.500
anova(model_x)
## Type III Analysis of Variance Table with Satterthwaite's method
##              Sum Sq  Mean Sq NumDF DenDF F value    Pr(>F)    
## Group       0.06988 0.069880     1    20  5.2598   0.03279 *  
## Block       0.35801 0.179006     2  3142 13.4737 1.491e-06 ***
## Group:Block 0.12186 0.060929     2  3142  4.5861   0.01026 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_obj <- emmeans(model_x, ~ Group | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3168' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3168)' 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 = 3168' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3168)' or larger];
## but be warned that this may result in large computation time and memory use.
group_block_comparisons <- contrast(emmeans_obj, method = "pairwise")
summary(group_block_comparisons)
## Block = 1:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%  -0.0420 0.0265 Inf  -1.586  0.1127
## 
## Block = 9:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%  -0.0652 0.0265 Inf  -2.462  0.0138
## 
## Block = 10:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%  -0.0706 0.0265 Inf  -2.665  0.0077
## 
## Degrees-of-freedom method: asymptotic
model_y <- lmer(hurst_acceleration_y ~ Group * Block + (1 | Subject), 
                data = preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))

summary(model_y)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group * Block + (1 | Subject)
##    Data: preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in%  
##     c(1, 9, 10))
## 
## REML criterion at convergence: -3797.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -5.2622 -0.6029  0.2574  0.6848  2.4662 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.004746 0.06889 
##  Residual             0.017003 0.13039 
## Number of obs: 3168, groups:  Subject, 22
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)           8.191e-01  2.153e-02  2.199e+01  38.042  < 2e-16 ***
## GroupTop 50%          4.561e-02  3.045e-02  2.199e+01   1.498  0.14842    
## Block9               -1.860e-03  8.025e-03  3.142e+03  -0.232  0.81677    
## Block10               7.442e-03  8.025e-03  3.142e+03   0.927  0.35381    
## GroupTop 50%:Block9   3.117e-02  1.135e-02  3.142e+03   2.746  0.00606 ** 
## GroupTop 50%:Block10  2.369e-02  1.135e-02  3.142e+03   2.088  0.03692 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) GrT50% Block9 Blck10 GT50%:B9
## GroupTop50% -0.707                              
## Block9      -0.186  0.132                       
## Block10     -0.186  0.132  0.500                
## GrpT50%:Bl9  0.132 -0.186 -0.707 -0.354         
## GrpT50%:B10  0.132 -0.186 -0.354 -0.707  0.500
anova(model_y)
## Type III Analysis of Variance Table with Satterthwaite's method
##               Sum Sq  Mean Sq NumDF DenDF F value   Pr(>F)   
## Group       0.078494 0.078494     1    20  4.6166 0.044091 * 
## Block       0.208160 0.104080     2  3142  6.1214 0.002222 **
## Group:Block 0.139806 0.069903     2  3142  4.1113 0.016475 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_obj <- emmeans(model_y, ~ Group | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3168' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3168)' 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 = 3168' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3168)' or larger];
## but be warned that this may result in large computation time and memory use.
group_block_comparisons <- contrast(emmeans_obj, method = "pairwise")
summary(group_block_comparisons)
## Block = 1:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%  -0.0456 0.0305 Inf  -1.498  0.1342
## 
## Block = 9:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%  -0.0768 0.0305 Inf  -2.521  0.0117
## 
## Block = 10:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%  -0.0693 0.0305 Inf  -2.276  0.0229
## 
## Degrees-of-freedom method: asymptotic
model_z <- lmer(hurst_acceleration_z ~ Group * Block + (1 | Subject), 
                data = preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))

summary(model_z)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group * Block + (1 | Subject)
##    Data: preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in%  
##     c(1, 9, 10))
## 
## REML criterion at convergence: -3026.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.6613 -0.5348  0.2198  0.5697  2.0304 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.006773 0.0823  
##  Residual             0.021687 0.1473  
## Number of obs: 3168, groups:  Subject, 22
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)           8.022e-01  2.563e-02  2.178e+01  31.301  < 2e-16 ***
## GroupTop 50%          7.597e-02  3.624e-02  2.178e+01   2.096  0.04791 *  
## Block9               -9.044e-03  9.064e-03  3.142e+03  -0.998  0.31842    
## Block10               3.550e-03  9.064e-03  3.142e+03   0.392  0.69529    
## GroupTop 50%:Block9   3.349e-02  1.282e-02  3.142e+03   2.613  0.00903 ** 
## GroupTop 50%:Block10  2.609e-02  1.282e-02  3.142e+03   2.035  0.04191 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) GrT50% Block9 Blck10 GT50%:B9
## GroupTop50% -0.707                              
## Block9      -0.177  0.125                       
## Block10     -0.177  0.125  0.500                
## GrpT50%:Bl9  0.125 -0.177 -0.707 -0.354         
## GrpT50%:B10  0.125 -0.177 -0.354 -0.707  0.500
anova(model_z)
## Type III Analysis of Variance Table with Satterthwaite's method
##              Sum Sq  Mean Sq NumDF DenDF F value  Pr(>F)  
## Group       0.15822 0.158220     1    20  7.2956 0.01375 *
## Block       0.14565 0.072823     2  3142  3.3579 0.03493 *
## Group:Block 0.16339 0.081693     2  3142  3.7669 0.02323 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_obj <- emmeans(model_z, ~ Group | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3168' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3168)' 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 = 3168' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3168)' or larger];
## but be warned that this may result in large computation time and memory use.
group_block_comparisons <- contrast(emmeans_obj, method = "pairwise")
summary(group_block_comparisons)
## Block = 1:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   -0.076 0.0362 Inf  -2.096  0.0361
## 
## Block = 9:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   -0.109 0.0362 Inf  -3.020  0.0025
## 
## Block = 10:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   -0.102 0.0362 Inf  -2.816  0.0049
## 
## Degrees-of-freedom method: asymptotic
model_x <- lmer(hurst_acceleration_x ~ Group * Block + (1 | Subject), 
                data = preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))
model_y <- lmer(hurst_acceleration_y ~ Group * Block + (1 | Subject), 
                data = preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))
model_z <- lmer(hurst_acceleration_z ~ Group * Block + (1 | Subject), 
                data = preparation_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))


get_model_effects_df <- function(model) {

  model_effects <- allEffects(model)
  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
  
  return(model_effects_df)
}

# Apply the function to the three models (X, Y, Z)
model_x_effects_df <- get_model_effects_df(model_x)
model_y_effects_df <- get_model_effects_df(model_y)
model_z_effects_df <- get_model_effects_df(model_z)

# Combine the model effect data frames into one for plotting
model_x_effects_df$Axis <- "Acceleration X"
model_y_effects_df$Axis <- "Acceleration Y"
model_z_effects_df$Axis <- "Acceleration Z"

combined_effects_df <- rbind(model_x_effects_df, model_y_effects_df, model_z_effects_df)

# Rename the X Axis Labels for plotting
combined_effects_df <- combined_effects_df %>%
  mutate(Block = case_when(
    Block == "1" ~ "Block 1\n(Initial Exposure)",
    Block == "9" ~ "Block 9\n(Extended Practice)",
    Block == "10" ~ "Block 10\n(Unfamiliar Sequences)",
    TRUE ~ Block  
  ))

# Reorder the Group factor to have Top 50% on top in the legend
combined_effects_df$Group <- factor(combined_effects_df$Group, levels = c("Top 50%", "Bottom 50%"))

# Set Order
combined_effects_df <- combined_effects_df %>%
  mutate(Block = factor(Block, levels = c(
    "Block 1\n(Initial Exposure)", 
    "Block 9\n(Extended Practice)", 
    "Block 10\n(Unfamiliar Sequences)"
  )))


# Adjust plot for Hurst Exponent X
plot_x <- ggplot(combined_effects_df %>% filter(Axis == "Acceleration X"), aes(x = Block, y = fit, color = Group, group = Group)) +
  geom_vline(xintercept = 3, color = "darkorchid", size = 1.5, alpha = 0.25, linetype = "solid") +
  geom_line(size = 2.5) +  
  geom_point(size = 5) +  
  geom_ribbon(aes(ymin = l83, ymax = u83, fill = Group), alpha = 0.5) +  
  labs(
    title = " ",
    subtitle = "                          Acceleration X",
    x = NULL,
    y = "Estimated Hurst Exponent"
  ) +
  theme_minimal() +
  theme(
    text = element_text(size = 20),  
    legend.title = element_text(size = 20), 
    legend.text = element_text(size = 20), 
    legend.position = "none",
    plot.title = element_text(face = "bold", size = 24),  
    plot.subtitle = element_text(size = 26),  
    axis.title.y = element_text(size = 26),  
    axis.text.x = ggtext::element_markdown(size = 22, face = "bold", angle = 0, hjust = 0.5),  
    axis.text.y = element_text(size = 24),  
    panel.grid.major = element_blank(),  
    panel.grid.minor = element_blank(),  
    panel.grid.major.y = element_line(color = "gray80", size = 0.5),  
    panel.grid.minor.y = element_line(color = "gray80", size = 0.25)  
  ) +
  scale_color_manual(values = c("Top 50%" = "darkorchid3", "Bottom 50%" = "grey")) +
  scale_fill_manual(values = c("Top 50%" = "darkorchid3", "Bottom 50%" = "grey")) +  
  ylim(0.7, 1.02) +
  annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7, face = "bold",color = "darkorchid", hjust = 0.5, vjust = 0, alpha = 0.8)
## 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.
## Warning: The `size` argument of `element_line()` is deprecated as of ggplot2 3.4.0.
## ℹ Please use the `linewidth` argument instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## Warning in annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7,
## : Ignoring unknown parameters: `face`
# Customizing the x-axis labels with color to signify significance
plot_x <- plot_x + 
  scale_x_discrete(labels = c(
    "Block 1<br><span style='color:#333333; font-size:18pt;'>Initial<br>Exposure</span>",
    "<span style='color:red;'>Block 9</span><span style='color:#333333; font-size:18pt;'><br>Extended<br>Practice</span>",
    "<span style='color:red;'>Block 10"
  ))

print(plot_x)

# Plot for Hurst Exponent Y
plot_y <- ggplot(combined_effects_df %>% filter(Axis == "Acceleration Y"), aes(x = Block, y = fit, color = Group, group = Group)) +
  geom_vline(xintercept = 3, color = "darkorchid", size = 1.5, alpha = 0.25, linetype = "solid") +
  geom_line(size = 2.5) +  
  geom_point(size = 5) +  
  geom_ribbon(aes(ymin = l83, ymax = u83, fill = Group), alpha = 0.5) +  
  labs(
    title = " ",
    subtitle = "                          Acceleration Y",
    x = NULL,
    y = "Estimated Hurst Exponent"
  ) +
  theme_minimal() +
  theme(
    text = element_text(size = 20),  
    legend.title = element_text(size = 20),  
    legend.text = element_text(size = 20),  
    legend.position = "none",
    plot.title = element_text(face = "bold", size = 24),  
    plot.subtitle = element_text(size = 26),  
    axis.title.y = element_text(size = 26),  
    axis.text.x = ggtext::element_markdown(size = 22, face = "bold", angle = 0, hjust = 0.5),  
    axis.text.y = element_text(size = 24),  
    panel.grid.major = element_blank(), 
    panel.grid.minor = element_blank(),  
    panel.grid.major.y = element_line(color = "gray80", size = 0.5),  
    panel.grid.minor.y = element_line(color = "gray80", size = 0.25)   
  ) +
  scale_color_manual(values = c("Top 50%" = "darkorchid3", "Bottom 50%" = "grey")) +
  scale_fill_manual(values = c("Top 50%" = "darkorchid3", "Bottom 50%" = "grey")) +  
  ylim(0.7, 1.02) +
  annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7, face = "bold",color = "darkorchid", hjust = 0.5, vjust = 0, alpha = 0.8)
## Warning in annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7,
## : Ignoring unknown parameters: `face`
# Customizing the x-axis labels with color to signify significance
plot_y <- plot_y + 
  scale_x_discrete(labels = c(
    "Block 1<br><span style='color:#333333; font-size:18pt;'>Initial<br>Exposure</span>",
    "<span style='color:red;'>Block 9</span><span style='color:#333333; font-size:18pt;'><br>Extended<br>Practice</span>",
    "<span style='color:red;'>Block 10"
  ))

print(plot_y)

# Plot for Hurst Exponent Z
plot_z <- ggplot(combined_effects_df %>% filter(Axis == "Acceleration Z"), aes(x = Block, y = fit, color = Group, group = Group)) +
  geom_vline(xintercept = 3, color = "darkorchid", size = 1.5, alpha = 0.25, linetype = "solid") +
  geom_line(size = 2.5) +  
  geom_point(size = 5) +  
  geom_ribbon(aes(ymin = l83, ymax = u83, fill = Group), alpha = 0.5) +  
  labs(
    title = " ",
    subtitle = "                        Acceleration Z",
    x = NULL,
    y = "Estimated Hurst Exponent"
  ) +
  theme_minimal() +
  theme(
    text = element_text(size = 20),  
    legend.title = element_text(size = 20, face = "bold"),
    legend.text = element_text(size = 20,  face = "bold"),
    legend.position = "right",
    plot.title = element_text(face = "bold", size = 24),  
    plot.subtitle = element_text(size = 26),  
    axis.title.y = element_text(size = 26), 
    axis.text.x = ggtext::element_markdown(size = 22, face = "bold", angle = 0, hjust = 0.5),  
    axis.text.y = element_text(size = 24),  
    panel.grid.major = element_blank(), 
    panel.grid.minor = element_blank(),  
    panel.grid.major.y = element_line(color = "gray80", size = 0.5),  
    panel.grid.minor.y = element_line(color = "gray80", size = 0.25)   
  ) +
  scale_color_manual(values = c("Top 50%" = "darkorchid3", "Bottom 50%" = "grey")) +
  scale_fill_manual(values = c("Top 50%" = "darkorchid3", "Bottom 50%" = "grey")) +  
  ylim(0.7, 1.02) +
  annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7, face = "bold",color = "darkorchid", hjust = 0.5, vjust = 0, alpha = 0.8)
## Warning in annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7,
## : Ignoring unknown parameters: `face`
# Customizing the x-axis labels with color to signify significance
plot_z <- plot_z + 
  scale_x_discrete(labels = c(
    "<span style='color:red;'>Block 1<br><span style='color:#333333; font-size:18pt;'>Initial<br>Exposure</span>",
    "<span style='color:red;'>Block 9</span><span style='color:#333333; font-size:18pt;'><br>Extended<br>Practice</span>",
    "<span style='color:red;'>Block 10"
  ))

print(plot_z)

# Save the plot for Hurst Exponent X
ggsave("Preparation_Hurst_Exponent_X.png", plot = plot_x, width = 8.2, height = 7, dpi = 300)

# Save the plot for Hurst Exponent Y
ggsave("Preparation_Hurst_Exponent_Y.png", plot = plot_y, width = 8.2, height = 7, dpi = 300)

# Save the plot for Hurst Exponent Z
ggsave("Preparation_Hurst_Exponent_Z.png", plot = plot_z, width = 10, height = 7, dpi = 300)

Grouped by Speed and Accuracy - Execution Phase Stats

execution_data_grouped_by_speed_and_accuracy$Block <- factor(execution_data_grouped_by_speed_and_accuracy$Block, 
                                                levels = c("1", "9", "10"), 
                                                ordered = FALSE)

model_x <- lmer(hurst_acceleration_x ~ Group * Block + (1 | Subject), 
                data = execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))

summary(model_x)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_x ~ Group * Block + (1 | Subject)
##    Data: execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in%  
##     c(1, 9, 10))
## 
## REML criterion at convergence: -7412.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -7.0492 -0.0725  0.1367  0.3721  2.8406 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.002956 0.05437 
##  Residual             0.005398 0.07347 
## Number of obs: 3168, groups:  Subject, 22
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)           9.837e-01  1.670e-02  2.101e+01  58.896  < 2e-16 ***
## GroupTop 50%         -1.648e-02  2.362e-02  2.101e+01  -0.698   0.4929    
## Block9               -8.505e-03  4.522e-03  3.142e+03  -1.881   0.0601 .  
## Block10              -2.099e-03  4.522e-03  3.142e+03  -0.464   0.6425    
## GroupTop 50%:Block9  -5.202e-02  6.395e-03  3.142e+03  -8.134 5.91e-16 ***
## GroupTop 50%:Block10 -7.381e-02  6.395e-03  3.142e+03 -11.541  < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) GrT50% Block9 Blck10 GT50%:B9
## GroupTop50% -0.707                              
## Block9      -0.135  0.096                       
## Block10     -0.135  0.096  0.500                
## GrpT50%:Bl9  0.096 -0.135 -0.707 -0.354         
## GrpT50%:B10  0.096 -0.135 -0.354 -0.707  0.500
anova(model_x)
## Type III Analysis of Variance Table with Satterthwaite's method
##              Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)    
## Group       0.03385 0.03385     1    20  6.2713 0.02104 *  
## Block       0.96188 0.48094     2  3142 89.0909 < 2e-16 ***
## Group:Block 0.75929 0.37964     2  3142 70.3269 < 2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_obj <- emmeans(model_x, ~ Group | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3168' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3168)' 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 = 3168' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3168)' or larger];
## but be warned that this may result in large computation time and memory use.
group_block_comparisons <- contrast(emmeans_obj, method = "pairwise")
summary(group_block_comparisons)
## Block = 1:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   0.0165 0.0236 Inf   0.698  0.4853
## 
## Block = 9:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   0.0685 0.0236 Inf   2.900  0.0037
## 
## Block = 10:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   0.0903 0.0236 Inf   3.823  0.0001
## 
## Degrees-of-freedom method: asymptotic
model_y <- lmer(hurst_acceleration_y ~ Group * Block + (1 | Subject), 
                data = execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))

summary(model_y)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_y ~ Group * Block + (1 | Subject)
##    Data: execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in%  
##     c(1, 9, 10))
## 
## REML criterion at convergence: -7345
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -7.6751 -0.0381  0.0891  0.2834  3.1985 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev.
##  Subject  (Intercept) 0.003487 0.05905 
##  Residual             0.005510 0.07423 
## Number of obs: 3168, groups:  Subject, 22
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)           9.858e-01  1.810e-02  2.088e+01  54.478  < 2e-16 ***
## GroupTop 50%         -2.628e-02  2.559e-02  2.088e+01  -1.027  0.31624    
## Block9                2.032e-03  4.568e-03  3.142e+03   0.445  0.65647    
## Block10              -6.375e-03  4.568e-03  3.142e+03  -1.395  0.16297    
## GroupTop 50%:Block9  -5.066e-02  6.461e-03  3.142e+03  -7.841 6.09e-15 ***
## GroupTop 50%:Block10 -1.988e-02  6.461e-03  3.142e+03  -3.077  0.00211 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) GrT50% Block9 Blck10 GT50%:B9
## GroupTop50% -0.707                              
## Block9      -0.126  0.089                       
## Block10     -0.126  0.089  0.500                
## GrpT50%:Bl9  0.089 -0.126 -0.707 -0.354         
## GrpT50%:B10  0.089 -0.126 -0.354 -0.707  0.500
anova(model_y)
## Type III Analysis of Variance Table with Satterthwaite's method
##              Sum Sq  Mean Sq NumDF DenDF F value    Pr(>F)    
## Group       0.02131 0.021308     1    20  3.8675   0.06326 .  
## Block       0.30187 0.150937     2  3142 27.3954 1.603e-12 ***
## Group:Block 0.34394 0.171968     2  3142 31.2127 3.779e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_obj <- emmeans(model_y, ~ Group | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3168' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3168)' 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 = 3168' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3168)' or larger];
## but be warned that this may result in large computation time and memory use.
group_block_comparisons <- contrast(emmeans_obj, method = "pairwise")
summary(group_block_comparisons)
## Block = 1:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   0.0263 0.0256 Inf   1.027  0.3045
## 
## Block = 9:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   0.0769 0.0256 Inf   3.006  0.0026
## 
## Block = 10:
##  contrast             estimate     SE  df z.ratio p.value
##  Bottom 50% - Top 50%   0.0462 0.0256 Inf   1.804  0.0713
## 
## Degrees-of-freedom method: asymptotic
model_z <- lmer(hurst_acceleration_z ~ Group * Block + (1 | Subject), 
                data = execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))

summary(model_z)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: hurst_acceleration_z ~ Group * Block + (1 | Subject)
##    Data: execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in%  
##     c(1, 9, 10))
## 
## REML criterion at convergence: -12911.9
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -16.7370  -0.0333   0.1121   0.2361   0.8155 
## 
## Random effects:
##  Groups   Name        Variance  Std.Dev.
##  Subject  (Intercept) 4.836e-05 0.006954
##  Residual             9.619e-04 0.031015
## Number of obs: 3168, groups:  Subject, 22
## 
## Fixed effects:
##                        Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)           9.861e-01  2.494e-03  3.088e+01 395.438  < 2e-16 ***
## GroupTop 50%          6.483e-03  3.527e-03  3.088e+01   1.838  0.07565 .  
## Block9                7.539e-03  1.909e-03  3.142e+03   3.949 8.00e-05 ***
## Block10               6.160e-03  1.909e-03  3.142e+03   3.227  0.00126 ** 
## GroupTop 50%:Block9  -1.421e-02  2.699e-03  3.142e+03  -5.263 1.52e-07 ***
## GroupTop 50%:Block10 -1.199e-02  2.699e-03  3.142e+03  -4.442 9.22e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) GrT50% Block9 Blck10 GT50%:B9
## GroupTop50% -0.707                              
## Block9      -0.383  0.271                       
## Block10     -0.383  0.271  0.500                
## GrpT50%:Bl9  0.271 -0.383 -0.707 -0.354         
## GrpT50%:B10  0.271 -0.383 -0.354 -0.707  0.500
anova(model_z)
## Type III Analysis of Variance Table with Satterthwaite's method
##                Sum Sq   Mean Sq NumDF DenDF F value    Pr(>F)    
## Group       0.0004865 0.0004865     1    20  0.5057    0.4852    
## Block       0.0001022 0.0000511     2  3142  0.0531    0.9483    
## Group:Block 0.0308455 0.0154227     2  3142 16.0334 1.181e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
emmeans_obj <- emmeans(model_z, ~ Group | Block)
## Note: D.f. calculations have been disabled because the number of observations exceeds 3000.
## To enable adjustments, add the argument 'pbkrtest.limit = 3168' (or larger)
## [or, globally, 'set emm_options(pbkrtest.limit = 3168)' 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 = 3168' (or larger)
## [or, globally, 'set emm_options(lmerTest.limit = 3168)' or larger];
## but be warned that this may result in large computation time and memory use.
group_block_comparisons <- contrast(emmeans_obj, method = "pairwise")
summary(group_block_comparisons)
## Block = 1:
##  contrast             estimate      SE  df z.ratio p.value
##  Bottom 50% - Top 50% -0.00648 0.00353 Inf  -1.838  0.0660
## 
## Block = 9:
##  contrast             estimate      SE  df z.ratio p.value
##  Bottom 50% - Top 50%  0.00772 0.00353 Inf   2.190  0.0285
## 
## Block = 10:
##  contrast             estimate      SE  df z.ratio p.value
##  Bottom 50% - Top 50%  0.00551 0.00353 Inf   1.562  0.1183
## 
## Degrees-of-freedom method: asymptotic
model_x <- lmer(hurst_acceleration_x ~ Group * Block + (1 | Subject), 
                data = execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))
model_y <- lmer(hurst_acceleration_y ~ Group * Block + (1 | Subject), 
                data = execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))
model_z <- lmer(hurst_acceleration_z ~ Group * Block + (1 | Subject), 
                data = execution_data_grouped_by_speed_and_accuracy %>% filter(Block %in% c(1, 9, 10)))


get_model_effects_df <- function(model) {

  model_effects <- allEffects(model)
  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
  
  return(model_effects_df)
}

# Apply the function to the three models (X, Y, Z)
model_x_effects_df <- get_model_effects_df(model_x)
model_y_effects_df <- get_model_effects_df(model_y)
model_z_effects_df <- get_model_effects_df(model_z)

# Combine the model effect data frames into one for plotting
model_x_effects_df$Axis <- "Acceleration X"
model_y_effects_df$Axis <- "Acceleration Y"
model_z_effects_df$Axis <- "Acceleration Z"

combined_effects_df <- rbind(model_x_effects_df, model_y_effects_df, model_z_effects_df)

# Rename the X Axis Labels for plotting
combined_effects_df <- combined_effects_df %>%
  mutate(Block = case_when(
    Block == "1" ~ "Block 1\n(Initial Exposure)",
    Block == "9" ~ "Block 9\n(Extended Practice)",
    Block == "10" ~ "Block 10\n(Unfamiliar Sequences)",
    TRUE ~ Block  
  ))

# Reorder the Group factor to have Top 50% on top in the legend
combined_effects_df$Group <- factor(combined_effects_df$Group, levels = c("Top 50%", "Bottom 50%"))

# Set Order
combined_effects_df <- combined_effects_df %>%
  mutate(Block = factor(Block, levels = c(
    "Block 1\n(Initial Exposure)", 
    "Block 9\n(Extended Practice)", 
    "Block 10\n(Unfamiliar Sequences)"
  )))

# Adjust plot for Hurst Exponent X
plot_x <- ggplot(combined_effects_df %>% filter(Axis == "Acceleration X"), aes(x = Block, y = fit, color = Group, group = Group)) +
  geom_vline(xintercept = 3, color = "darkseagreen", size = 1.5, alpha = 0.25, linetype = "solid") +
  geom_line(size = 2.5) +  
  geom_point(size = 5) +  
  geom_ribbon(aes(ymin = l83, ymax = u83, fill = Group), alpha = 0.5) +  
  labs(
    title = " ",
    subtitle = "                          Acceleration X", 
    x = NULL,
    y = "Estimated Hurst Exponent"
  ) +
  theme_minimal() +
  theme(
    text = element_text(size = 20),  
    legend.title = element_text(size = 20),  
    legend.text = element_text(size = 20),   
    legend.position = "none",  
    plot.title = element_text(face = "bold", size = 24),  
    plot.subtitle = element_text(size = 26),  
    axis.title.y = element_text(size = 26),  
    axis.text.x = ggtext::element_markdown(size = 22, face = "bold", angle = 0, hjust = 0.5),  
    axis.text.y = element_text(size = 24),  
    panel.grid.major = element_blank(), 
    panel.grid.minor = element_blank(),  
    panel.grid.major.y = element_line(color = "gray80", size = 0.5),  
    panel.grid.minor.y = element_line(color = "gray80", size = 0.25)   
  ) +
  scale_color_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "grey")) +  
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "grey")) +  
  ylim(0.7, 1.02) +
  annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7, face = "bold",color = "darkseagreen4", hjust = 0.5, vjust = 0, alpha = 0.8)
## Warning in annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7,
## : Ignoring unknown parameters: `face`
# Customizing the x-axis labels with color to signify significance
plot_x <- plot_x + 
  scale_x_discrete(labels = c(
    "Block 1<br><span style='color:#333333; font-size:18pt;'>Initial<br>Exposure</span>",
    "<span style='color:red;'>Block 9</span><span style='color:#333333; font-size:18pt;'><br>Extended<br>Practice</span>",
    "<span style='color:red;'>Block 10"
  ))

print(plot_x)

# Plot for Hurst Exponent Y
plot_y <- ggplot(combined_effects_df %>% filter(Axis == "Acceleration Y"), aes(x = Block, y = fit, color = Group, group = Group)) +
  geom_vline(xintercept = 3, color = "darkseagreen", size = 1.5, alpha = 0.25, linetype = "solid") +
  geom_line(size = 2.5) +  
  geom_point(size = 5) +  
  geom_ribbon(aes(ymin = l83, ymax = u83, fill = Group), alpha = 0.5) +  
  labs(
    title = " ",
    subtitle = "                          Acceleration Y",  
    x = NULL,
    y = "Estimated Hurst Exponent"
  ) +
  theme_minimal() +
  theme(
    text = element_text(size = 20),  
    legend.title = element_text(size = 120),  
    legend.text = element_text(size = 20),   
    legend.position = "none",  
    plot.title = element_text(face = "bold", size = 24),  
    plot.subtitle = element_text(size = 26),  
    axis.title.y = element_text(size = 26),  
    axis.text.x = ggtext::element_markdown(size = 22, face = "bold", angle = 0, hjust = 0.5),  
    axis.text.y = element_text(size = 24),  
    panel.grid.major = element_blank(), 
    panel.grid.minor = element_blank(),  
    panel.grid.major.y = element_line(color = "gray80", size = 0.5),  
    panel.grid.minor.y = element_line(color = "gray80", size = 0.25)   
  ) +
  scale_color_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "grey")) +  
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "grey")) +  
  ylim(0.7, 1.02) +
  annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7, face = "bold",color = "darkseagreen4", hjust = 0.5, vjust = 0, alpha = 0.8)
## Warning in annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7,
## : Ignoring unknown parameters: `face`
# Customizing the x-axis labels with color to signify significance
plot_y <- plot_y + 
  scale_x_discrete(labels = c(
    "Block 1<br><span style='color:#333333; font-size:18pt;'>Initial<br>Exposure</span>",
    "<span style='color:red;'>Block 9</span><span style='color:#333333; font-size:18pt;'><br>Extended<br>Practice</span>",
    "Block 10"
  ))

print(plot_y)

# Plot for Hurst Exponent Z
plot_z <- ggplot(combined_effects_df %>% filter(Axis == "Acceleration Z"), aes(x = Block, y = fit, color = Group, group = Group)) +
  geom_vline(xintercept = 3, color = "darkseagreen", size = 1.5, alpha = 0.25, linetype = "solid") +
  geom_line(size = 2.5) +  
  geom_point(size = 5) +  
  geom_ribbon(aes(ymin = l83, ymax = u83, fill = Group), alpha = 0.5) +  
  labs(
    title = " ",
    subtitle = "                        Acceleration Z",  
    x = NULL,
    y = "Estimated Hurst Exponent"
  ) +
  theme_minimal() +
  theme(
    text = element_text(size = 20), 
    legend.title = element_text(size = 20, face = "bold"),  
    legend.text = element_text(size = 20, face = "bold"),   
    legend.position = "right",  
    plot.title = element_text(face = "bold", size = 24),  
    plot.subtitle = element_text(size = 26),  
    axis.title.y = element_text(size = 26),  
    axis.text.x = ggtext::element_markdown(size = 22, face = "bold", angle = 0, hjust = 0.5),  
    axis.text.y = element_text(size = 24),  
    panel.grid.major = element_blank(),  
    panel.grid.minor = element_blank(),  
    panel.grid.major.y = element_line(color = "gray80", size = 0.5),  
    panel.grid.minor.y = element_line(color = "gray80", size = 0.25)  
  ) +
  scale_color_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "grey")) +  
  scale_fill_manual(values = c("Top 50%" = "aquamarine4", "Bottom 50%" = "grey")) +  
  ylim(0.7, 1.02) +
  annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7, face = "bold",color = "darkseagreen4", hjust = 0.5, vjust = 0, alpha = 0.8)
## Warning in annotate("text", x = 3, y = 0.71, label = "New Sequences", size = 7,
## : Ignoring unknown parameters: `face`
# Customizing the x-axis labels with color to signify significance
plot_z <- plot_z + 
  scale_x_discrete(labels = c(
    "Block 1<br><span style='color:#333333; font-size:18pt;'>Initial<br>Exposure</span>",
    "<span style='color:red;'>Block 9</span><span style='color:#333333; font-size:18pt;'><br>Extended<br>Practice</span>",
    "Block 10"
  ))

print(plot_z)

# Save the plot for Hurst Exponent X
ggsave("Execution_Hurst_Exponent_X.png", plot = plot_x, width = 8.2, height = 7, dpi = 300)

# Save the plot for Hurst Exponent Y
ggsave("Execution_Hurst_Exponent_Y.png", plot = plot_y, width = 8.2, height = 7, dpi = 300)

# Save the plot for Hurst Exponent Z
ggsave("Execution_Hurst_Exponent_Z.png", plot = plot_z, width = 10, height = 7, dpi = 300)
# Loop through axes (x, y, z), blocks, and groups for the preparation phase
axes <- c("hurst_acceleration_x", "hurst_acceleration_y", "hurst_acceleration_z")
blocks <- c("1", "9", "10")

# Function to perform the regression for hurst_acceleration axes
run_regression <- function(data, axis, phase, block, group) {
  model <- lm(trial_total_rt ~ get(axis), data = data)
  cat("\n============================\n")
  cat(group, "Group - Block", block, "-", phase, "Phase -", axis, "\n")
  cat("============================\n")
  print(summary(model))
}
# Loop through the PREPARATION phase data
for (axis in axes) {
  for (block in blocks) {
    # Filter for each block in preparation phase
    block_data <- preparation_data_grouped_by_speed_and_accuracy %>% filter(Block == block)
    
    # Top 50% group in preparation phase
    top50_data <- block_data %>% filter(Group == "Top 50%")
    run_regression(top50_data, axis, "Preparation", block, "Top 50%")
    
    # Bottom 50% group in preparation phase
    bottom50_data <- block_data %>% filter(Group == "Bottom 50%")
    run_regression(bottom50_data, axis, "Preparation", block, "Bottom 50%")
  }
}
## 
## ============================
## Top 50% Group - Block 1 - Preparation Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3155.2 -1455.6  -556.7   666.3 25376.7 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3678.0      822.4   4.472  9.5e-06 ***
## get(axis)      111.9      916.4   0.122    0.903    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2716 on 526 degrees of freedom
## Multiple R-squared:  2.834e-05,  Adjusted R-squared:  -0.001873 
## F-statistic: 0.01491 on 1 and 526 DF,  p-value: 0.9029
## 
## 
## ============================
## Bottom 50% Group - Block 1 - Preparation Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -4789  -2557  -1179    965  75147 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     1586       1332   1.190 0.234546    
## get(axis)       5220       1551   3.365 0.000822 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5275 on 526 degrees of freedom
## Multiple R-squared:  0.02107,    Adjusted R-squared:  0.01921 
## F-statistic: 11.32 on 1 and 526 DF,  p-value: 0.0008215
## 
## 
## ============================
## Top 50% Group - Block 9 - Preparation Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1948.5  -530.3  -235.8   129.8 20968.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3042.1      570.8    5.33 1.46e-07 ***
## get(axis)    -1461.0      616.4   -2.37   0.0181 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1498 on 526 degrees of freedom
## Multiple R-squared:  0.01057,    Adjusted R-squared:  0.008688 
## F-statistic: 5.619 on 1 and 526 DF,  p-value: 0.01813
## 
## 
## ============================
## Bottom 50% Group - Block 9 - Preparation Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1804.9  -634.9   -98.4   463.9  5934.6 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1560.0      272.3   5.730 1.69e-08 ***
## get(axis)     1244.5      314.5   3.958 8.61e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 997.4 on 526 degrees of freedom
## Multiple R-squared:  0.02892,    Adjusted R-squared:  0.02707 
## F-statistic: 15.66 on 1 and 526 DF,  p-value: 8.607e-05
## 
## 
## ============================
## Top 50% Group - Block 10 - Preparation Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1576.4  -515.4  -217.8   213.9 11618.7 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1863.62     427.50   4.359 1.57e-05 ***
## get(axis)     -45.69     458.54  -0.100    0.921    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1075 on 526 degrees of freedom
## Multiple R-squared:  1.888e-05,  Adjusted R-squared:  -0.001882 
## F-statistic: 0.009929 on 1 and 526 DF,  p-value: 0.9207
## 
## 
## ============================
## Bottom 50% Group - Block 10 - Preparation Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2334.2  -800.5  -198.6   457.1  8173.5 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3992.7      346.8  11.512   <2e-16 ***
## get(axis)     -602.6      399.7  -1.507    0.132    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1297 on 526 degrees of freedom
## Multiple R-squared:  0.004301,   Adjusted R-squared:  0.002408 
## F-statistic: 2.272 on 1 and 526 DF,  p-value: 0.1323
## 
## 
## ============================
## Top 50% Group - Block 1 - Preparation Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3275.5 -1415.0  -569.6   727.5 25241.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2798.6      725.7   3.856 0.000129 ***
## get(axis)     1131.9      828.1   1.367 0.172228    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2712 on 526 degrees of freedom
## Multiple R-squared:  0.00354,    Adjusted R-squared:  0.001645 
## F-statistic: 1.869 on 1 and 526 DF,  p-value: 0.1722
## 
## 
## ============================
## Bottom 50% Group - Block 1 - Preparation Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -4891  -2544  -1186    953  75094 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     1923       1177   1.634 0.102874    
## get(axis)       4980       1409   3.534 0.000445 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5269 on 526 degrees of freedom
## Multiple R-squared:  0.0232, Adjusted R-squared:  0.02134 
## F-statistic: 12.49 on 1 and 526 DF,  p-value: 0.0004446
## 
## 
## ============================
## Top 50% Group - Block 9 - Preparation Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1791.5  -524.9  -253.3   123.0 20969.1 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2804.9      473.8   5.920 5.82e-09 ***
## get(axis)    -1238.1      524.9  -2.359   0.0187 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1498 on 526 degrees of freedom
## Multiple R-squared:  0.01046,    Adjusted R-squared:  0.008583 
## F-statistic: 5.563 on 1 and 526 DF,  p-value: 0.01871
## 
## 
## ============================
## Bottom 50% Group - Block 9 - Preparation Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1790.3  -617.5  -147.5   496.7  6068.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1906.2      231.2   8.244 1.34e-15 ***
## get(axis)      878.0      277.8   3.160  0.00167 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1003 on 526 degrees of freedom
## Multiple R-squared:  0.01863,    Adjusted R-squared:  0.01677 
## F-statistic: 9.987 on 1 and 526 DF,  p-value: 0.001667
## 
## 
## ============================
## Top 50% Group - Block 10 - Preparation Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1580.3  -516.9  -217.1   217.9 11614.4 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1808.99     343.24   5.270 1.99e-07 ***
## get(axis)      13.72     379.56   0.036    0.971    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1075 on 526 degrees of freedom
## Multiple R-squared:  2.483e-06,  Adjusted R-squared:  -0.001899 
## F-statistic: 0.001306 on 1 and 526 DF,  p-value: 0.9712
## 
## 
## ============================
## Bottom 50% Group - Block 10 - Preparation Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2349.6  -775.1  -177.6   441.8  8213.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4183.6      295.7  14.148   <2e-16 ***
## get(axis)     -855.0      351.2  -2.434   0.0153 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1292 on 526 degrees of freedom
## Multiple R-squared:  0.01114,    Adjusted R-squared:  0.00926 
## F-statistic: 5.926 on 1 and 526 DF,  p-value: 0.01525
## 
## 
## ============================
## Top 50% Group - Block 1 - Preparation Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3182.8 -1471.7  -568.0   642.4 25346.5 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   3463.5      690.3   5.018 7.16e-07 ***
## get(axis)      357.4      774.4   0.462    0.645    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2716 on 526 degrees of freedom
## Multiple R-squared:  0.0004048,  Adjusted R-squared:  -0.001496 
## F-statistic: 0.213 on 1 and 526 DF,  p-value: 0.6446
## 
## 
## ============================
## Bottom 50% Group - Block 1 - Preparation Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -5005  -2502  -1197   1010  74928 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     1839       1031   1.784   0.0751 .  
## get(axis)       5190       1254   4.140 4.04e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5246 on 526 degrees of freedom
## Multiple R-squared:  0.03156,    Adjusted R-squared:  0.02972 
## F-statistic: 17.14 on 1 and 526 DF,  p-value: 4.038e-05
## 
## 
## ============================
## Top 50% Group - Block 9 - Preparation Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1833.2  -537.0  -241.9   128.0 20898.6 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2570.2      437.5   5.874 7.54e-09 ***
## get(axis)     -966.3      479.3  -2.016   0.0443 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1500 on 526 degrees of freedom
## Multiple R-squared:  0.007667,   Adjusted R-squared:  0.005781 
## F-statistic: 4.064 on 1 and 526 DF,  p-value: 0.04431
## 
## 
## ============================
## Bottom 50% Group - Block 9 - Preparation Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1790.2  -587.0  -150.8   502.5  6094.0 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   2161.8      189.4  11.412   <2e-16 ***
## get(axis)      582.4      232.4   2.506   0.0125 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1006 on 526 degrees of freedom
## Multiple R-squared:  0.0118, Adjusted R-squared:  0.009924 
## F-statistic: 6.282 on 1 and 526 DF,  p-value: 0.0125
## 
## 
## ============================
## Top 50% Group - Block 10 - Preparation Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1568.3  -518.9  -214.6   214.2 11626.7 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1935.4      308.7   6.270 7.51e-10 ***
## get(axis)     -125.7      336.1  -0.374    0.708    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1075 on 526 degrees of freedom
## Multiple R-squared:  0.000266,   Adjusted R-squared:  -0.001635 
## F-statistic:  0.14 on 1 and 526 DF,  p-value: 0.7085
## 
## 
## ============================
## Bottom 50% Group - Block 10 - Preparation Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2491.7  -801.7  -186.2   456.3  8230.6 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4188.5      241.7  17.332  < 2e-16 ***
## get(axis)     -883.2      291.8  -3.027  0.00259 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1288 on 526 degrees of freedom
## Multiple R-squared:  0.01712,    Adjusted R-squared:  0.01526 
## F-statistic: 9.164 on 1 and 526 DF,  p-value: 0.002589
# Loop through axes (x, y, z), blocks, and groups for the EXECUTION phase
for (axis in axes) {
  for (block in blocks) {
    # Filter for each block in execution phase
    block_data <- execution_data_grouped_by_speed_and_accuracy %>% filter(Block == block)
    
    # Top 50% group in execution phase
    top50_data <- block_data %>% filter(Group == "Top 50%")
    run_regression(top50_data, axis, "Execution", block, "Top 50%")
    
    # Bottom 50% group in execution phase
    bottom50_data <- block_data %>% filter(Group == "Bottom 50%")
    run_regression(bottom50_data, axis, "Execution", block, "Bottom 50%")
  }
}
## 
## ============================
## Top 50% Group - Block 1 - Execution Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2738.5 -1436.1  -642.4   618.7 25250.4 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    -2015       1331  -1.514    0.131    
## get(axis)       5989       1371   4.369  1.5e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2668 on 526 degrees of freedom
## Multiple R-squared:  0.03502,    Adjusted R-squared:  0.03318 
## F-statistic: 19.09 on 1 and 526 DF,  p-value: 1.505e-05
## 
## 
## ============================
## Bottom 50% Group - Block 1 - Execution Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -5292  -2489  -1509    894  75679 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)    14222       4379   3.248  0.00124 **
## get(axis)      -8357       4445  -1.880  0.06066 . 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5313 on 526 degrees of freedom
## Multiple R-squared:  0.006674,   Adjusted R-squared:  0.004786 
## F-statistic: 3.534 on 1 and 526 DF,  p-value: 0.06066
## 
## 
## ============================
## Top 50% Group - Block 9 - Execution Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1449.7  -505.2  -237.1   143.9 21111.3 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  1746.84     467.56   3.736 0.000207 ***
## get(axis)     -53.88     510.59  -0.106 0.915998    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1506 on 526 degrees of freedom
## Multiple R-squared:  2.117e-05,  Adjusted R-squared:  -0.00188 
## F-statistic: 0.01114 on 1 and 526 DF,  p-value: 0.916
## 
## 
## ============================
## Bottom 50% Group - Block 9 - Execution Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1747.1  -617.4  -223.2   483.7  6301.7 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)  -2460.6      779.0  -3.159  0.00168 ** 
## get(axis)     5213.7      797.7   6.536 1.49e-10 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 973.4 on 526 degrees of freedom
## Multiple R-squared:  0.07512,    Adjusted R-squared:  0.07336 
## F-statistic: 42.72 on 1 and 526 DF,  p-value: 1.495e-10
## 
## 
## ============================
## Top 50% Group - Block 10 - Execution Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1422.7  -550.5  -200.0   219.5 11459.5 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    84.28     312.32   0.270    0.787    
## get(axis)    1948.82     346.68   5.621 3.08e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1044 on 526 degrees of freedom
## Multiple R-squared:  0.05667,    Adjusted R-squared:  0.05488 
## F-statistic:  31.6 on 1 and 526 DF,  p-value: 3.079e-08
## 
## 
## ============================
## Bottom 50% Group - Block 10 - Execution Phase - hurst_acceleration_x 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2415.0  -801.9  -179.7   500.3  8111.3 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     5019       1209   4.151 3.86e-05 ***
## get(axis)      -1571       1230  -1.277    0.202    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1297 on 526 degrees of freedom
## Multiple R-squared:  0.00309,    Adjusted R-squared:  0.001195 
## F-statistic:  1.63 on 1 and 526 DF,  p-value: 0.2022
## 
## 
## ============================
## Top 50% Group - Block 1 - Execution Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2720.9 -1448.7  -594.7   555.2 25268.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -262.3      988.3  -0.265    0.791    
## get(axis)     4210.0     1022.7   4.116 4.47e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 2674 on 526 degrees of freedom
## Multiple R-squared:  0.03121,    Adjusted R-squared:  0.02937 
## F-statistic: 16.94 on 1 and 526 DF,  p-value: 4.468e-05
## 
## 
## ============================
## Bottom 50% Group - Block 1 - Execution Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -8256  -2424  -1469    853  75547 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    20062       4193   4.784 2.23e-06 ***
## get(axis)     -14262       4247  -3.358 0.000842 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5275 on 526 degrees of freedom
## Multiple R-squared:  0.02099,    Adjusted R-squared:  0.01913 
## F-statistic: 11.28 on 1 and 526 DF,  p-value: 0.0008419
## 
## 
## ============================
## Top 50% Group - Block 9 - Execution Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1454.4  -501.1  -233.0   142.6 21113.6 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   1795.5      446.1   4.025 6.52e-05 ***
## get(axis)     -107.1      484.4  -0.221    0.825    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1506 on 526 degrees of freedom
## Multiple R-squared:  9.29e-05,   Adjusted R-squared:  -0.001808 
## F-statistic: 0.04887 on 1 and 526 DF,  p-value: 0.8251
## 
## 
## ============================
## Bottom 50% Group - Block 9 - Execution Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1829.6  -565.7  -212.8   561.1  6073.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)   
## (Intercept)     4876       1526   3.195  0.00148 **
## get(axis)      -2279       1544  -1.476  0.14051   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1010 on 526 degrees of freedom
## Multiple R-squared:  0.004125,   Adjusted R-squared:  0.002232 
## F-statistic: 2.179 on 1 and 526 DF,  p-value: 0.1405
## 
## 
## ============================
## Top 50% Group - Block 10 - Execution Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1352.3  -516.2  -202.9   207.5 11509.3 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   -48.09     381.42  -0.126      0.9    
## get(axis)    2002.97     405.73   4.937 1.07e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1051 on 526 degrees of freedom
## Multiple R-squared:  0.04428,    Adjusted R-squared:  0.04246 
## F-statistic: 24.37 on 1 and 526 DF,  p-value: 1.068e-06
## 
## 
## ============================
## Bottom 50% Group - Block 10 - Execution Phase - hurst_acceleration_y 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2399.7  -797.8  -179.0   478.2  8108.0 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)   4773.4      841.4   5.673 2.31e-08 ***
## get(axis)    -1323.7      857.1  -1.544    0.123    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1297 on 526 degrees of freedom
## Multiple R-squared:  0.004515,   Adjusted R-squared:  0.002622 
## F-statistic: 2.385 on 1 and 526 DF,  p-value: 0.1231
## 
## 
## ============================
## Top 50% Group - Block 1 - Execution Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -3152.6 -1455.0  -553.8   657.7 25388.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)   4469.6     4427.8   1.009    0.313
## get(axis)     -697.4     4459.4  -0.156    0.876
## 
## Residual standard error: 2716 on 526 degrees of freedom
## Multiple R-squared:  4.649e-05,  Adjusted R-squared:  -0.001855 
## F-statistic: 0.02446 on 1 and 526 DF,  p-value: 0.8758
## 
## 
## ============================
## Bottom 50% Group - Block 1 - Execution Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
##  -6861  -2439  -1523    852  75956 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    16225       3976   4.081 5.17e-05 ***
## get(axis)     -10367       4025  -2.576   0.0103 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 5298 on 526 degrees of freedom
## Multiple R-squared:  0.01246,    Adjusted R-squared:  0.01058 
## F-statistic: 6.635 on 1 and 526 DF,  p-value: 0.01027
## 
## 
## ============================
## Top 50% Group - Block 9 - Execution Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1371.4  -500.9  -253.4   129.2 21113.2 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)    101.1     2529.7   0.040    0.968
## get(axis)     1619.8     2565.1   0.631    0.528
## 
## Residual standard error: 1505 on 526 degrees of freedom
## Multiple R-squared:  0.0007575,  Adjusted R-squared:  -0.001142 
## F-statistic: 0.3988 on 1 and 526 DF,  p-value: 0.528
## 
## 
## ============================
## Bottom 50% Group - Block 9 - Execution Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1703.5  -576.2  -205.9   548.2  6068.8 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    12559       2147   5.850 8.63e-09 ***
## get(axis)      -9999       2160  -4.629 4.63e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 992.2 on 526 degrees of freedom
## Multiple R-squared:  0.03914,    Adjusted R-squared:  0.03732 
## F-statistic: 21.43 on 1 and 526 DF,  p-value: 4.631e-06
## 
## 
## ============================
## Top 50% Group - Block 10 - Execution Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1478.2  -520.8  -231.0   188.1 11574.6 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)  
## (Intercept)    -3014       2060  -1.463   0.1440  
## get(axis)       4900       2087   2.348   0.0192 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1069 on 526 degrees of freedom
## Multiple R-squared:  0.01037,    Adjusted R-squared:  0.008492 
## F-statistic: 5.513 on 1 and 526 DF,  p-value: 0.01924
## 
## 
## ============================
## Bottom 50% Group - Block 10 - Execution Phase - hurst_acceleration_z 
## ============================
## 
## Call:
## lm(formula = trial_total_rt ~ get(axis), data = data)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -2372.7  -780.0  -169.0   483.1  8048.9 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept)    12988       2498   5.198 2.88e-07 ***
## get(axis)      -9585       2517  -3.808 0.000157 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1282 on 526 degrees of freedom
## Multiple R-squared:  0.02682,    Adjusted R-squared:  0.02497 
## F-statistic:  14.5 on 1 and 526 DF,  p-value: 0.0001569