Dissertation

library(readxl)
library(readr)
library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ purrr     1.0.2
✔ forcats   1.0.0     ✔ stringr   1.5.1
✔ ggplot2   3.5.1     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.1
── 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(janitor)

Attaching package: 'janitor'

The following objects are masked from 'package:stats':

    chisq.test, fisher.test
library(dplyr)
library(ggplot2)
library(lubridate)
setwd("~/Documents/Desktop - Jade’s MacBook Air/OneDrive - Teesside University/MSc Strength and Conditioning for Performance and Rehabilitation/Research Project/Data Analysis")

strength_data <- read_csv("forceframe-test-export-16_02_2024.csv") %>%
  mutate(
    ID = str_replace_all(Name, " ", ""))
Rows: 310 Columns: 25
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr   (7): Name, Date UTC, Device, Mode, Test, Direction, Position
dbl  (15): L Reps, R Reps, L Max Force (N), R Max Force (N), Max Imbalance, ...
lgl   (2): ExternalId, Notes
time  (1): Time UTC

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
names <- names(strength_data%>%clean_names)
colnames(strength_data) <- names

strength_data <- strength_data %>%
  filter(date_utc %in% c('14/02/2024', '16/02/2024', '21/02/2024', '23/02/2024', '20/02/2024'))

strength_data <- strength_data %>% subset(select = c(name, date_utc, direction, l_max_force_n, r_max_force_n)) %>% rename(l = l_max_force_n, r = r_max_force_n, id = name)%>% pivot_wider(names_from = direction, values_from = c(l,r))

strength_data <- strength_data %>%
  mutate(id = gsub(" ", "", id)) %>% mutate(id = str_trim(id))

head(strength_data)
# A tibble: 6 × 6
  id    date_utc   l_Pull l_Squeeze r_Pull r_Squeeze
  <chr> <chr>       <dbl>     <dbl>  <dbl>     <dbl>
1 ETC02 16/02/2024   214.      205    194.      221 
2 ETC03 16/02/2024   142.      152.   138.      142.
3 ETC05 16/02/2024   220       222.   230.      231.
4 ETC06 23/02/2024   192       231.   197.      234.
5 ETC07 16/02/2024   179.      227.   190.      216.
6 ETC08 16/02/2024   181.      229    193       228.
ID <- read_excel("FPPA_data.xlsx", sheet = "Groups") %>%
  mutate(
    ID = str_replace_all(ID, " ", ""))

Pre <- read_excel("FPPA_data.xlsx", sheet = "Pre") %>%
  mutate(
    ID = str_replace_all(ID, " ", ""))

head(ID)
# A tibble: 6 × 3
  ID    Leg_dominance Group
  <chr> <chr>         <chr>
1 RTC29 left          Land 
2 RTC84 left          Land 
3 ETC03 left          Land 
4 ETC15 left          Land 
5 RTC85 right         Land 
6 RTC89 right         Land 
pre_long<-pivot_longer(Pre, cols = c(3:7), names_to = "Trial", values_to = "FPPA")

pre_meanFFPA <-mean(pre_long$FPPA)
pre_sd_FFPA <-sd(pre_long$FPPA)

# Remove rows containing outliers from the Five variable

threshold <- 2 * pre_sd_FFPA 

pre_long_clean <- pre_long[abs(pre_long$FPPA - pre_meanFFPA) < threshold, ]
pre_left <-pre_long_clean %>% 
  subset(select = -c(Average)) %>% 
  filter(Limb == "Left") %>% 
  group_by(ID) %>% summarise( mean(FPPA))
  
left<- left_join(pre_left, ID, 
                  by = c("ID")) %>%  rename(preFPPA= "mean(FPPA)") %>% mutate(limb_dom = ifelse( Leg_dominance == "left", "dom", "non_dom"), limb = "left")


pre_right <-pre_long_clean %>% 
  subset(select = -c(Average)) %>% 
  filter(Limb == "Right") %>% 
  group_by(ID) %>% summarise(mean(FPPA))

  
right<- left_join(pre_right, ID,
                  by = c("ID")) %>%  rename(preFPPA= "mean(FPPA)") %>% mutate(limb_dom = ifelse(Leg_dominance == "right", "dom", "non_dom"), limb = "right")


FPPA_ready<- rbind(right, left) %>% subset(select = c(ID, preFPPA, Leg_dominance, limb, limb_dom))%>% rename(id = ID, FPPA = preFPPA) %>% pivot_wider(id_cols = id,names_from = limb, values_from = c(FPPA)) 

ID<- ID %>% rename(id =ID) %>% mutate(id = str_trim(id))



FPPA_ready<-left_join(FPPA_ready, ID, 
                  by = c("id")) %>% subset(select= -c(Group))
FPPA_Hip<-left_join(FPPA_ready, strength_data, 
                  by = c("id"))

head(FPPA_Hip)
# A tibble: 6 × 9
  id    right  left Leg_dominance date_utc   l_Pull l_Squeeze r_Pull r_Squeeze
  <chr> <dbl> <dbl> <chr>         <chr>       <dbl>     <dbl>  <dbl>     <dbl>
1 ETC02 12.2   4.59 right         16/02/2024   214.      205    194.      221 
2 ETC03  8.33 12.7  left          16/02/2024   142.      152.   138.      142.
3 ETC05  7.81  8.21 right         16/02/2024   220       222.   230.      231.
4 ETC06 12.4  12.0  right         23/02/2024   192       231.   197.      234.
5 ETC07  9.94  8.41 right         16/02/2024   179.      227.   190.      216.
6 ETC08 13.2   9.81 right         16/02/2024   181.      229    193       228.
#Checking data to find out why there is missing data
unique_FPPAs <- unique(FPPA_ready$id)
unique_strength <- unique(strength_data$id)

# Check the intersection of IDs
common_ids <- intersect(unique_FPPAs, unique_strength)
print(length(common_ids))  # Number of common IDs
[1] 56
print(setdiff(unique_FPPAs, unique_strength))  # IDs in FPPA_ready not in strength_data
character(0)
print(setdiff(unique_strength, unique_FPPAs))  # IDs in strength_data not in FPPA_ready
character(0)
participant_data <- read_csv ("jade.csv") 
Rows: 110 Columns: 23
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (5): ID, Group, Date, DOB, category
dbl (18): Height, Mass, IFT, Sit_height, x10m, x20m, x30m, Maturity_offset, ...

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
names <- names(participant_data%>%clean_names)
colnames(participant_data) <- names

participant_data <- participant_data %>%
  filter(date %in% c('14/02/2024', '16/02/2024', '21/02/2024', '23/02/2024', '20/02/2024'))

participant_data <- participant_data %>% subset(select = c(id, group, height, mass, maturity_offset, dob)) %>% distinct(id, .keep_all = TRUE)
all <- left_join(participant_data, FPPA_Hip,
                  by = c("id"))
head(all)
# A tibble: 6 × 14
  id    group height  mass maturity_offset dob        right  left Leg_dominance
  <chr> <chr>  <dbl> <dbl>           <dbl> <chr>      <dbl> <dbl> <chr>        
1 ETC02 u12s     148  37.6         -0.370  03/05/2012 12.2   4.59 right        
2 ETC03 u12s     142  32.4         -0.686  04/08/2012  8.33 12.7  left         
3 ETC05 u12s     151  45.5         -0.559  25/04/2013  7.81  8.21 right        
4 ETC06 u12s     154  38.6         -0.0285 19/03/2012 12.4  12.0  right        
5 ETC07 u12s     160  41.5          0.764  01/11/2011  9.94  8.41 right        
6 ETC08 u12s     157  44.6          0.641  16/09/2011 13.2   9.81 right        
# ℹ 5 more variables: date_utc <chr>, l_Pull <dbl>, l_Squeeze <dbl>,
#   r_Pull <dbl>, r_Squeeze <dbl>
#Normalising hip strength data to body mass
all_norm <- all %>%
  group_by(id) %>%
  mutate(
    l_Pull = l_Pull / mass,
    l_Squeeze = l_Squeeze / mass,
    r_Pull = r_Pull / mass,
    r_Squeeze = r_Squeeze / mass
  ) %>% 
  rename(
    FPPA_r = right,
    FPPA_l = left
  )

