##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)
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
library(gridExtra)
##
## Attaching package: 'gridExtra'
##
## The following object is masked from 'package:dplyr':
##
## combine
#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)
execution_data_filtered_acc <- execution_data_filtered %>% 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)
preparation_data_filtered_acc <- preparation_data_filtered %>% filter(trial_acc == 1)
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 6 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 6 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1367.6 -1048.6 -735.3 166.7 9524.5
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2504.3 3384.9 0.740 0.464
## hurst_acceleration_x -570.7 3621.7 -0.158 0.876
##
## Residual standard error: 2073 on 40 degrees of freedom
## Multiple R-squared: 0.0006204, Adjusted R-squared: -0.02436
## F-statistic: 0.02483 on 1 and 40 DF, p-value: 0.8756
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 15 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 15 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1831.5 -861.4 -165.2 488.2 4548.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2810.0 1626.5 1.728 0.0929 .
## hurst_acceleration_x 581.7 1817.1 0.320 0.7508
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1267 on 35 degrees of freedom
## Multiple R-squared: 0.002919, Adjusted R-squared: -0.02557
## F-statistic: 0.1025 on 1 and 35 DF, p-value: 0.7508
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 28 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 28 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1427.4 -905.4 -137.7 663.4 2749.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4559 1133 4.023 0.000217 ***
## hurst_acceleration_x -1098 1410 -0.778 0.440467
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1094 on 45 degrees of freedom
## Multiple R-squared: 0.01328, Adjusted R-squared: -0.008645
## F-statistic: 0.6057 on 1 and 45 DF, p-value: 0.4405
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 26 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 26 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -776.9 -537.1 -138.5 386.0 2453.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3937.4 654.9 6.013 4.54e-07 ***
## hurst_acceleration_x -136.8 743.5 -0.184 0.855
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 647.8 on 40 degrees of freedom
## Multiple R-squared: 0.0008462, Adjusted R-squared: -0.02413
## F-statistic: 0.03388 on 1 and 40 DF, p-value: 0.8549
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 23 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 23 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1456.7 -984.1 -476.1 46.5 14044.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 5435.4 2152.8 2.525 0.0158 *
## hurst_acceleration_x -537.5 2914.8 -0.184 0.8547
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2482 on 39 degrees of freedom
## Multiple R-squared: 0.0008711, Adjusted R-squared: -0.02475
## F-statistic: 0.034 on 1 and 39 DF, p-value: 0.8547
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 35 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 35 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1692.2 -1003.1 -395.6 949.4 3156.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 9209 2152 4.278 0.000334 ***
## hurst_acceleration_x -3899 2311 -1.687 0.106307
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1315 on 21 degrees of freedom
## Multiple R-squared: 0.1194, Adjusted R-squared: 0.07748
## F-statistic: 2.848 on 1 and 21 DF, p-value: 0.1063
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 6 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 6 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -369.88 -199.15 -50.48 51.46 1710.39
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -127.4 641.3 -0.199 0.844
## hurst_acceleration_x 808.7 681.4 1.187 0.242
##
## Residual standard error: 336.3 on 40 degrees of freedom
## Multiple R-squared: 0.03401, Adjusted R-squared: 0.009864
## F-statistic: 1.408 on 1 and 40 DF, p-value: 0.2423
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 15 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 15 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -557.51 -166.24 -44.13 130.04 1724.16
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1113.3 663.7 1.677 0.102
## hurst_acceleration_x 148.0 716.0 0.207 0.837
##
## Residual standard error: 360.4 on 38 degrees of freedom
## Multiple R-squared: 0.001123, Adjusted R-squared: -0.02516
## F-statistic: 0.0427 on 1 and 38 DF, p-value: 0.8374
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 28 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 28 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -523.42 -72.89 -21.77 49.42 1235.28
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1839.0 325.0 5.658 1.07e-06 ***
## hurst_acceleration_x -572.3 365.0 -1.568 0.124
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 233.2 on 44 degrees of freedom
## Multiple R-squared: 0.0529, Adjusted R-squared: 0.03138
## F-statistic: 2.458 on 1 and 44 DF, p-value: 0.1241
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 26 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 26 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -693.42 -260.60 -52.16 97.95 1626.32
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3384.4 583.6 5.799 7.16e-07 ***
## hurst_acceleration_x 226.9 677.4 0.335 0.739
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 470.7 on 43 degrees of freedom
## Multiple R-squared: 0.002603, Adjusted R-squared: -0.02059
## F-statistic: 0.1122 on 1 and 43 DF, p-value: 0.7393
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 23 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 23 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -482.52 -78.64 -4.86 99.63 858.08
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2527.2 195.3 12.943 <2e-16 ***
## hurst_acceleration_x -335.7 266.7 -1.259 0.215
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 241.3 on 45 degrees of freedom
## Multiple R-squared: 0.03401, Adjusted R-squared: 0.01254
## F-statistic: 1.584 on 1 and 45 DF, p-value: 0.2146
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 35 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 35 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1021.0 -403.0 -251.7 414.4 4947.6
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2112.6 883.9 2.390 0.0215 *
## hurst_acceleration_x 1200.3 1091.8 1.099 0.2780
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 933.7 on 41 degrees of freedom
## Multiple R-squared: 0.02863, Adjusted R-squared: 0.004942
## F-statistic: 1.209 on 1 and 41 DF, p-value: 0.278
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 6 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 6 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -650.74 -247.23 -139.98 76.71 1283.74
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1368.3 1142.2 1.198 0.238
## hurst_acceleration_x -481.6 1206.1 -0.399 0.692
##
## Residual standard error: 440.4 on 40 degrees of freedom
## Multiple R-squared: 0.00397, Adjusted R-squared: -0.02093
## F-statistic: 0.1594 on 1 and 40 DF, p-value: 0.6918
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 15 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 15 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -613.3 -298.2 -127.8 199.6 1436.9
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2252.7 943.6 2.387 0.0213 *
## hurst_acceleration_x -961.9 995.0 -0.967 0.3390
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 458.9 on 44 degrees of freedom
## Multiple R-squared: 0.0208, Adjusted R-squared: -0.001456
## F-statistic: 0.9346 on 1 and 44 DF, p-value: 0.339
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 28 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 28 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -512.34 -116.46 -11.29 53.80 610.05
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1741.0 352.7 4.936 1.38e-05 ***
## hurst_acceleration_x -435.4 393.4 -1.107 0.275
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 221.1 on 41 degrees of freedom
## Multiple R-squared: 0.02901, Adjusted R-squared: 0.005329
## F-statistic: 1.225 on 1 and 41 DF, p-value: 0.2748
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 26 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 26 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -966.88 -350.19 -49.11 243.93 1041.82
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4283.0 510.9 8.383 5.53e-10 ***
## hurst_acceleration_x -660.1 580.0 -1.138 0.263
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 491.3 on 36 degrees of freedom
## Multiple R-squared: 0.03472, Adjusted R-squared: 0.007909
## F-statistic: 1.295 on 1 and 36 DF, p-value: 0.2627
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 23 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 23 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -999.6 -521.0 -129.8 360.6 2298.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4206.9 576.1 7.303 6.19e-09 ***
## hurst_acceleration_x -432.0 788.8 -0.548 0.587
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 688.7 on 41 degrees of freedom
## Multiple R-squared: 0.007262, Adjusted R-squared: -0.01695
## F-statistic: 0.2999 on 1 and 41 DF, p-value: 0.5869
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc, subset = (Subject == 35 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = preparation_data_acc,
## subset = (Subject == 35 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1910.5 -1065.9 -156.3 896.8 2393.2
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 3609 1028 3.510 0.0011 **
## hurst_acceleration_x 1203 1317 0.914 0.3663
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1180 on 41 degrees of freedom
## Multiple R-squared: 0.01995, Adjusted R-squared: -0.003951
## F-statistic: 0.8347 on 1 and 41 DF, p-value: 0.3663
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 6 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 6 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1816.7 -942.0 -143.9 182.6 8148.3
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -3639 1595 -2.281 0.027946 *
## hurst_acceleration_x 7027 1967 3.573 0.000939 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1806 on 40 degrees of freedom
## Multiple R-squared: 0.2419, Adjusted R-squared: 0.223
## F-statistic: 12.77 on 1 and 40 DF, p-value: 0.0009387
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 15 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 15 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1495.2 -841.9 -221.9 516.1 4169.5
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -316852 116122 -2.729 0.00988 **
## hurst_acceleration_x 321887 116742 2.757 0.00920 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1150 on 35 degrees of freedom
## Multiple R-squared: 0.1785, Adjusted R-squared: 0.155
## F-statistic: 7.602 on 1 and 35 DF, p-value: 0.009199
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 28 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 28 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1458.8 -891.2 -416.9 717.7 2672.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 254614 214299 1.188 0.241
## hurst_acceleration_x -251741 214993 -1.171 0.248
##
## Residual standard error: 1085 on 45 degrees of freedom
## Multiple R-squared: 0.02957, Adjusted R-squared: 0.008002
## F-statistic: 1.371 on 1 and 45 DF, p-value: 0.2478
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 26 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 26 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -763.24 -532.97 -63.24 354.73 2441.43
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -132710 305586 -0.434 0.666
## hurst_acceleration_x 136884 306382 0.447 0.657
##
## Residual standard error: 646.5 on 40 degrees of freedom
## Multiple R-squared: 0.004965, Adjusted R-squared: -0.01991
## F-statistic: 0.1996 on 1 and 40 DF, p-value: 0.6574
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 23 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 23 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1451.9 -1016.3 -512.4 -15.0 14073.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -92151 417505 -0.221 0.826
## hurst_acceleration_x 97560 419072 0.233 0.817
##
## Residual standard error: 2481 on 39 degrees of freedom
## Multiple R-squared: 0.001388, Adjusted R-squared: -0.02422
## F-statistic: 0.0542 on 1 and 39 DF, p-value: 0.8171
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 35 & Block == 1))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 35 & Block == 1))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1658.5 -1073.6 -235.5 722.6 3192.8
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 12220 5946 2.055 0.0525 .
## hurst_acceleration_x -6715 6030 -1.114 0.2780
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1361 on 21 degrees of freedom
## Multiple R-squared: 0.05576, Adjusted R-squared: 0.01079
## F-statistic: 1.24 on 1 and 21 DF, p-value: 0.278
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 6 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 6 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -481.28 -199.56 -25.02 118.49 1440.17
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1222.8 267.2 4.577 4.51e-05 ***
## hurst_acceleration_x -778.7 345.5 -2.254 0.0298 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 322.3 on 40 degrees of freedom
## Multiple R-squared: 0.1127, Adjusted R-squared: 0.0905
## F-statistic: 5.08 on 1 and 40 DF, p-value: 0.02976
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 15 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 15 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -554.46 -175.19 -25.43 135.98 1714.24
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1441.9 359.1 4.015 0.00027 ***
## hurst_acceleration_x -278.5 514.7 -0.541 0.59161
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 359.2 on 38 degrees of freedom
## Multiple R-squared: 0.007646, Adjusted R-squared: -0.01847
## F-statistic: 0.2928 on 1 and 38 DF, p-value: 0.5916
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 28 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 28 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -493.46 -93.83 -22.98 51.81 1307.54
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -8198 22467 -0.365 0.717
## hurst_acceleration_x 9597 22623 0.424 0.673
##
## Residual standard error: 239.1 on 44 degrees of freedom
## Multiple R-squared: 0.004073, Adjusted R-squared: -0.01856
## F-statistic: 0.18 on 1 and 44 DF, p-value: 0.6735
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 26 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 26 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -803.14 -227.19 -61.14 182.92 1252.81
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 599680 169426 3.539 0.000977 ***
## hurst_acceleration_x -597751 169895 -3.518 0.001040 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 415.3 on 43 degrees of freedom
## Multiple R-squared: 0.2235, Adjusted R-squared: 0.2055
## F-statistic: 12.38 on 1 and 43 DF, p-value: 0.00104
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 23 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 23 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -525.28 -106.14 16.72 134.18 702.89
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 169655 57232 2.964 0.00484 **
## hurst_acceleration_x -167937 57426 -2.924 0.00539 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 225.1 on 45 degrees of freedom
## Multiple R-squared: 0.1597, Adjusted R-squared: 0.141
## F-statistic: 8.552 on 1 and 45 DF, p-value: 0.005387
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 35 & Block == 9))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 35 & Block == 9))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1830.3 -355.8 -26.4 260.5 1215.9
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 29877 3219 9.282 1.25e-11 ***
## hurst_acceleration_x -27122 3256 -8.331 2.34e-10 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 577.3 on 41 degrees of freedom
## Multiple R-squared: 0.6286, Adjusted R-squared: 0.6196
## F-statistic: 69.41 on 1 and 41 DF, p-value: 2.337e-10
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 6 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 6 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -670.93 -269.05 -15.64 115.11 988.74
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -769.0 493.6 -1.558 0.1271
## hurst_acceleration_x 2047.3 596.3 3.433 0.0014 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 387.8 on 40 degrees of freedom
## Multiple R-squared: 0.2276, Adjusted R-squared: 0.2083
## F-statistic: 11.79 on 1 and 40 DF, p-value: 0.001401
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 15 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 15 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -763.9 -264.1 -161.2 169.6 1325.5
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 633.8 406.8 1.558 0.1264
## hurst_acceleration_x 937.3 530.7 1.766 0.0843 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 448.1 on 44 degrees of freedom
## Multiple R-squared: 0.06621, Adjusted R-squared: 0.04499
## F-statistic: 3.12 on 1 and 44 DF, p-value: 0.08428
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 28 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 28 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -559.48 -101.73 -23.53 81.59 673.85
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -50.22 2010.74 -0.025 0.980
## hurst_acceleration_x 1418.07 2032.64 0.698 0.489
##
## Residual standard error: 223 on 41 degrees of freedom
## Multiple R-squared: 0.01173, Adjusted R-squared: -0.01237
## F-statistic: 0.4867 on 1 and 41 DF, p-value: 0.4893
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 26 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 26 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -947.99 -291.78 -12.82 248.75 962.81
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 90543 23893 3.790 0.000554 ***
## hurst_acceleration_x -87223 24000 -3.634 0.000863 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 427.7 on 36 degrees of freedom
## Multiple R-squared: 0.2684, Adjusted R-squared: 0.2481
## F-statistic: 13.21 on 1 and 36 DF, p-value: 0.000863
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 23 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 23 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1044.56 -320.70 -41.29 286.92 2165.14
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -216864 82033 -2.644 0.0116 *
## hurst_acceleration_x 221572 82335 2.691 0.0103 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 637.2 on 41 degrees of freedom
## Multiple R-squared: 0.1501, Adjusted R-squared: 0.1294
## F-statistic: 7.242 on 1 and 41 DF, p-value: 0.01026
model <- lm(trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc, subset = (Subject == 35 & Block == 10))
summary(model)
##
## Call:
## lm(formula = trial_total_rt ~ hurst_acceleration_x, data = execution_data_acc,
## subset = (Subject == 35 & Block == 10))
##
## Residuals:
## Min 1Q Median 3Q Max
## -1967.0 -939.0 -122.9 803.4 2460.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 8163 3185 2.563 0.0141 *
## hurst_acceleration_x -3697 3240 -1.141 0.2604
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1174 on 41 degrees of freedom
## Multiple R-squared: 0.03079, Adjusted R-squared: 0.007147
## F-statistic: 1.302 on 1 and 41 DF, p-value: 0.2604
# Function to calculate correlation, display results, and plot for Blocks 1, 9, and 10
calculate_correlation_and_plot <- function(subject, data, phase, acceleration_axis = "hurst_acceleration_x") {
blocks <- c(1, 9, 10) # Specify the blocks to analyze
phase_label <- ifelse(phase == 'execution', 'Sequence Execution', 'Movement Preparation')
for (block in blocks) {
# Filter data for specific subject and block
filtered_data <- data %>% filter(Subject == subject, Block == block)
if(nrow(filtered_data) > 0) {
# Calculate correlation
correlation_result <- cor.test(filtered_data[[acceleration_axis]], filtered_data$trial_total_rt)
# Extract correlation coefficient and p-value
corr_coef <- correlation_result$estimate
p_value <- correlation_result$p.value
# Format p-value for readability
formatted_p_value <- ifelse(p_value < 0.0001, "< 0.0001", format(p_value, digits = 4))
# Prepare annotation text
annotation_text <- paste("Correlation coefficient:", round(corr_coef, 4), "\n",
"p-value:", formatted_p_value)
# Plot data
plot <- ggplot(filtered_data, aes(x = !!sym(acceleration_axis), y = trial_total_rt)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = paste("Correlation for Subject", subject, "in Block", block, "-", phase_label),
x = acceleration_axis,
y = "Trial Total Response Time") +
annotate("text", x = Inf, y = Inf, label = annotation_text, hjust = 1.1, vjust = 2, size = 4, color = "black") +
theme_minimal()
# Display plot
print(plot)
} else {
cat("Subject:", subject, "Block:", block, "- No data available\n\n")
}
}
}
Movement Preparation
calculate_correlation_and_plot(subject = 6, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 6, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 6, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Sequence Execution
calculate_correlation_and_plot(subject = 6, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 6, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 6, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Movement Preparation
calculate_correlation_and_plot(subject = 15, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 15, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 15, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Sequence Execution
calculate_correlation_and_plot(subject = 15, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 15, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 15, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Movement Preparation
calculate_correlation_and_plot(subject = 28, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 28, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 28, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Sequence Execution
calculate_correlation_and_plot(subject = 28, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 28, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 28, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Movement Preparation
calculate_correlation_and_plot(subject = 26, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 26, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 26, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Sequence Execution
calculate_correlation_and_plot(subject = 26, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 26, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 26, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Movement Preparation
calculate_correlation_and_plot(subject = 23, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 23, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 23, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Sequence Execution
calculate_correlation_and_plot(subject = 23, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 23, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 23, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Movement Preparation
calculate_correlation_and_plot(subject = 35, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 35, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 35, data = preparation_data_filtered_acc, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Sequence Execution
calculate_correlation_and_plot(subject = 35, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 35, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot(subject = 35, data = execution_data_filtered_acc, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
Time Series and State Space Plots:
generate_plots <- function(subject, phase, block, acceleration_axis) {
# Select the appropriate dataset based on the phase
data <- if (phase == 'execution') {
execution_data
} else if (phase == 'preparation') {
preparation_data
} else {
stop("Invalid phase. Choose 'execution' or 'preparation'.")
}
# Filter data for specific subject and block
filtered_data <- data %>% filter(Subject == subject, Block == block)
# Define y-axis label based on the selected acceleration axis
y_label <- switch(acceleration_axis,
hurst_acceleration_x = "Hurst Exponent (X Axis)",
hurst_acceleration_y = "Hurst Exponent (Y Axis)",
hurst_acceleration_z = "Hurst Exponent (Z Axis)",
stop("Invalid acceleration axis. Choose 'hurst_acceleration_x', 'hurst_acceleration_y', or 'hurst_acceleration_z'."))
# Time series plot
time_series_plot <- ggplot(filtered_data, aes(x = Trial, y = !!sym(acceleration_axis))) +
geom_line() +
geom_point() +
labs(title = paste("Time Series and State Space for Subject", subject, "in Block", block, "-", acceleration_axis),
x = "Trial",
y = y_label) +
theme_minimal()
# Calculate change in Hurst exponent
filtered_data <- filtered_data %>%
arrange(Trial) %>%
mutate(change_hurst = c(NA, diff(!!sym(acceleration_axis))))
# Remove NA values
filtered_data <- filtered_data %>% filter(!is.na(change_hurst))
# Scatter plot with regression line
scatter_plot <- ggplot(filtered_data, aes(x = !!sym(acceleration_axis), y = change_hurst)) +
geom_point() +
geom_smooth(method = "lm", formula = y ~ poly(x, 3), se = FALSE, color = "darkorchid4") +
geom_hline(yintercept = 0, color = "antiquewhite4") +
labs(title = " ",
x = y_label,
y = paste("Change in", y_label)) +
theme_minimal()
# Arrange the plots side by side using gridExtra
combined_plot <- grid.arrange(time_series_plot, scatter_plot, ncol = 2)
return(combined_plot)
}
Movement Preparation:
generate_plots(subject = 6, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Sequence Execution:
generate_plots(subject = 6, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 6, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Movement Preparation:
generate_plots(subject = 15, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Sequence Execution:
generate_plots(subject = 15, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 15, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Movement Preparation:
generate_plots(subject = 28, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Sequence Execution:
generate_plots(subject = 28, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 28, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Movement Preparation:
generate_plots(subject = 26, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Sequence Execution:
generate_plots(subject = 26, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 26, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Movement Preparation:
generate_plots(subject = 23, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Sequence Execution:
generate_plots(subject = 23, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 23, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Movement Preparation:
generate_plots(subject = 35, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'preparation', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
Sequence Execution:
generate_plots(subject = 35, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 1, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 9, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_x')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_y')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
generate_plots(subject = 35, phase = 'execution', block = 10, acceleration_axis = 'hurst_acceleration_z')
## TableGrob (1 x 2) "arrange": 2 grobs
## z cells name grob
## 1 1 (1-1,1-1) arrange gtable[layout]
## 2 2 (1-1,2-2) arrange gtable[layout]
# Function to calculate correlation, display results, and plot for a given block
calculate_correlation_and_plot_all <- function(block, data, phase, acceleration_axis = "hurst_acceleration_x") {
phase_label <- ifelse(phase == 'execution', 'Sequence Execution', 'Movement Preparation')
# Filter data for the specified block
filtered_data <- data %>% filter(Block == block)
if(nrow(filtered_data) > 0) {
# Calculate correlation
correlation_result <- cor.test(filtered_data[[acceleration_axis]], filtered_data$trial_total_rt)
# Extract correlation coefficient and p-value
corr_coef <- correlation_result$estimate
p_value <- correlation_result$p.value
# Format p-value for readability
formatted_p_value <- ifelse(p_value < 0.0001, "< 0.0001", format(p_value, digits = 4))
# Prepare annotation text
annotation_text <- paste("Correlation coefficient:", round(corr_coef, 4), "\n",
"p-value:", formatted_p_value)
# Plot data
plot <- ggplot(filtered_data, aes(x = !!sym(acceleration_axis), y = trial_total_rt)) +
geom_point() +
geom_smooth(method = "lm", se = FALSE, color = "blue") +
labs(title = paste("Correlation for All Participants in Block", block, "-", phase_label),
x = acceleration_axis,
y = "Trial Total Response Time") +
annotate("text", x = Inf, y = Inf, label = annotation_text, hjust = 1.1, vjust = 2, size = 4, color = "black") +
theme_minimal()
# Display plot
print(plot)
} else {
cat("Block:", block, "- No data available\n\n")
}
}
calculate_correlation_and_plot_all(block = 1, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 9, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 10, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 1, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 9, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 10, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 1, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 9, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 10, data = preparation_data, phase = 'preparation', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 1, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 9, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 10, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_x")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 1, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 9, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 10, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_y")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 1, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 9, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'
calculate_correlation_and_plot_all(block = 10, data = execution_data, phase = 'execution', acceleration_axis = "hurst_acceleration_z")
## `geom_smooth()` using formula = 'y ~ x'