head(all_norm)
# A tibble: 6 × 14
# Groups:   id [6]
  id    group height  mass maturity_offset dob       FPPA_r FPPA_l Leg_dominance
  <chr> <chr>  <dbl> <dbl>           <dbl> <chr>      <dbl>  <dbl> <chr>        
1 ETC02 u12s     148  37.6         -0.370  03/05/20…  12.2    4.59 right        
2 ETC03 u12s     142  32.4         -0.686  04/08/20…   8.33  12.7  left         
3 ETC05 u12s     151  45.5         -0.559  25/04/20…   7.81   8.21 right        
4 ETC06 u12s     154  38.6         -0.0285 19/03/20…  12.4   12.0  right        
5 ETC07 u12s     160  41.5          0.764  01/11/20…   9.94   8.41 right        
6 ETC08 u12s     157  44.6          0.641  16/09/20…  13.2    9.81 right        
# ℹ 5 more variables: date_utc <chr>, l_Pull <dbl>, l_Squeeze <dbl>,
#   r_Pull <dbl>, r_Squeeze <dbl>
shapiro.test(all_norm$FPPA_r)

    Shapiro-Wilk normality test

data:  all_norm$FPPA_r
W = 0.97252, p-value = 0.2288
shapiro.test(all_norm$r_Pull)

    Shapiro-Wilk normality test

data:  all_norm$r_Pull
W = 0.96948, p-value = 0.1664
shapiro.test(all_norm$r_Squeeze)

    Shapiro-Wilk normality test

data:  all_norm$r_Squeeze
W = 0.96872, p-value = 0.1535
shapiro.test(all_norm$FPPA_l)

    Shapiro-Wilk normality test

data:  all_norm$FPPA_l
W = 0.97624, p-value = 0.3332
shapiro.test(all_norm$l_Pull)

    Shapiro-Wilk normality test

data:  all_norm$l_Pull
W = 0.96762, p-value = 0.1367
shapiro.test(all_norm$l_Squeeze)

    Shapiro-Wilk normality test

data:  all_norm$l_Squeeze
W = 0.96941, p-value = 0.1653
library(ggplot2)
library(patchwork)

# Create QQ plot
p1 <- ggplot(all_norm, aes(sample = FPPA_l)) +
  geom_qq() +
  geom_qq_line(col = "blue")+
  labs(
    x = "Theoretical Quantiles",
    y = "FPPA"
  ) +
  theme_minimal()

p2 <- ggplot(all_norm, aes(sample = FPPA_r)) +
  geom_qq() +
  geom_qq_line(col = "blue")+
  labs(
    x = "Theoretical Quantiles",
    y = "FPPA"
  ) +
  theme_minimal()

p3 <- ggplot(all_norm, aes(sample = l_Pull)) +
  geom_qq() +
  geom_qq_line(col = "red")+
  labs(
    x = "Theoretical Quantiles",
    y = "Hip Abduction Max Force (N)"
  ) +
  theme_minimal()

p4 <- ggplot(all_norm, aes(sample = l_Squeeze)) +
  geom_qq() +
  geom_qq_line(col = "green")+
  labs(
    x = "Theoretical Quantiles",
    y = "Hip Adduction Max Force (N)"
  ) +
  theme_minimal()

p5 <- ggplot(all_norm, aes(sample = r_Pull)) +
  geom_qq() +
  geom_qq_line(col = "red")+
  labs(
    x = "Theoretical Quantiles",
    y = "Hip Abduction Max Force (N)"
  ) +
  theme_minimal()

p6 <- ggplot(all_norm, aes(sample = r_Squeeze)) +
  geom_qq() +
  geom_qq_line(col = "green")+
  labs(
    x = "Theoretical Quantiles",
    y = "Hip Adduction Max Force (N)"
  ) +
  theme_minimal()

p1+p2

ggsave("QQ.png")
Saving 7 x 5 in image
p3+p5

ggsave("ABD.png")
Saving 7 x 5 in image
p4+p6

ggsave("ADD.png")
Saving 7 x 5 in image
p7 <- ggplot(all_norm, aes(y =FPPA_r, x = r_Pull)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    y = "FPPA (degrees)",
    x = "Hip Abduction Max Force (N•kg-1)"
  ) +
  theme_minimal()

p8 <- ggplot(all_norm, aes(y =FPPA_l, x = l_Pull)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    y = "FPPA (degrees)",
    x = "Hip Abduction Max Force (N•kg-1)"
  ) +
  theme_minimal()

p8+p7 +plot_annotation(tag_levels = 'A')
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'

ggsave("Figure1.png")
Saving 7 x 5 in image
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
cor.test(all_norm$FPPA_r, all_norm$r_Squeeze)

    Pearson's product-moment correlation

data:  all_norm$FPPA_r and all_norm$r_Squeeze
t = -0.499, df = 54, p-value = 0.6198
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.3248632  0.1986906
sample estimates:
        cor 
-0.06774889 
cor.test(all_norm$FPPA_r, all_norm$r_Pull)

    Pearson's product-moment correlation

data:  all_norm$FPPA_r and all_norm$r_Pull
t = -0.23603, df = 54, p-value = 0.8143
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2925342  0.2327624
sample estimates:
        cor 
-0.03210262 
p9 <- ggplot(all_norm, aes(y =FPPA_r, x = r_Squeeze)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    y = "FPPA (degrees)",
    x = "Hip Adduction Max Force (N•kg-1)"
  ) +
  theme_minimal()

p10 <- ggplot(all_norm, aes(y =FPPA_l, x = l_Squeeze)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    y = "FPPA (degrees)",
    x = "Hip Adduction Max Force (N•kg-1)"
  ) +
  theme_minimal()

p10+p9 +plot_annotation(tag_levels = 'A')
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'

ggsave("Figure4.png")
Saving 7 x 5 in image
`geom_smooth()` using formula = 'y ~ x'
`geom_smooth()` using formula = 'y ~ x'
cor.test(all_norm$FPPA_l, all_norm$l_Squeeze)

    Pearson's product-moment correlation

data:  all_norm$FPPA_l and all_norm$l_Squeeze
t = -2.2103, df = 54, p-value = 0.03134
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.51215782 -0.02720026
sample estimates:
      cor 
-0.288041 
cor.test(all_norm$FPPA_l, all_norm$l_Pull)

    Pearson's product-moment correlation

data:  all_norm$FPPA_l and all_norm$l_Pull
t = -0.62597, df = 54, p-value = 0.534
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.3401856  0.1820877
sample estimates:
       cor 
-0.0848759 
averages <- all_norm %>%
  group_by(group) %>%
  summarise_if(is.numeric,mean, na.rm = TRUE)

head(averages)
# A tibble: 3 × 10
  group height  mass maturity_offset FPPA_r FPPA_l l_Pull l_Squeeze r_Pull
  <chr>  <dbl> <dbl>           <dbl>  <dbl>  <dbl>  <dbl>     <dbl>  <dbl>
1 u12s    150.  40.3          -0.230   12.7   10.8   4.80      5.27   4.72
2 u14s    160.  50.8           1.37    14.6   11.0   4.77      5.47   4.75
3 u16s    166.  61.4           3.18    12.6   11.5   4.87      5.82   4.90
# ℹ 1 more variable: r_Squeeze <dbl>
library(dplyr)
library(stringr)

# Capitalize group names
all_norm <- all_norm %>%
  mutate(group = str_to_title(group))  # Capitalizes the first letter of each word

#Graph showing FPPA vs Groin Squeeze for Right leg grouped by age group
library(ggrepel)
library(viridis)  # For larger color palettes
Loading required package: viridisLite
smooth_r_Squeeze <- all_norm %>%
  dplyr::group_by(group) %>%
  dplyr::summarize(
    FPPA_mid = mean(FPPA_r, na.rm = TRUE),
    Squeeze_mid = mean(r_Squeeze, na.rm = TRUE),
    label = case_when(
      first(group) == "U12s" ~ "U12s",
      first(group) == "U14s" ~ "U14s",
      first(group) == "U16s" ~ "U16s",
  ))

# Define distinct colors for groups
group_colors <- c("U12s" = "#4c72b0", "U14s" = "#e08214", "U16s" = "#6a0c70")
# Generate a larger color palette for IDs
id_colors <- viridis::viridis(n = length(unique(all_norm$id)), option = "magma")

# Combine group and id colors (ensure you have enough colors)
color_map <- setNames(c(id_colors, group_colors), c(unique(all_norm$id), unique(all_norm$group)))

# Create the plot
ggplot(all_norm, aes(r_Squeeze, FPPA_r, group = group)) +
  geom_point(aes(color = id, shape = group), show.legend = TRUE) +  # Ensure shape legend is shown
  geom_smooth(aes(color = group), method = "lm", formula = y ~ x, show.legend = FALSE) +  # Hide legend for smoothed lines
  #geom_label_repel(
   # data = smooth_r_Squeeze,
    #aes(label = label, x = Squeeze_mid, y = FPPA_mid, color = group),
    #size = 3,
   # segment.color = "transparent",
   # direction = "both",
   # box.padding = 0.5,  # Adjusted for better readability
   # point.padding = 0.5,
   # min.segment.length = 0.5,
   # nudge_x = 2,
   # nudge_y = 0,
   # show.legend = FALSE  # Hide legend for labels
 # ) + 
  labs(
    x = "Hip Adduction Max Force (N•kg-1)",
    y = "FPPA (degrees)",
  ) +
  scale_color_manual(values = color_map, guide = "none") +  # Apply distinct colors and hide color legend
  scale_shape_manual(values = c("U12s" = 19, "U14s" = 17, "U16s" = 15)) +
  theme_minimal() +
  theme(
    text = element_text(size = 14),
    axis.text.x = element_text(angle = 0, hjust = 1),
    legend.position = "none"
  ) +
  labs(shape = "Groups") +
  facet_wrap(~group)

ggsave("Figure6.png")
Saving 7 x 5 in image
#Graph showing FPPA vs Groin Squeeze for Left leg grouped by age group
library(ggrepel)
library(viridis)  # For larger color palettes

#smooth_l_Squeeze <- all_norm %>%
 # dplyr::group_by(group) %>%
  #dplyr::summarize(
   # FPPA_mid = mean(FPPA_l, na.rm = TRUE),
    #Squeeze_mid = mean(l_Squeeze, na.rm = TRUE),
      #first(group) == "u12s" ~ "u12s",
   # label = case_when(
      #first(group) == "u14s" ~ "u14s",
     # first(group) == "u16s" ~ "u16s",
 # ))

# Define distinct colors for groups
group_colors <- c("U12s" = "#4c72b0", "U14s" = "#e08214", "U16s" = "#6a0c70")
# Generate a larger color palette for IDs
id_colors <- viridis::viridis(n = length(unique(all_norm$id)), option = "magma")

# Combine group and id colors (ensure you have enough colors)
color_map <- setNames(c(id_colors, group_colors), c(unique(all_norm$id), unique(all_norm$group)))

# Create the plot
ggplot(all_norm, aes(l_Squeeze, FPPA_l, group = group)) +
  geom_point(aes(color = id, shape = group), show.legend = TRUE) +  # Ensure shape legend is shown
  geom_smooth(aes(color = group), method = "lm", formula = y ~ x, show.legend = FALSE) +  # Hide legend for smoothed lines
  #geom_label_repel(
   # data = smooth_l_Squeeze,
   # aes(label = label, x = Squeeze_mid, y = FPPA_mid, color = group),
   # size = 3,
    #segment.color = "transparent",
    #direction = "both",
    #box.padding = 0.5,  # Adjusted for better readability
    #point.padding = 0.5,
    #min.segment.length = 0.5,
    #nudge_x = 0,
    #nudge_y = 0,
    #show.legend = FALSE  # Hide legend for labels
  #) + 
  labs(
    x = "Hip Adduction Max Force (N•kg-1)",
    y = "FPPA (degrees)",
  ) +
  scale_color_manual(values = color_map, guide = "none") +  # Apply distinct colors and hide color legend
  scale_shape_manual(values = c("U12s" = 19, "U14s" = 17, "U16s" = 15)) +
  theme_minimal() +
  theme(
    text = element_text(size = 14),
    axis.text.x = element_text(angle = 0, hjust = 1),
    legend.position = "none"  # Adjust position of the legend
  ) +
  labs(shape = "Groups") +
  facet_wrap(~group) 

ggsave("Figure5.png")
Saving 7 x 5 in image
#Graph showing FPPA vs Groin Pull for Right leg grouped by age group
library(ggrepel)
library(viridis)  # For larger color palettes

#smooth_r_Pull <- all_norm %>%
 # dplyr::group_by(group) %>%
  #dplyr::summarize(
  #  FPPA_mid = mean(FPPA_r, na.rm = TRUE),
  #  Pull_mid = mean(r_Pull, na.rm = TRUE),
  #  label = case_when(
   #   first(group) == "u12s" ~ "u12s",
    # first(group) == "u14s" ~ "u14s",
     # first(group) == "u16s" ~ "u16s",
 # ))

# Define distinct colors for groups
group_colors <- c("U12s" = "#4c72b0", "U14s" = "#e08214", "U16s" = "#6a0c70")
# Generate a larger color palette for IDs
id_colors <- viridis::viridis(n = length(unique(all_norm$id)), option = "magma")

# Combine group and id colors (ensure you have enough colors)
color_map <- setNames(c(id_colors, group_colors), c(unique(all_norm$id), unique(all_norm$group)))

# Create the plot
ggplot(all_norm, aes(r_Pull, FPPA_r, group = group)) +
  geom_point(aes(color = id, shape = group), show.legend = TRUE) +  # Ensure shape legend is shown
  geom_smooth(aes(color = group), method = "lm", formula = y ~ x, show.legend = FALSE) +  # Hide legend for smoothed lines
 # geom_label_repel(
  #  data = smooth_r_Pull,
  #  aes(label = label, x = Pull_mid, y = FPPA_mid, color = group),
  #  size = 3,
  #  segment.color = "transparent",
  #  direction = "both",
  #  box.padding = 0.5,  # Adjusted for better readability
   # point.padding = 0.5,
   # min.segment.length = 0.5,
   # nudge_x = 0,
   # nudge_y = 0,
   # show.legend = FALSE  # Hide legend for labels
 # ) + 
  labs(
    x = "Hip Abduction Max Force (N•kg-1)",
    y = "FPPA (degrees)",
  ) +
  scale_color_manual(values = color_map, guide = "none") +  # Apply distinct colors and hide color legend
  scale_shape_manual(values = c("U12s" = 19, "U14s" = 17, "U16s" = 15)) +
  theme_minimal() +
  theme(
    text = element_text(size = 14),
    axis.text.x = element_text(angle = 0, hjust = 1),
    legend.position = "none"  # Adjust position of the legend
  ) +
  labs(shape = "Groups") +
  facet_wrap(~group)   # Add label for the shape legend

ggsave("Figure3.png")
Saving 7 x 5 in image
#Graph showing FPPA vs Groin Pull for Left leg grouped by age group
library(ggrepel)
library(viridis)  # For larger color palettes

#smooth_l_Pull <- all_norm %>%
 # dplyr::group_by(group) %>%
  #dplyr::summarize(
  #  FPPA_mid = mean(FPPA_l, na.rm = TRUE),
   # Pull_mid = mean(l_Pull, na.rm = TRUE),
   # label = case_when(
    #  first(group) == "u12s" ~ "u12s",
    #  first(group) == "u14s" ~ "u14s",
     # first(group) == "u16s" ~ "u16s",
 # ))

# Define distinct colors for groups
group_colors <- c("U12s" = "#4c72b0", "U14s" = "#e08214", "U16s" = "#6a0c70")
# Generate a larger color palette for IDs
id_colors <- viridis::viridis(n = length(unique(all_norm$id)), option = "magma")

# Combine group and id colors (ensure you have enough colors)
color_map <- setNames(c(id_colors, group_colors), c(unique(all_norm$id), unique(all_norm$group)))

# Create the plot
ggplot(all_norm, aes(l_Pull, FPPA_l, group = group)) +
  geom_point(aes(color = id, shape = group), show.legend = TRUE) +  # Ensure shape legend is shown
  geom_smooth(aes(color = group), method = "lm", formula = y ~ x, show.legend = FALSE) +  # Hide legend for smoothed lines
  #geom_label_repel(
   # data = smooth_l_Pull,
    #aes(label = label, x = Pull_mid, y = FPPA_mid, color = group),
    #size = 3,
   # segment.color = "transparent",
   # direction = "both",
   # box.padding = 0.5,  # Adjusted for better readability
   # point.padding = 0.5,
   # min.segment.length = 0.5,
   # nudge_x = 0,
   # nudge_y = 0,
   # show.legend = FALSE  # Hide legend for labels
 # ) + 
  labs(
    x = "Hip Abduction Max Force (N•kg-1)",
    y = "FPPA (degrees)",
  ) +
  scale_color_manual(values = color_map, guide = "none") +  # Apply distinct colors and hide color legend
  scale_shape_manual(values = c("U12s" = 19, "U14s" = 17, "U16s" = 15)) +
  theme_minimal() +
  theme(
    text = element_text(size = 14),
    axis.text.x = element_text(angle = 0, hjust = 1),
    legend.position = "none"  # Adjust position of the legend
  ) +
  labs(shape = "Groups") +
  facet_wrap(~group)   # Add label for the shape legend

ggsave("Figure2.png")
Saving 7 x 5 in image
#Not used in study
#Graph showing FPPA vs Groin Squeeze for Right leg grouped by leg dominance

smooth_r_Squeezedom <- all_norm %>%
   dplyr::group_by(Leg_dominance) %>%
   dplyr::summarize(
   FPPA_mid = mean(FPPA_r, na.rm = TRUE),
    Squeeze_mid = mean(r_Squeeze, na.rm = TRUE),
    label = case_when(
      first(Leg_dominance) == "right" ~ "right",
      first(Leg_dominance) == "left" ~ "left",
  ))
# Define distinct colors for groups
leg_colors <- c("right" = "#4c72b0", "left" = "#e08214")
# Generate a larger color palette for IDs
id_colors <- viridis::viridis(n = length(unique(all_norm$id)), option = "magma")

# Combine group and id colors (ensure you have enough colors)
color_map <- setNames(c(id_colors, leg_colors), c(unique(all_norm$id), unique(all_norm$Leg_dominance)))

# Create the plot
ggplot(all_norm, aes(r_Squeeze, FPPA_r, group = Leg_dominance)) +
  geom_point(aes(color = id, shape = Leg_dominance), show.legend = TRUE) +  # Ensure shape legend is shown
  geom_smooth(aes(color = Leg_dominance), method = "lm", formula = y ~ x, show.legend = FALSE) +  # Hide legend for smoothed lines
  geom_label_repel(
    data = smooth_r_Squeezedom,
    aes(label = label, x = Squeeze_mid, y = FPPA_mid, color = Leg_dominance),
    size = 3,
    segment.color = "transparent",
    direction = "both",
    box.padding = -0.5,  # Adjusted for better readability
    point.padding = 0.5,
    min.segment.length = 0.5,
    nudge_x = 0,
    nudge_y = 0,
    show.legend = FALSE  # Hide legend for labels
  ) + 
  labs(
    x = "Groin Squeeze Strength",
    y = "Frontal Plane Projection Angle",
  ) +
  scale_color_manual(values = color_map, guide = "none") +  # Apply distinct colors and hide color legend
  scale_shape_manual(values = c("right" = 19, "left" = 17)) +
  theme_minimal() +
  theme(
    text = element_text(size = 14),
    axis.text.x = element_text(angle = 0, hjust = 1),
    legend.position = "right"  # Adjust position of the legend
  ) +
  labs(shape = "Leg Dominance")  # Add label for the shape legend

all_asym <- within(all, pull_asym <-(l_Pull - r_Pull) / (l_Pull + r_Pull) * 100)

all_asym <- within(all_asym, squeeze_asym <-(l_Squeeze - r_Squeeze) / (l_Squeeze + r_Squeeze) * 100)

head(all_asym)
# A tibble: 6 × 16
  id    group height  mass maturity_offset dob        right  left Leg_dominance
  <chr> <chr>  <dbl> <dbl>           <dbl> <chr>      <dbl> <dbl> <chr>        
1 ETC02 u12s     148  37.6         -0.370  03/05/2012 12.2   4.59 right        
2 ETC03 u12s     142  32.4         -0.686  04/08/2012  8.33 12.7  left         
3 ETC05 u12s     151  45.5         -0.559  25/04/2013  7.81  8.21 right        
4 ETC06 u12s     154  38.6         -0.0285 19/03/2012 12.4  12.0  right        
5 ETC07 u12s     160  41.5          0.764  01/11/2011  9.94  8.41 right        
6 ETC08 u12s     157  44.6          0.641  16/09/2011 13.2   9.81 right        
# ℹ 7 more variables: date_utc <chr>, l_Pull <dbl>, l_Squeeze <dbl>,
#   r_Pull <dbl>, r_Squeeze <dbl>, pull_asym <dbl>, squeeze_asym <dbl>
#not used in study
# Count the number of positive and negative pull_asym values
pull_asym_counts <- all_asym %>%
  dplyr::summarize(left_stronger_pull = sum(pull_asym > 0),
            right_stronger_pull = sum(pull_asym < 0),
            no_asym_pull = sum(pull_asym == 0))

# Count the number of positive and negative pull_asym values
squeeze_asym_counts <- all_asym %>%
  dplyr::summarize(left_stronger_squeeze = sum(squeeze_asym > 0),
            right_stronger_squeeze = sum(squeeze_asym < 0),
            no_asym_squeeze = sum(squeeze_asym == 0))

asym_counts <- cross_join(pull_asym_counts, squeeze_asym_counts)

head(asym_counts)
# A tibble: 1 × 6
  left_stronger_pull right_stronger_pull no_asym_pull left_stronger_squeeze
               <int>               <int>        <int>                 <int>
1                 27                  28            1                    27
# ℹ 2 more variables: right_stronger_squeeze <int>, no_asym_squeeze <int>
#not used in study
# Add pull and squeeze asymmetry direction to your data
all_asym <- all_asym %>%
  dplyr::mutate(
    pull_asym_direction = case_when(
      pull_asym > 0 ~ "left_stronger",
      pull_asym < 0 ~ "right_stronger",
      TRUE ~ "no_asym"
    ),
    squeeze_asym_direction = case_when(
      squeeze_asym > 0 ~ "left_stronger",
      squeeze_asym < 0 ~ "right_stronger",
      TRUE ~ "no_asym"
    )
  )
# Not used in study
# Logistic regression for pull asymmetry
pull_asym_model <- glm(pull_asym_direction == "left_stronger" ~ Leg_dominance, 
                       data = all_asym, 
                       family = "binomial")
summary(pull_asym_model)

Call:
glm(formula = pull_asym_direction == "left_stronger" ~ Leg_dominance, 
    family = "binomial", data = all_asym)

Coefficients:
                     Estimate Std. Error z value Pr(>|z|)
(Intercept)        -1.517e-15  8.165e-01   0.000    1.000
Leg_dominanceright -8.004e-02  8.642e-01  -0.093    0.926

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 77.561  on 55  degrees of freedom
Residual deviance: 77.552  on 54  degrees of freedom
AIC: 81.552

Number of Fisher Scoring iterations: 3
# Logistic regression for squeeze asymmetry
squeeze_asym_model <- glm(squeeze_asym_direction == "left_stronger" ~ Leg_dominance, 
                          data = all_asym, 
                          family = "binomial")
summary(squeeze_asym_model)

Call:
glm(formula = squeeze_asym_direction == "left_stronger" ~ Leg_dominance, 
    family = "binomial", data = all_asym)

Coefficients:
                   Estimate Std. Error z value Pr(>|z|)
(Intercept)           1.609      1.095   1.469    0.142
Leg_dominanceright   -1.851      1.132  -1.635    0.102

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 77.561  on 55  degrees of freedom
Residual deviance: 74.000  on 54  degrees of freedom
AIC: 78

Number of Fisher Scoring iterations: 3
# Not used in study
#Graph showing FPPA and Pull Asymmetry for Right Leg
ggplot(all_asym, aes(x =right, y = pull_asym)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    title = "Scatter Plot of Right vs. Pull Assymetry",
    x = "Right",
    y = "Pull Asym"
  ) +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

# Not used in study
#Graph showing FPPA and Pull Asymmetry for Left Leg
ggplot(all_asym, aes(x =left, y = pull_asym)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    title = "Scatter Plot of Left vs. Pull Assymetry",
    x = "Left",
    y = "Pull Asym"
  ) +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

# Not used in study
#Graph showing FPPA and Squeeze Asymmetry for Left Leg
ggplot(all_asym, aes(x =left, y = squeeze_asym)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    title = "Scatter Plot of Left vs. Squeeze Assymetry",
    x = "Left",
    y = "Squeeze Asym"
  ) +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

# Not used in study
#Graph showing FPPA and Squeeze Asymmetry for Right Leg
ggplot(all_asym, aes(x =right, y = squeeze_asym)) +
  geom_point(size = 3) +  # Scatter plot points
  geom_smooth(method = "lm", se = TRUE, color = "black") +  # Add a smooth line
  labs(
    title = "Scatter Plot of Right vs. Squeeze Assymetry",
    x = "Right",
    y = "Squeeze Asym"
  ) +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

# Not used in study
all_pos_asym <- within(all, {
  pull_asym <- ifelse(l_Pull > r_Pull, 
                      (l_Pull - r_Pull) / (l_Pull + r_Pull) * 100, 
                      (r_Pull-l_Pull) / (l_Pull + r_Pull) * 100
                      )
})

all <- within(all_pos_asym, {
  squeeze_asym <- ifelse(l_Squeeze > r_Squeeze, 
                      (l_Squeeze - r_Squeeze) / (l_Squeeze + r_Squeeze) * 100, 
                      (r_Squeeze-l_Squeeze) / (l_Squeeze + r_Squeeze) * 100
                      )
})
head(all_pos_asym)
# A tibble: 6 × 15
  id    group height  mass maturity_offset dob        right  left Leg_dominance
  <chr> <chr>  <dbl> <dbl>           <dbl> <chr>      <dbl> <dbl> <chr>        
1 ETC02 u12s     148  37.6         -0.370  03/05/2012 12.2   4.59 right        
2 ETC03 u12s     142  32.4         -0.686  04/08/2012  8.33 12.7  left         
3 ETC05 u12s     151  45.5         -0.559  25/04/2013  7.81  8.21 right        
4 ETC06 u12s     154  38.6         -0.0285 19/03/2012 12.4  12.0  right        
5 ETC07 u12s     160  41.5          0.764  01/11/2011  9.94  8.41 right        
6 ETC08 u12s     157  44.6          0.641  16/09/2011 13.2   9.81 right        
# ℹ 6 more variables: date_utc <chr>, l_Pull <dbl>, l_Squeeze <dbl>,
#   r_Pull <dbl>, r_Squeeze <dbl>, pull_asym <dbl>
# Not used in study
# Pearson correlation for pull asymmetry and FPPA
cor_pull_fppa <- cor(all_asym$pull_asym, all_asym$right, method = "pearson")
print(cor_pull_fppa)
[1] 0.1256906
# Pearson correlation for squeeze asymmetry and FPPA
cor_squeeze_fppa <- cor(all_asym$squeeze_asym, all_asym$right, method = "pearson")
print(cor_squeeze_fppa)
[1] -0.01831602
# Not used in study
# Shapiro-Wilk test for pull asymmetry direction
shapiro_test_left <- shapiro.test(all_asym$right[all_asym$pull_asym_direction == "left_stronger"])
shapiro_test_right <- shapiro.test(all_asym$right[all_asym$pull_asym_direction == "right_stronger"])

# Print results
print(shapiro_test_left)

    Shapiro-Wilk normality test

data:  all_asym$right[all_asym$pull_asym_direction == "left_stronger"]
W = 0.97088, p-value = 0.6253
print(shapiro_test_right)

    Shapiro-Wilk normality test

data:  all_asym$right[all_asym$pull_asym_direction == "right_stronger"]
W = 0.96006, p-value = 0.3499
# Shapiro-Wilk test for squeeze asymmetry direction
shapiro_test_squeeze_left <- shapiro.test(all_asym$right[all_asym$squeeze_asym_direction == "left_stronger"])
shapiro_test_squeeze_right <- shapiro.test(all_asym$right[all_asym$squeeze_asym_direction == "right_stronger"])

# Print results
print(shapiro_test_squeeze_left)

    Shapiro-Wilk normality test

data:  all_asym$right[all_asym$squeeze_asym_direction == "left_stronger"]
W = 0.94454, p-value = 0.1576
print(shapiro_test_squeeze_right)

    Shapiro-Wilk normality test

data:  all_asym$right[all_asym$squeeze_asym_direction == "right_stronger"]
W = 0.98698, p-value = 0.9694
# Shapiro-Wilk test for pull asymmetry direction
shapiro_test_left <- shapiro.test(all_asym$left[all_asym$pull_asym_direction == "left_stronger"])
shapiro_test_right <- shapiro.test(all_asym$left[all_asym$pull_asym_direction == "right_stronger"])

# Print results
print(shapiro_test_left)

    Shapiro-Wilk normality test

data:  all_asym$left[all_asym$pull_asym_direction == "left_stronger"]
W = 0.98253, p-value = 0.9144
print(shapiro_test_right)

    Shapiro-Wilk normality test

data:  all_asym$left[all_asym$pull_asym_direction == "right_stronger"]
W = 0.92684, p-value = 0.05135
# Shapiro-Wilk test for squeeze asymmetry direction
shapiro_test_squeeze_left <- shapiro.test(all_asym$left[all_asym$squeeze_asym_direction == "left_stronger"])
shapiro_test_squeeze_right <- shapiro.test(all_asym$left[all_asym$squeeze_asym_direction == "right_stronger"])

# Print results
print(shapiro_test_squeeze_left)

    Shapiro-Wilk normality test

data:  all_asym$left[all_asym$squeeze_asym_direction == "left_stronger"]
W = 0.95606, p-value = 0.2995
print(shapiro_test_squeeze_right)

    Shapiro-Wilk normality test

data:  all_asym$left[all_asym$squeeze_asym_direction == "right_stronger"]
W = 0.97141, p-value = 0.5984
# Not used in study
# Checking relationship between asymmetry and FPPA
# ANOVA for pull asymmetry direction and FPPA
anova_pull <- aov(right ~ pull_asym_direction, data = all_asym)
summary(anova_pull)
                    Df Sum Sq Mean Sq F value Pr(>F)
pull_asym_direction  2   50.2   25.09   1.422   0.25
Residuals           53  935.1   17.64               
# ANOVA for squeeze asymmetry direction and FPPA
anova_squeeze <- aov(right ~ squeeze_asym_direction, data = all_asym)
summary(anova_squeeze)
                       Df Sum Sq Mean Sq F value Pr(>F)
squeeze_asym_direction  1    0.1   0.055   0.003  0.956
Residuals              54  985.2  18.244               
# ANOVA for pull asymmetry direction and FPPA
anova_pull <- aov(left ~ pull_asym_direction, data = all_asym)
summary(anova_pull)
                    Df Sum Sq Mean Sq F value Pr(>F)
pull_asym_direction  2   52.0   26.02   1.889  0.161
Residuals           53  729.9   13.77               
# ANOVA for squeeze asymmetry direction and FPPA
anova_squeeze <- aov(left ~ squeeze_asym_direction, data = all_asym)
summary(anova_squeeze)
                       Df Sum Sq Mean Sq F value Pr(>F)
squeeze_asym_direction  1   11.6   11.60   0.813  0.371
Residuals              54  770.3   14.27               
#Not used in study
#Graph showing FPPA and Squeeze Asymmetry for Right Leg grouped by Leg Dominance

smooth_r_Squeezedom <- all_asym %>%
  dplyr::group_by(Leg_dominance) %>%
  dplyr::summarize(
    FPPA_mid = mean(right, na.rm = TRUE),
    Squeeze_mid = mean(squeeze_asym, na.rm = TRUE),
     label = case_when(
      first(Leg_dominance) == "right" ~ "right",
      first(Leg_dominance) == "left" ~ "left"
    )
  )

# Define distinct colors for groups
leg_colors <- c("right" = "#4c72b0", "left" = "#e08214")
# Generate a larger color palette for IDs
id_colors <- viridis::viridis(n = length(unique(all_asym$id)), option = "magma")

# Combine group and id colors (ensure you have enough colors)
color_map <- setNames(c(id_colors, leg_colors), c(unique(all_asym$id), unique(all_asym$Leg_dominance)))

# Create the plot
ggplot(all_asym, aes(squeeze_asym, right, group = Leg_dominance)) +
  geom_point(aes(color = id, shape = Leg_dominance), show.legend = TRUE) +  # Ensure shape legend is shown
  geom_smooth(aes(color = Leg_dominance), method = "lm", formula = y ~ x, show.legend = FALSE) +  # Hide legend for smoothed lines
  geom_label_repel(
    data = smooth_r_Squeezedom,
    aes(label = label, x = Squeeze_mid, y = FPPA_mid, color = Leg_dominance),
    size = 3,
    segment.color = "transparent",
    direction = "both",
    box.padding = -0.5,  # Adjusted for better readability
    point.padding = 0.5,
    min.segment.length = 0.5,
    nudge_x = 0,
    nudge_y = 0,
    show.legend = FALSE  # Hide legend for labels
  ) + 
  labs(
    x = "Groin Squeeze Strength Asymmetry",
    y = "Frontal Plane Projection Angle",
  ) +
  scale_color_manual(values = color_map, guide = "none") +  # Apply distinct colors and hide color legend
  scale_shape_manual(values = c("right" = 19, "left" = 17)) +
  theme_minimal() +
  theme(
    text = element_text(size = 14),
    axis.text.x = element_text(angle = 0, hjust = 1),
    legend.position = "right"  # Adjust position of the legend
  ) +
  labs(shape = "Leg Dominance")  # Add label for the shape legend

#Participant Characteristics
mean_height <-mean(all$height)
sd_height <-sd(all$height)
range_height <- range(all$height)

print(mean_height)
[1] 157.8214
print(sd_height)
[1] 9.502358
print(range_height)
[1] 122 182
mean_mass <-mean(all$mass)
sd_mass <-sd(all$mass)
range_mass <- range(all$mass)

print(mean_mass)
[1] 49.53036
print(sd_mass)
[1] 10.74056
print(range_mass)
[1] 25.9 76.9
mean_mat<-mean(all$maturity_offset)
sd_mat <-sd(all$maturity_offset)
range_mat <- range(all$maturity_offset)

print(mean_mat)
[1] 1.218224
print(sd_mat)
[1] 1.428589
print(range_mat)
[1] -1.711783  4.347478
#Paricipant Ages
all$dob <- dmy(all$dob)
all$date_utc <- dmy(all$date_utc)
all$age <- floor(interval(all$dob, all$date_utc) / years(1))

mean_age<-mean(all$age)
sd_age <-sd(all$age)
range_age <- range(all$age)

print(mean_age)
[1] 12.73214
print(sd_age)
[1] 1.700172
print(range_age)
[1] 10 16
#Not used in study
# Count the number of "right" and "left" in Leg_dominance
leg_dominance_counts <- all_norm %>%
  dplyr::group_by(Leg_dominance) %>%
  dplyr::summarize(count = n()) %>%
  dplyr::filter(Leg_dominance %in% c("right", "left")) %>%
  tidyr::pivot_wider(names_from = Leg_dominance, values_from = count)


# View the results
print(leg_dominance_counts)
# A tibble: 1 × 2
   left right
  <int> <int>
1     6    50
library(Hmisc)

Attaching package: 'Hmisc'
The following objects are masked from 'package:dplyr':

    src, summarize
The following objects are masked from 'package:base':

    format.pval, units
# Subset the data where group is u12 (L)
subset_data <- all_norm[all_norm$group == "U12s", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_l", "l_Pull", "l_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_l     l_Pull  l_Squeeze
FPPA_l     1.0000000 -0.1604188 -0.4375860
l_Pull    -0.1604188  1.0000000  0.4512681
l_Squeeze -0.4375860  0.4512681  1.0000000
print(p_value_matrix)
              FPPA_l     l_Pull  l_Squeeze
FPPA_l            NA 0.49928363 0.05366628
l_Pull    0.49928363         NA 0.04580744
l_Squeeze 0.05366628 0.04580744         NA
subset_data <- all_norm[all_norm$group == "U12s", ]
cor.test(subset_data$FPPA_l, subset_data$l_Squeeze)

    Pearson's product-moment correlation

data:  subset_data$FPPA_l and subset_data$l_Squeeze
t = -2.0647, df = 18, p-value = 0.05367
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.737329639  0.006119774
sample estimates:
      cor 
-0.437586 
cor.test(subset_data$FPPA_l, subset_data$l_Pull)

    Pearson's product-moment correlation

data:  subset_data$FPPA_l and subset_data$l_Pull
t = -0.68953, df = 18, p-value = 0.4993
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.5629748  0.3036582
sample estimates:
       cor 
-0.1604188 
# Subset the data where group is u14s (L)
subset_data <- all_norm[all_norm$group == "U14s", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_l", "l_Pull", "l_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_l     l_Pull l_Squeeze
FPPA_l     1.0000000 -0.1636214 -0.310094
l_Pull    -0.1636214  1.0000000  0.338969
l_Squeeze -0.3100940  0.3389690  1.000000
print(p_value_matrix)
             FPPA_l    l_Pull l_Squeeze
FPPA_l           NA 0.4556734 0.1498661
l_Pull    0.4556734        NA 0.1135948
l_Squeeze 0.1498661 0.1135948        NA
subset_data <- all_norm[all_norm$group == "U14s", ]
cor.test(subset_data$FPPA_l, subset_data$l_Squeeze)

    Pearson's product-moment correlation

data:  subset_data$FPPA_l and subset_data$l_Squeeze
t = -1.4947, df = 21, p-value = 0.1499
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.6404349  0.1170725
sample estimates:
      cor 
-0.310094 
cor.test(subset_data$FPPA_l, subset_data$l_Pull)

    Pearson's product-moment correlation

data:  subset_data$FPPA_l and subset_data$l_Pull
t = -0.76005, df = 21, p-value = 0.4557
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.5394409  0.2665589
sample estimates:
       cor 
-0.1636214 
# Subset the data where group is u16s (L)
subset_data <- all_norm[all_norm$group == "U16s", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_l", "l_Pull", "l_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_l    l_Pull  l_Squeeze
FPPA_l     1.0000000 0.1681817 -0.1683066
l_Pull     0.1681817 1.0000000  0.4852751
l_Squeeze -0.1683066 0.4852751  1.0000000
print(p_value_matrix)
             FPPA_l    l_Pull l_Squeeze
FPPA_l           NA 0.5828507 0.5825669
l_Pull    0.5828507        NA 0.0927690
l_Squeeze 0.5825669 0.0927690        NA
subset_data <- all_norm[all_norm$group == "U16s", ]
cor.test(subset_data$FPPA_l, subset_data$l_Squeeze)

    Pearson's product-moment correlation

data:  subset_data$FPPA_l and subset_data$l_Squeeze
t = -0.56629, df = 11, p-value = 0.5826
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.6582495  0.4217935
sample estimates:
       cor 
-0.1683066 
cor.test(subset_data$FPPA_l, subset_data$l_Pull)

    Pearson's product-moment correlation

data:  subset_data$FPPA_l and subset_data$l_Pull
t = 0.56586, df = 11, p-value = 0.5829
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.4218991  0.6581767
sample estimates:
      cor 
0.1681817 
# Subset the data where group is u12 (R)
subset_data <- all_norm[all_norm$group == "U12s", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_r", "r_Pull", "r_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
             FPPA_r    r_Pull r_Squeeze
FPPA_r    1.0000000 0.2020055 0.2445594
r_Pull    0.2020055 1.0000000 0.7099020
r_Squeeze 0.2445594 0.7099020 1.0000000
print(p_value_matrix)
             FPPA_r       r_Pull    r_Squeeze
FPPA_r           NA 0.3930591594 0.2987270965
r_Pull    0.3930592           NA 0.0004542765
r_Squeeze 0.2987271 0.0004542765           NA
subset_data <- all_norm[all_norm$group == "U12s", ]
cor.test(subset_data$FPPA_r, subset_data$r_Squeeze)

    Pearson's product-moment correlation

data:  subset_data$FPPA_r and subset_data$r_Squeeze
t = 1.0701, df = 18, p-value = 0.2987
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2219852  0.6199839
sample estimates:
      cor 
0.2445594 
cor.test(subset_data$FPPA_r, subset_data$r_Pull)

    Pearson's product-moment correlation

data:  subset_data$FPPA_r and subset_data$r_Pull
t = 0.87508, df = 18, p-value = 0.3931
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.2641259  0.5916387
sample estimates:
      cor 
0.2020055 
# Subset the data where group is u14 (R)
subset_data <- all_norm[all_norm$group == "U14s", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_r", "r_Pull", "r_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_r     r_Pull r_Squeeze
FPPA_r     1.0000000 -0.1430824 -0.376249
r_Pull    -0.1430824  1.0000000  0.514136
r_Squeeze -0.3762490  0.5141360  1.000000
print(p_value_matrix)
              FPPA_r     r_Pull  r_Squeeze
FPPA_r            NA 0.51485517 0.07681343
r_Pull    0.51485517         NA 0.01208124
r_Squeeze 0.07681343 0.01208124         NA
subset_data <- all_norm[all_norm$group == "U14s", ]
cor.test(subset_data$FPPA_r, subset_data$r_Squeeze)

    Pearson's product-moment correlation

data:  subset_data$FPPA_r and subset_data$r_Squeeze
t = -1.8609, df = 21, p-value = 0.07681
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.68258816  0.04255266
sample estimates:
      cor 
-0.376249 
cor.test(subset_data$FPPA_r, subset_data$r_Pull)

    Pearson's product-moment correlation

data:  subset_data$FPPA_r and subset_data$r_Pull
t = -0.6625, df = 21, p-value = 0.5149
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.5243585  0.2859870
sample estimates:
       cor 
-0.1430824 
# Subset the data where group is u16 (R)
subset_data <- all_norm[all_norm$group == "U16s", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_r", "r_Pull", "r_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_r     r_Pull r_Squeeze
FPPA_r     1.0000000 -0.1328858 0.2653095
r_Pull    -0.1328858  1.0000000 0.1497676
r_Squeeze  0.2653095  0.1497676 1.0000000
print(p_value_matrix)
             FPPA_r    r_Pull r_Squeeze
FPPA_r           NA 0.6651764 0.3810001
r_Pull    0.6651764        NA 0.6252987
r_Squeeze 0.3810001 0.6252987        NA
subset_data <- all_norm[all_norm$group == "U16s", ]
cor.test(subset_data$FPPA_r, subset_data$r_Squeeze)

    Pearson's product-moment correlation

data:  subset_data$FPPA_r and subset_data$r_Squeeze
t = 0.91264, df = 11, p-value = 0.381
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.3345861  0.7121863
sample estimates:
      cor 
0.2653095 
cor.test(subset_data$FPPA_r, subset_data$r_Pull)

    Pearson's product-moment correlation

data:  subset_data$FPPA_r and subset_data$r_Pull
t = -0.44468, df = 11, p-value = 0.6652
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 -0.6372154  0.4511305
sample estimates:
       cor 
-0.1328858 
#not used in study
result_asym <- rcorr(as.matrix(all_asym[, c("right","left", "pull_asym", "squeeze_asym")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result_asym$r

# Extract the p-value matrix
p_value_matrix <- result_asym$P

# Print the correlation and p-value matrices
print(correlation_matrix)
                   right       left  pull_asym squeeze_asym
right         1.00000000 0.47672487  0.1256906  -0.01831602
left          0.47672487 1.00000000  0.2101742   0.06027983
pull_asym     0.12569063 0.21017416  1.0000000  -0.11988398
squeeze_asym -0.01831602 0.06027983 -0.1198840   1.00000000
print(p_value_matrix)
                    right         left pull_asym squeeze_asym
right                  NA 0.0002036826 0.3559885    0.8934150
left         0.0002036826           NA 0.1200061    0.6589810
pull_asym    0.3559884693 0.1200060612        NA    0.3788185
squeeze_asym 0.8934149522 0.6589809603 0.3788185           NA
#not used in study
cor(averages[, c("FPPA_r", "r_Pull", "r_Squeeze")], method = "pearson")
              FPPA_r     r_Pull  r_Squeeze
FPPA_r     1.0000000 -0.3988677 -0.0230643
r_Pull    -0.3988677  1.0000000  0.9259641
r_Squeeze -0.0230643  0.9259641  1.0000000
cor(averages[, c("FPPA_l", "l_Pull", "l_Squeeze")], method = "pearson")
             FPPA_l    l_Pull l_Squeeze
FPPA_l    1.0000000 0.8467196 0.9926955
l_Pull    0.8467196 1.0000000 0.7763459
l_Squeeze 0.9926955 0.7763459 1.0000000
result_normr <- rcorr(as.matrix(all_norm[, c("FPPA_r", "r_Pull", "r_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result_normr$r

# Extract the p-value matrix
p_value_matrix <- result_normr$P

# Print the correlation and p-value matrices
print(correlation_matrix)
               FPPA_r      r_Pull   r_Squeeze
FPPA_r     1.00000000 -0.03210262 -0.06774889
r_Pull    -0.03210262  1.00000000  0.51744880
r_Squeeze -0.06774889  0.51744880  1.00000000
print(p_value_matrix)
             FPPA_r       r_Pull    r_Squeeze
FPPA_r           NA 8.143049e-01 6.198082e-01
r_Pull    0.8143049           NA 4.430596e-05
r_Squeeze 0.6198082 4.430596e-05           NA
result_norml <- rcorr(as.matrix(all_norm[, c("FPPA_l", "l_Pull", "l_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result_norml$r

# Extract the p-value matrix
p_value_matrix <- result_norml$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_l     l_Pull  l_Squeeze
FPPA_l     1.0000000 -0.0848759 -0.2880410
l_Pull    -0.0848759  1.0000000  0.3868289
l_Squeeze -0.2880410  0.3868289  1.0000000
print(p_value_matrix)
              FPPA_l      l_Pull   l_Squeeze
FPPA_l            NA 0.533973801 0.031339221
l_Pull    0.53397380          NA 0.003228937
l_Squeeze 0.03133922 0.003228937          NA
#Not used in study
# Subset the data where leg dominance is right (R)
subset_data <- all_norm[all_norm$Leg_dominance == "right", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_r", "r_Pull", "r_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
               FPPA_r     r_Pull   r_Squeeze
FPPA_r     1.00000000 0.04826194 -0.05500949
r_Pull     0.04826194 1.00000000  0.50998177
r_Squeeze -0.05500949 0.50998177  1.00000000
print(p_value_matrix)
             FPPA_r      r_Pull   r_Squeeze
FPPA_r           NA 0.739265654 0.704372269
r_Pull    0.7392657          NA 0.000154851
r_Squeeze 0.7043723 0.000154851          NA
# Not used in study
# Subset the data where leg dominance is right (L)
subset_data <- all_norm[all_norm$Leg_dominance == "right", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_l", "l_Pull", "l_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_l     l_Pull  l_Squeeze
FPPA_l     1.0000000 -0.1371169 -0.2841553
l_Pull    -0.1371169  1.0000000  0.3584524
l_Squeeze -0.2841553  0.3584524  1.0000000
print(p_value_matrix)
             FPPA_l    l_Pull l_Squeeze
FPPA_l           NA 0.3423488 0.0455115
l_Pull    0.3423488        NA 0.0105854
l_Squeeze 0.0455115 0.0105854        NA
# Not used in study
# Subset the data where leg dominance is left (R)
subset_data <- all_norm[all_norm$Leg_dominance == "left", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_r", "r_Pull", "r_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
               FPPA_r     r_Pull   r_Squeeze
FPPA_r     1.00000000 -0.4700289 -0.04591746
r_Pull    -0.47002894  1.0000000  0.59929630
r_Squeeze -0.04591746  0.5992963  1.00000000
print(p_value_matrix)
             FPPA_r    r_Pull r_Squeeze
FPPA_r           NA 0.3468777 0.9311722
r_Pull    0.3468777        NA 0.2086760
r_Squeeze 0.9311722 0.2086760        NA
# Not used in study
# Subset the data where leg dominance is left (L)
subset_data <- all_norm[all_norm$Leg_dominance == "left", ]

# Calculate the correlation matrix and p-values
result <- rcorr(as.matrix(subset_data[, c("FPPA_l", "l_Pull", "l_Squeeze")]), type = "pearson")

# Extract the correlation matrix
correlation_matrix <- result$r

# Extract the p-value matrix
p_value_matrix <- result$P

# Print the correlation and p-value matrices
print(correlation_matrix)
              FPPA_l    l_Pull  l_Squeeze
FPPA_l     1.0000000 0.4362153 -0.4915000
l_Pull     0.4362153 1.0000000  0.5227608
l_Squeeze -0.4915000 0.5227608  1.0000000
print(p_value_matrix)
             FPPA_l    l_Pull l_Squeeze
FPPA_l           NA 0.3871794 0.3221164
l_Pull    0.3871794        NA 0.2872885
l_Squeeze 0.3221164 0.2872885        NA
#Inter-rater reliability testing
library(readxl)
library(psych)

Attaching package: 'psych'
The following object is masked from 'package:Hmisc':

    describe
The following objects are masked from 'package:ggplot2':

    %+%, alpha
reliability <- read_excel("FPPA_data.xlsx", sheet = "Reliability")

reliability <- subset(reliability, select = -c(Difference))
head(reliability)
# A tibble: 6 × 2
  Original Remeasure
     <dbl>     <dbl>
1    21.4      22.4 
2    12.5      12.1 
3     7.99      7.36
4    16.2      15.8 
5    10.8      12.0 
6     7.78      8.21
# Perform normality tests on 'Original' and 'Remeasure'
shapiro.test(reliability$Original)

    Shapiro-Wilk normality test

data:  reliability$Original
W = 0.9589, p-value = 0.2903
shapiro.test(reliability$Remeasure)

    Shapiro-Wilk normality test

data:  reliability$Remeasure
W = 0.95704, p-value = 0.2598
# Calculate Pearson correlation between the two measures as a preliminary check
cor.test(reliability$Original, reliability$Remeasure, method = "pearson")

    Pearson's product-moment correlation

data:  reliability$Original and reliability$Remeasure
t = 31.034, df = 28, p-value < 2.2e-16
alternative hypothesis: true correlation is not equal to 0
95 percent confidence interval:
 0.9699889 0.9932837
sample estimates:
      cor 
0.9857728 
# Calculate ICC using the psych package
icc_result <- ICC(reliability)

# Print all ICC results (this will give various ICC values, including ICC(3,1))
print(icc_result)
Call: ICC(x = reliability)

Intraclass correlation coefficients 
                         type  ICC   F df1 df2       p lower bound upper bound
Single_raters_absolute   ICC1 0.99 133  29  30 1.1e-24        0.97        0.99
Single_random_raters     ICC2 0.99 138  29  29 3.2e-24        0.97        0.99
Single_fixed_raters      ICC3 0.99 138  29  29 3.2e-24        0.97        0.99
Average_raters_absolute ICC1k 0.99 133  29  30 1.1e-24        0.98        1.00
Average_random_raters   ICC2k 0.99 138  29  29 3.2e-24        0.98        1.00
Average_fixed_raters    ICC3k 0.99 138  29  29 3.2e-24        0.98        1.00

 Number of subjects = 30     Number of Judges =  2
See the help file for a discussion of the other 4 McGraw and Wong estimates,
# Extract the ICC value for ICC(3,1) - single measures, absolute agreement
# In the psych package's ICC function, ICC(3,1) is typically the 3rd row
icc_value <- icc_result$results[3, "ICC"]
print(paste("ICC(3,1):", icc_value))
[1] "ICC(3,1): 0.985575138145207"
# Number of subjects (or pairs)
n <- nrow(reliability)

# Calculate Standard Error (SE) for ICC(3,1)
SE_ICC <- sqrt((1 - icc_value)^2 / (n - 1))

# Print the Standard Error
print(paste("Standard Error (SE) of ICC(3,1):", SE_ICC))
[1] "Standard Error (SE) of ICC(3,1): 0.00267862960028312"