9deportes

Published

May 5, 2024

crees que podríamos hacer un análisis multivariante donde se pueda observar todos los deportes por separado para mujeres y hombres por separado?? con C.I. 95% también sería interesante poder comparar cuándo “sube más el cortisol de 0 a 30” si los días de descanso (rest) o los días de competición (Comp)??

Carga de datos

library(tidyverse)
Warning: package 'ggplot2' was built under R version 4.3.3
Warning: package 'tidyr' was built under R version 4.3.3
Warning: package 'dplyr' was built under R version 4.3.2
Warning: package 'stringr' was built under R version 4.3.2
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.4     ✔ readr     2.1.4
✔ 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(ggsignif)
library(DT)
Warning: package 'DT' was built under R version 4.3.2
devtools::load_all("../ggstatsplot-main")
ℹ Loading ggstatsplot
Registered S3 method overwritten by 'ggside':
  method from   
  +.gg   ggplot2
Warning: package 'testthat' was built under R version 4.3.2
You can cite this package as:
     Patil, I. (2021). Visualizations with statistical details: The 'ggstatsplot' approach.
     Journal of Open Source Software, 6(61), 3167, doi:10.21105/joss.03167
Warning: package 'statsExpressions' was built under R version 4.3.3
#1library(ggstatsplot)
library(lme4)
Warning: package 'lme4' was built under R version 4.3.2
Loading required package: Matrix
Warning: package 'Matrix' was built under R version 4.3.2

Attaching package: 'Matrix'

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

    expand, pack, unpack
library(lmerTest)
Warning: package 'lmerTest' was built under R version 4.3.2

Attaching package: 'lmerTest'

The following object is masked from 'package:lme4':

    lmer

The following object is masked from 'package:stats':

    step
theme_set(theme_minimal())
miTema <-theme_get()
#miTema <-theme_get() +
#theme(axis.text.x = element_text(angle = 0, vjust = 0, hjust=1),legend.position = "none")
theme_set(miTema)

df=readxl::read_xlsx("CAR_PNEC_2.xlsx",1) %>% 
  mutate(ID=1:nrow(.),
         IMC=round(IMC,2),
         
         Cluster=as.factor(sprintf("%d_%d",Sport,Cluster))) %>%
  select(ID,Cluster,everything()) %>%
  mutate(CORTinc_rest=round(CORT_30_rest-CORT_Awak_rest,3),
         CORTinc_comp=round(CORT_30_comp-CORT_awak_comp,3),
         CORTincDif=round(CORTinc_comp-CORTinc_rest,3)) %>% 
  mutate(Sport=factor(Sport, 
                         levels=1:8,
                         labels=c("Hockey","Handball","e-Sports","Swimming", "Football", "Athletism", "Badminton","Judo"))) %>% 
  mutate(Sport = forcats::fct_relevel(Sport,
  "Swimming", "Athletism", "Judo", "Badminton", "Football", "Hockey", "Handball", "e-Sports"),
         IT=factor(IT,labels=c("Individual","Team")),
         GENDER=factor(GENDER,labels=c("Female","Male"))) %>% 
         mutate(Clasificacion=case_when(
           Sport=="e-Sports" ~ 3,
           IT =="Individual" ~ 1,
           TRUE ~2
         ),
         Clasificacion=factor(Clasificacion,levels=1:3,labels=c("Individual","Team","e-Sports"))) %>% 
  select(ID:GENDER,Clasificacion,starts_with("CORTinc"),everything())
df %>% datatable()

Abril de 2024

Vamos a dejar temporalmente fuera a los e-sports. Segumos con el resto.

df=df %>% filter(Sport!="e-Sports")

¿La respuesta al cortisol está relacionada con las exigencias del deportista al empezar el día comparado con el día de descanso.?

Todos los días de competición han sido dias importantes (salvo quizás no tanto Atletismo y natación).

Es posible que en el futbol la variabilidad sea relacionada con ser suplente, portero, …

Llamamos repuesta al cortisol a la diferencia entre los 30 minutos y el despertar (Salience/Slope)

Queremos comparar los slopes INTRA entre dias de descanso y dias de competición.

Deportes individuales vs deportes de equipo.

Las demandas cognitivs produicen respuestas anticipatorias. Los equipos de e-sports no tienen ningun esfuerzo físico, pero si mental. Queremos comparar e-sports vs individuales.

Discriptiva general de qué diferencia hay en los cambios entre dias de competicion y dias normales (CORTinc_Dif)

Dado que suele haber ciertos incrementos a los 30 minutos de despertarse, y tenemos dias de competición y de descanso, vamos a llamar CORTinc_Dif a la diferencia entre los respectivos incrementos de cortisol a los 30 minutos de despertarse entre dias de competición y días de descanso. Exploremos la variable en los diferentes deportes y vamos a añadir unos contrastes simples entre ellos:

Tras corregir por las diferencias de variabilidad con la prueba de Welch aparentemente los que experimentan cambios más altos entre dias de competición son los jugadores de badminton, que presentan diferencias significativas con respecto a los de atletismo y natación, que son los que experimentan menos cambios.

El coeficiente omega cuadrado parcial=0.32 indica que aproximadamente el 32% de la variabilidad en la variable dependiente se puede explicar por la diferencia entre los tipos de deporte, y visto como size-effect es un valor de efecto grande el que tiene el deporte en los cambios experimentados (valores mayores que 0.06 se consideran medianos y mayores que 0.14 grandes. Incluso el intervalo de confianza del 95% deja claro que el tamaño de efecto es de mediano a grande tirando más a grande.)

Deportes individuales vs deportes de equipo.

Pero el objetivo no era ese sino comparar deportes individuales y de grupo. Vamos a hacerlo de la forma más simple comparandolos directamente tal cual sin tener en cuenta otras consideraciones:

ggbetweenstats(
  data = df,
  x = IT,
  y = CORTincDif,
    var.equal=FALSE,
  bf.message=FALSE,
    point.args= list(color="gray"),
  ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE),
  centrality.plotting = FALSE,
  centrality.point.args=list(alpha=0.5),
  centrality.label.args=list(fill = "#FFFFFF88",
                             max.overlaps = getOption("ggrepel.max.overlaps", default = 20)),
  ylab="Differences in salivary cortisol",
  xlab=""

)

Ahora vamos a hacer lo mismo usando una prueba no paramétrica:

ggbetweenstats(
  data = df,
  x = IT,
  y = CORTincDif,
  type="np",
  bf.message=FALSE,
    point.args= list(color="gray"),
  ggsignif.args = list(textsize = 3, tip_length = 0.01, na.rm = TRUE),
  centrality.plotting = FALSE,
  centrality.point.args=list(alpha=0.5),
  centrality.label.args=list(fill = "#FFFFFF88",
                             max.overlaps = getOption("ggrepel.max.overlaps", default = 20)),
  ylab="Differences in salivary cortisol",
  xlab=""
)

Tal cual, en la comparación no se aprecia diferencias significativas. Pero hay algo que no tenemos en cuenta… Los deportistas pertenecen a diferentes deportes y podría haber un efecto concreto de cada deporte (cluster) y lo que buscamos es si, más allá de ese efecto del deporte, hay algo que diferencie a los deportes individuales de los de equipo.

Vamos a hacer un modelo mixto con el deporte como factor aleatorio y el tipo de deporte como factor fijo:

lmer(CORTincDif ~ IT + (1 | Sport), data = df) %>% summary()
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: CORTincDif ~ IT + (1 | Sport)
   Data: df

REML criterion at convergence: 1267.3

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.6223 -0.4588 -0.1229  0.2749  5.7659 

Random effects:
 Groups   Name        Variance Std.Dev.
 Sport    (Intercept)  1.944   1.394   
 Residual             35.190   5.932   
Number of obs: 198, groups:  Sport, 7

Fixed effects:
            Estimate Std. Error     df t value Pr(>|t|)  
(Intercept)   3.3253     0.9399 5.7577   3.538   0.0131 *
ITTeam        0.7799     1.4281 5.1560   0.546   0.6078  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
       (Intr)
ITTeam -0.658

En este modelo el intercept nos mide cuanto aumenta el cortisol en los dias de competición en los deportes individuales y es 3.3253 (EE 0.94, p=0.013), pero en los de equipo, aunque el cambio es mayor (hay que añadirele 0.78), no es significativamente diferente a los individuales.

Sí que los deportes son diferentes entre sí (como vimos badminton vs Natación), sí que hay un aumento los días de competición con respecto a los de descanso, pero no hay un cambio especial entre dias de competición y descanso entre deportes de equipo e individuales.

Segmento por sexos, no vaya a ser que las mujeres vayan por un lado completamente diferente de los hombres:

lmer(CORTincDif ~ IT + (1 | Sport), data = df %>% filter(GENDER=="Male")) %>% summary()
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: CORTincDif ~ IT + (1 | Sport)
   Data: df %>% filter(GENDER == "Male")

REML criterion at convergence: 902

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.2834 -0.4320 -0.1574  0.2367  5.0485 

Random effects:
 Groups   Name        Variance Std.Dev.
 Sport    (Intercept)  0.1689  0.411   
 Residual             46.0613  6.787   
Number of obs: 136, groups:  Sport, 6

Fixed effects:
            Estimate Std. Error     df t value Pr(>|t|)  
(Intercept)   3.3811     1.0331 4.2197   3.273   0.0284 *
ITTeam        0.2103     1.3020 0.7579   0.161   0.9040  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
       (Intr)
ITTeam -0.793
lmer(CORTincDif ~ IT + (1 | Sport), data = df %>% filter(GENDER=="Female")) %>% summary()
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: CORTincDif ~ IT + (1 | Sport)
   Data: df %>% filter(GENDER == "Female")

REML criterion at convergence: 334.7

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-1.5172 -0.7197 -0.1120  0.4852  2.7933 

Random effects:
 Groups   Name        Variance Std.Dev.
 Sport    (Intercept)  3.464   1.861   
 Residual             12.999   3.605   
Number of obs: 62, groups:  Sport, 5

Fixed effects:
            Estimate Std. Error    df t value Pr(>|t|)  
(Intercept)    3.362      1.084 3.263   3.102   0.0475 *
ITTeam         2.036      2.360 2.984   0.863   0.4520  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
       (Intr)
ITTeam -0.459

Mirando los sexos por separado, no se ve nada diferente a lo que vimos en el global. No hay diferencias significativas entre deportes individuales y de equipo en la respuesta al cortisol entre dias de competición y descanso. Solo parece que los hombres experimentan menos cambios que las mujeres. Veamos un modelo que desglose por tipo de deporte y sexo:

lmer(CORTincDif ~ GENDER+ IT + (1 | Sport), data = df) %>% summary()
Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: CORTincDif ~ GENDER + IT + (1 | Sport)
   Data: df

REML criterion at convergence: 1265.1

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-2.6126 -0.4559 -0.1343  0.2983  5.7548 

Random effects:
 Groups   Name        Variance Std.Dev.
 Sport    (Intercept)  1.87    1.367   
 Residual             35.36    5.947   
Number of obs: 198, groups:  Sport, 7

Fixed effects:
            Estimate Std. Error      df t value Pr(>|t|)  
(Intercept)   3.5417     1.0790  8.4853   3.282   0.0103 *
GENDERMale   -0.4300     1.1058 96.3268  -0.389   0.6982  
ITTeam        0.8784     1.4398  5.4446   0.610   0.5664  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation of Fixed Effects:
           (Intr) GENDER
GENDERMale -0.506       
ITTeam     -0.461 -0.191

No vemos nada diferente a lo anterior. No hay diferencias significativas entre deportes individuales y de equipo en la respuesta al cortisol entre dias de competición y descanso. Sí, el cortisol sube significativamente más los dias de competición, se observa más en las mujeres y más en los deportes de equipo, pero no significativo con respecto a los hombres y los deportes individuales respectivamente.

Visión en modo de “Slopes”, incrementos de cortisol según deportes y días de competición

Vamos a hacer un seguimiento de cada individuo y ver como varía su cortisol en los días de competición y descanso, aunque este tipo de gráficos es más adecuado para muestras pequeñas que estas muestras tan grandes y donde hay riesgo de ver más bien una maraña de líneas.

Vamos a pasar la base de datos al formato tidy

dfLong=df %>% pivot_longer(-c(ID:IMC)) %>% 
  mutate(name=str_replace(name,"^CORT_","")) %>% 
    mutate(name=str_replace(name,"^[Aa]wak_","m00_"),
           name=str_replace(name,"^30_","m30_")) %>% 
  separate(name,into=c("time","activity")) %>% 
  mutate(time=as.factor(time),activity=as.factor(activity)) %>% 
  rename(Cortisol=value)
dfLong  %>% datatable()
dfLong %>% names()
 [1] "ID"            "Cluster"       "Sport"         "IT"           
 [5] "GENDER"        "Clasificacion" "CORTinc_rest"  "CORTinc_comp" 
 [9] "CORTincDif"    "IMC"           "time"          "activity"     
[13] "Cortisol"     
tipoDia="comp"



#thisSport="Badminton"
#thisActivity="comp"
#thisGender="Male"

graficoIntra=function(thisSport,thisActivity,thisGender,...){
   ggwithinstats(
  data = dfLong %>% filter(Sport==thisSport,activity==thisActivity,GENDER==thisGender),
  x = time,
  y = Cortisol,
  type = "np",
  effsize.type = "d",
  conf.level = 0.99,
  title = str_c(thisSport,"/",thisActivity,"/",thisGender),
  package = "ggsci",
  palette = "nrc_npg"
)+  scale_y_log10()+coord_cartesian(ylim=c(1.5,40))
}

#graficoIntra(thisSport,thisActivity,thisGender)
#dfLong %>% count(IT)

dfOrden=dfLong %>% distinct(IT,Sport,GENDER,activity) %>% arrange(IT,Sport,GENDER,rev(activity)) %>% 
  transmute(IT=IT,thisSport=Sport,thisActivity=activity,thisGender=GENDER) %>% 
  mutate(grafico=pmap(.,graficoIntra)) #%>% 
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
Scale for y is already present.
Adding another scale for y, which will replace the existing scale.
#  slice(-c(21,22))

#dfOrden  %>% pluck("grafico")

Deportes de equipo

dfOrden %>% filter(IT=="Team") %>% pull(grafico) %>% keep(negate(is.null)) %>% gridExtra::grid.arrange(grobs=.,ncol=2)

Lo de arriba va en otro formato: y CORTISOL x: 0/30 CATEGORIAS: sEXO, cOMP/DESCANSO Medias+/EE

dfSummary1=df %>% select(Sport,Type=Clasificacion, 
                      CORT_Awak_rest, CORT_30_rest, 
                      CORT_awak_comp, CORT_30_comp) %>% 
  pivot_longer(-c(Sport,Type)) %>% 
  group_by(Sport,Type,name) %>% 
  summarise(mean=mean(value),se=sd(value)/sqrt(n()), n=n(),.groups = 'drop') %>% 
  mutate(Moment=ifelse(str_detect(name,"wak"),0,1),
         Day=ifelse(str_detect(name,"comp"),1,0)) %>% 
  mutate(Moment=ifelse(Moment==1,"30 min","Awake"),
         Moment=forcats::fct_relevel(Moment,"Awake","30 min"),
         Day=ifelse(Day==1,"Comp.","Rest")) %>% 
  select(Sport,Type,Moment,Day,everything())
  

dfSummary1
# A tibble: 28 × 8
   Sport     Type       Moment Day   name            mean    se     n
   <fct>     <fct>      <fct>  <chr> <chr>          <dbl> <dbl> <int>
 1 Swimming  Individual 30 min Comp. CORT_30_comp    7.47 0.558    20
 2 Swimming  Individual 30 min Rest  CORT_30_rest    4.74 0.410    20
 3 Swimming  Individual Awake  Rest  CORT_Awak_rest  3.12 0.329    20
 4 Swimming  Individual Awake  Comp. CORT_awak_comp  4.15 0.360    20
 5 Athletism Individual 30 min Comp. CORT_30_comp    7.93 0.533    24
 6 Athletism Individual 30 min Rest  CORT_30_rest    6.53 0.559    24
 7 Athletism Individual Awake  Rest  CORT_Awak_rest  4.74 0.423    24
 8 Athletism Individual Awake  Comp. CORT_awak_comp  4.28 0.440    24
 9 Judo      Individual 30 min Comp. CORT_30_comp    9.98 0.638    15
10 Judo      Individual 30 min Rest  CORT_30_rest    5.18 0.420    15
# ℹ 18 more rows

dfSummary2=df %>% select(GENDER,Sport,Type=Clasificacion, 
                      CORT_Awak_rest, CORT_30_rest, 
                      CORT_awak_comp, CORT_30_comp) %>% 
  pivot_longer(-c(GENDER,Sport,Type)) %>% 
  group_by(GENDER,Sport,Type,name) %>% 
  summarise(mean=mean(value),se=sd(value)/sqrt(n()), n=n(),.groups = 'drop') %>% 
  mutate(Moment=ifelse(str_detect(name,"wak"),0,1),
         Day=ifelse(str_detect(name,"comp"),1,0)) %>% 
  mutate(Moment=ifelse(Moment==1,"30 min","Awake"),
         Moment=forcats::fct_relevel(Moment,"Awake","30 min"),
         Day=ifelse(Day==1,"Comp.","Rest")) %>% 
  select(GENDER,Sport,Type,Moment,Day,everything())
  

dfSummary2
# A tibble: 44 × 9
   GENDER Sport     Type       Moment Day   name            mean    se     n
   <fct>  <fct>     <fct>      <fct>  <chr> <chr>          <dbl> <dbl> <int>
 1 Female Swimming  Individual 30 min Comp. CORT_30_comp    7.57 0.831     8
 2 Female Swimming  Individual 30 min Rest  CORT_30_rest    5.43 0.792     8
 3 Female Swimming  Individual Awake  Rest  CORT_Awak_rest  3.89 0.597     8
 4 Female Swimming  Individual Awake  Comp. CORT_awak_comp  4.69 0.616     8
 5 Female Athletism Individual 30 min Comp. CORT_30_comp    8.23 0.856    13
 6 Female Athletism Individual 30 min Rest  CORT_30_rest    7.38 0.839    13
 7 Female Athletism Individual Awake  Rest  CORT_Awak_rest  5.55 0.657    13
 8 Female Athletism Individual Awake  Comp. CORT_awak_comp  4.56 0.659    13
 9 Female Judo      Individual 30 min Comp. CORT_30_comp   10.7  0.707     7
10 Female Judo      Individual 30 min Rest  CORT_30_rest    5.00 0.503     7
# ℹ 34 more rows

Tal vez no deberían pintar nada en este gráfico los deportes donde no hay simultáneamente hombres y mujeres (curiosamente son todos deportes de equipo).

Está sería la versión desglosandolos en dos gráficos: Uno para deportes individuales (donde es posible comparar sexos), y otro para deportes de equipo (donde no es posible comparar sexos):

Deportes individuales, posible comparar géneros

Una versión

Deportes de equipo, no es posible comparar géneros

Ahora vamos a por versión equivalente, pero comparando sexos:

Esto se puede entender añadiendo a todo el mundo en general o solo añadir aquellos deportes donde haya a la vez hombres y mujeres, controlando por el deporte que practican y estudiando cuanto se desvían con respecto a la media del mismo.

El primero es más simple, pero el segundo nos permite aislarnos del deporte en concreto, aunque perdemos casos. Lo vamos ahacer de las dos formas y luego ya veremos qué es mejor contar:

Comparación por sexos sin más:

dfSummary3=df %>% select(GENDER, 
                      CORT_Awak_rest, CORT_30_rest, 
                      CORT_awak_comp, CORT_30_comp) %>% 
  pivot_longer(-c(GENDER)) %>% 
  group_by(GENDER,name) %>% 
  summarise(mean=mean(value),se=sd(value)/sqrt(n()), n=n(),.groups = 'drop') %>% 
  mutate(Moment=ifelse(str_detect(name,"wak"),0,1),
         Day=ifelse(str_detect(name,"comp"),1,0)) %>% 
  mutate(Moment=ifelse(Moment==1,"30 min","Awake"),
         Moment=forcats::fct_relevel(Moment,"Awake","30 min"),
         Day=ifelse(Day==1,"Comp.","Rest")) %>% 
  select(GENDER,Moment,Day,everything())
  

dfSummary3
# A tibble: 8 × 7
  GENDER Moment Day   name            mean    se     n
  <fct>  <fct>  <chr> <chr>          <dbl> <dbl> <int>
1 Female 30 min Comp. CORT_30_comp   10.8  0.621    62
2 Female 30 min Rest  CORT_30_rest    6.54 0.336    62
3 Female Awake  Rest  CORT_Awak_rest  5.40 0.337    62
4 Female Awake  Comp. CORT_awak_comp  5.52 0.373    62
5 Male   30 min Comp. CORT_30_comp   10.3  0.578   136
6 Male   30 min Rest  CORT_30_rest    5.72 0.221   136
7 Male   Awake  Rest  CORT_Awak_rest  4.94 0.273   136
8 Male   Awake  Comp. CORT_awak_comp  6.05 0.369   136

Comparacion por sexos, pero solo en los deportes donde haya a la vez en nuestro estudio hombres y mujeres:

dfSummary4=df %>% filter( Sport %in% c("Swimming","Athletism","Judo","Badminton")) %>%
  select(GENDER, 
                      CORT_Awak_rest, CORT_30_rest, 
                      CORT_awak_comp, CORT_30_comp) %>% 
  pivot_longer(-c(GENDER)) %>% 
  group_by(GENDER,name) %>% 
  summarise(mean=mean(value),se=sd(value)/sqrt(n()), n=n(),.groups = 'drop') %>% 
  mutate(Moment=ifelse(str_detect(name,"wak"),0,1),
         Day=ifelse(str_detect(name,"comp"),1,0)) %>% 
  mutate(Moment=ifelse(Moment==1,"30 min","Awake"),
         Moment=forcats::fct_relevel(Moment,"Awake","30 min"),
         Day=ifelse(Day==1,"Comp.","Rest")) %>% 
  select(GENDER,Moment,Day,everything())
  

dfSummary4
# A tibble: 8 × 7
  GENDER Moment Day   name            mean    se     n
  <fct>  <fct>  <chr> <chr>          <dbl> <dbl> <int>
1 Female 30 min Comp. CORT_30_comp   10.8  0.764    48
2 Female 30 min Rest  CORT_30_rest    7.06 0.385    48
3 Female Awake  Rest  CORT_Awak_rest  6.01 0.385    48
4 Female Awake  Comp. CORT_awak_comp  5.97 0.451    48
5 Male   30 min Comp. CORT_30_comp   10.3  0.786    45
6 Male   30 min Rest  CORT_30_rest    6.25 0.463    45
7 Male   Awake  Rest  CORT_Awak_rest  5.04 0.533    45
8 Male   Awake  Comp. CORT_awak_comp  5.75 0.514    45

Como en el anterior, no hay nada que diga que merezca gran cosa diferenciar por sexos. Para quitarnos las últimas dudas, vamos a hacer lo mismo que este, pero controlando por el sexo. Nos vamos a quedar con los residuos del modelo, que está en la misma escala que la variable actual, pero centrado en cero.

Comparación de hombres y mujeres, controlando por deporte

df2= df %>% filter( Sport %in% c("Swimming","Athletism","Judo","Badminton")) %>% 
    select(ID,GENDER, Sport, 
                      CORT_Awak_rest, CORT_30_rest, 
                      CORT_awak_comp, CORT_30_comp) %>% 
  pivot_longer(-c(ID,GENDER,Sport)) %>%  
  mutate(Moment=ifelse(str_detect(name,"wak"),0,1),
         Day=ifelse(str_detect(name,"comp"),1,0)) %>% 
  mutate(Moment=ifelse(Moment==1,"30 min","Awake"),
         Moment=forcats::fct_relevel(Moment,"Awake","30 min"),
         Day=ifelse(Day==1,"Comp.","Rest")) %>% select(ID,GENDER,Sport,Moment,Day,value)
df2
# A tibble: 372 × 6
      ID GENDER Sport    Moment Day   value
   <int> <fct>  <fct>    <fct>  <chr> <dbl>
 1    63 Female Swimming Awake  Rest   5.52
 2    63 Female Swimming 30 min Rest   6.46
 3    63 Female Swimming Awake  Comp.  4.26
 4    63 Female Swimming 30 min Comp.  7.12
 5    64 Female Swimming Awake  Rest   6.72
 6    64 Female Swimming 30 min Rest   6.79
 7    64 Female Swimming Awake  Comp.  7.02
 8    64 Female Swimming 30 min Comp.  9.12
 9    65 Female Swimming Awake  Rest   4.37
10    65 Female Swimming 30 min Rest   3.95
# ℹ 362 more rows
modelo_mixto=lme4::lmer(value ~  + (1|ID) +(1|Sport) , data=df2)




df2[["Residual"]]=resid(modelo_mixto)
df2
# A tibble: 372 × 7
      ID GENDER Sport    Moment Day   value Residual
   <int> <fct>  <fct>    <fct>  <chr> <dbl>    <dbl>
 1    63 Female Swimming Awake  Rest   5.52    0.183
 2    63 Female Swimming 30 min Rest   6.46    1.12 
 3    63 Female Swimming Awake  Comp.  4.26   -1.08 
 4    63 Female Swimming 30 min Comp.  7.12    1.78 
 5    64 Female Swimming Awake  Rest   6.72    0.713
 6    64 Female Swimming 30 min Rest   6.79    0.783
 7    64 Female Swimming Awake  Comp.  7.02    1.01 
 8    64 Female Swimming 30 min Comp.  9.12    3.11 
 9    65 Female Swimming Awake  Rest   4.37   -0.818
10    65 Female Swimming 30 min Rest   3.95   -1.24 
# ℹ 362 more rows
dfSummary5=df2 %>% group_by(GENDER,Moment,Day) %>% 
  summarise(mean=mean(Residual),se=sd(Residual)/sqrt(n()), n=n(),.groups = 'drop')


dfSummary5
# A tibble: 8 × 6
  GENDER Moment Day     mean    se     n
  <fct>  <fct>  <chr>  <dbl> <dbl> <int>
1 Female Awake  Comp. -1.45  0.304    48
2 Female Awake  Rest  -1.41  0.228    48
3 Female 30 min Comp.  3.34  0.556    48
4 Female 30 min Rest  -0.360 0.316    48
5 Male   Awake  Comp. -1.13  0.307    45
6 Male   Awake  Rest  -1.84  0.291    45
7 Male   30 min Comp.  3.47  0.521    45
8 Male   30 min Rest  -0.628 0.320    45

Aquí el eje Y representa lo de siempre pero de forma que 0 es el valor esperado para cada deporte para un dia aleatorio (sea de competición o descanso) y una persona aleatoria (hombre o mujer). Si el valor es positivo, es que el valor observado es mayor que el esperado, y si es negativo, es que es menor. Si acaso diría que parece que un hombre que practique undeporte parece despertar los dias de descanso con un nivel de cortisol algo más bajo que su equivalente del mismo deporte mujer. Pero tampoco es que llame mucho la atención y también podrían decir que hemos mirado mucho para que nos salga algo.

Por mí solo destacaría que al estudiar deportes donde hay hombres y mujeres, no parece que el sexo, tras controlar por deporte valga mucho la pena. En deportista de este nivel lo que importa es la competición.

Cosas antiguas pero que no borramos

Deportes individuales

dfOrden %>% filter(IT=="Individual") %>% pull(grafico) %>% keep(negate(is.null)) %>%  gridExtra::grid.arrange(grobs=.,ncol=2)

Calculos anteriores a partir de aquí

Vamos a representar gráficamente los datos en el formato tidy:

grafico=dfLong %>% ggplot(aes(x=time,y=Cortisol,fill=activity,color=activity))+
  geom_jitter(width=0.25,alpha=0.5)+
  geom_boxplot(alpha=0.25)+
  facet_wrap(GENDER~Clasificacion+Sport,nrow=2)

grafico

Vamos a poner la escala del cortisol en logaritmica para evitar falta de normalidad

grafico+ scale_y_log10()

Cuestiones previas para la tabla 1

Es interesante antes de ir a por los objetivos del estudio chequear si los valores al despertar los dias de competición son como los dias normales. Si lo fuesen podríamos plantearnos tomar como valores de referencia (“00”) la media de los dos. SI no lo fuesen deberíamos tomar como valores de referencia los del despertar de cada día. Haremos los dos análisis y ya veremos cual nos cuenta una historia más interesante.

dfPar= dfLong %>% filter(time=="m00") %>% pivot_wider(names_from="activity",values_from="Cortisol") %>% 
  mutate(dif=comp-rest)
dfPar %>% head() %>% knitr::kable()
ID Cluster Sport IT GENDER Clasificacion CORTinc_rest CORTinc_comp CORTincDif IMC time rest comp dif
1 1_NA Hockey Team Male Team 0.40 4.11 3.71 20.08 m00 4.00 5.59 1.59
2 1_NA Hockey Team Male Team 1.13 4.28 3.15 24.55 m00 2.32 2.50 0.18
3 1_NA Hockey Team Male Team 2.43 4.42 1.99 22.20 m00 2.90 4.23 1.33
4 1_NA Hockey Team Male Team 2.17 6.76 4.59 23.21 m00 4.30 4.74 0.44
5 1_NA Hockey Team Male Team 0.57 6.57 6.00 21.89 m00 4.80 2.97 -1.83
6 1_NA Hockey Team Male Team 2.93 8.56 5.63 24.95 m00 2.50 3.45 0.95
dfPar %>% ggplot(aes(y=dif,x=GENDER,color=IT))+
  geom_jitter(width=0.25,alpha=0.5)+
  geom_boxplot(alpha=0.25)+
  geom_hline(yintercept = 0)+
 facet_wrap(~Clasificacion+Sport,nrow =2) 

Aparentemente se levantan bastante igual sea cual sea el deporte y sexo, y donde aparece una pequeña diferencia la submuestra es pequeña. Sería posible si quisiésemos controlar cierta variabilidad tomar como valor de referencia la media de los dos días. Al menos sabemos que la posibilidad existe.

Cambios entre tiempo m00 y m30mm (diferencias), entre dias de competición y de descanso

dfPar= dfLong %>% mutate(name=str_c(time,"_",activity)) %>%
  select(-activity,-time) %>% 
  pivot_wider(names_from="name",values_from="Cortisol") %>% 
  mutate(dif_comp=m30_comp-m00_comp,
         dif_rest=m30_rest-m00_rest, 
         dif_comprest=dif_comp-dif_rest)
dfPar %>% head() %>% knitr::kable()
ID Cluster Sport IT GENDER Clasificacion CORTinc_rest CORTinc_comp CORTincDif IMC m00_rest m30_rest m00_comp m30_comp dif_comp dif_rest dif_comprest
1 1_NA Hockey Team Male Team 0.40 4.11 3.71 20.08 4.00 4.40 5.59 9.70 4.11 0.40 3.71
2 1_NA Hockey Team Male Team 1.13 4.28 3.15 24.55 2.32 3.45 2.50 6.78 4.28 1.13 3.15
3 1_NA Hockey Team Male Team 2.43 4.42 1.99 22.20 2.90 5.33 4.23 8.65 4.42 2.43 1.99
4 1_NA Hockey Team Male Team 2.17 6.76 4.59 23.21 4.30 6.47 4.74 11.50 6.76 2.17 4.59
5 1_NA Hockey Team Male Team 0.57 6.57 6.00 21.89 4.80 5.37 2.97 9.54 6.57 0.57 6.00
6 1_NA Hockey Team Male Team 2.93 8.56 5.63 24.95 2.50 5.43 3.45 12.01 8.56 2.93 5.63

En formato tidy, estas son las diferencias que podemos estudiar:

dfLongDif=dfPar %>% select(ID:IMC,starts_with("dif")) %>% pivot_longer(-c(ID:IMC)) %>% 
  mutate(name=factor(name,levels=c("dif_rest","dif_comp","dif_comprest"),labels=c("Rest","Competition","Competing - Rest")))
dfLongDif %>% head() %>% knitr::kable()
ID Cluster Sport IT GENDER Clasificacion CORTinc_rest CORTinc_comp CORTincDif IMC name value
1 1_NA Hockey Team Male Team 0.40 4.11 3.71 20.08 Competition 4.11
1 1_NA Hockey Team Male Team 0.40 4.11 3.71 20.08 Rest 0.40
1 1_NA Hockey Team Male Team 0.40 4.11 3.71 20.08 Competing - Rest 3.71
2 1_NA Hockey Team Male Team 1.13 4.28 3.15 24.55 Competition 4.28
2 1_NA Hockey Team Male Team 1.13 4.28 3.15 24.55 Rest 1.13
2 1_NA Hockey Team Male Team 1.13 4.28 3.15 24.55 Competing - Rest 3.15
dfDifAgr0=dfLongDif %>% group_by(Clasificacion,Sport,IT,name) %>% 
  summarise(n=length(value),
            media=mean(value),
            dt=sd(value),
            ee=dt/n,
            ic1=media-qt(0.975,df=n-1)*ee,
            ic2=media+qt(0.975,df=n-1)*ee)%>% ungroup()
`summarise()` has grouped output by 'Clasificacion', 'Sport', 'IT'. You can
override using the `.groups` argument.
dfReferencia1=dfDifAgr0 %>% select(Sport,name,media) %>% filter(name %in% c("Rest")) %>%
  select(-name) %>% 
  group_by(Sport) %>% 
  summarise(vReferencia1=mean(media,na.rm=T)) %>% 
  mutate(vReferencia1=as.integer(ordered(vReferencia1))) %>% 
  arrange(vReferencia1)

dfReferencia2=dfDifAgr0 %>% select(Sport,name,media) %>% filter(name %in% c("Competition")) %>%
  select(-name) %>% 
  group_by(Sport) %>% 
  summarise(vReferencia2=mean(media,na.rm=T)) %>% 
  mutate(vReferencia2=as.integer(ordered(vReferencia2))) %>% 
  arrange(vReferencia2)

dfReferencia3=dfDifAgr0 %>% select(Sport,name,media) %>% filter(name %in% c("Comp-Rest")) %>%
  select(-name) %>% 
  group_by(Sport) %>% 
  summarise(vReferencia3=mean(media,na.rm=T)) %>% 
  mutate(vReferencia3=as.integer(ordered(vReferencia3))) %>% 
  arrange(vReferencia3)


dfDifAgr=dfDifAgr0%>% left_join(dfReferencia1) %>% left_join(dfReferencia2) %>% left_join(dfReferencia3)
Joining with `by = join_by(Sport)`
Joining with `by = join_by(Sport)`
Joining with `by = join_by(Sport)`
dfDifAgr$Sport1=dfDifAgr$Sport %>% forcats::fct_relevel(as.character(dfReferencia1$Sport))
dfDifAgr$Sport2=dfDifAgr$Sport %>% forcats::fct_relevel(as.character(dfReferencia2$Sport))
dfDifAgr$Sport3=dfDifAgr$Sport %>% forcats::fct_relevel(as.character(dfReferencia3$Sport))
dfDifAgr%>% mutate_if(is_double,round %>% partial(digits=3) ) %>% knitr::kable()
Clasificacion Sport IT name n media dt ee ic1 ic2 vReferencia1 vReferencia2 vReferencia3 Sport1 Sport2 Sport3
Individual Swimming Individual Rest 20 1.622 1.748 0.087 1.439 1.805 5 1 NA Swimming Swimming Swimming
Individual Swimming Individual Competition 20 3.319 2.065 0.103 3.103 3.535 5 1 NA Swimming Swimming Swimming
Individual Swimming Individual Competing - Rest 20 1.697 2.271 0.114 1.459 1.935 5 1 NA Swimming Swimming Swimming
Individual Athletism Individual Rest 24 1.789 1.438 0.060 1.665 1.913 7 2 NA Athletism Athletism Athletism
Individual Athletism Individual Competition 24 3.647 1.941 0.081 3.480 3.814 7 2 NA Athletism Athletism Athletism
Individual Athletism Individual Competing - Rest 24 1.858 2.800 0.117 1.617 2.100 7 2 NA Athletism Athletism Athletism
Individual Judo Individual Rest 15 1.461 1.103 0.074 1.303 1.618 4 4 NA Judo Judo Judo
Individual Judo Individual Competition 15 4.526 2.082 0.139 4.228 4.824 4 4 NA Judo Judo Judo
Individual Judo Individual Competing - Rest 15 3.065 2.145 0.143 2.759 3.372 4 4 NA Judo Judo Judo
Individual Badminton Individual Rest 34 0.223 2.416 0.071 0.079 0.368 1 6 NA Badminton Badminton Badminton
Individual Badminton Individual Competition 34 6.321 3.961 0.116 6.084 6.558 1 6 NA Badminton Badminton Badminton
Individual Badminton Individual Competing - Rest 34 6.097 4.433 0.130 5.832 6.362 1 6 NA Badminton Badminton Badminton
Team Football Team Rest 77 0.355 2.877 0.037 0.280 0.429 2 3 NA Football Football Football
Team Football Team Competition 77 3.880 7.535 0.098 3.685 4.075 2 3 NA Football Football Football
Team Football Team Competing - Rest 77 3.525 8.463 0.110 3.306 3.744 2 3 NA Football Football Football
Team Hockey Team Rest 14 1.775 1.262 0.090 1.580 1.970 6 5 NA Hockey Hockey Hockey
Team Hockey Team Competition 14 5.664 2.286 0.163 5.312 6.017 6 5 NA Hockey Hockey Hockey
Team Hockey Team Competing - Rest 14 3.889 1.992 0.142 3.582 4.197 6 5 NA Hockey Hockey Hockey
Team Handball Team Rest 14 1.439 1.111 0.079 1.268 1.611 3 7 NA Handball Handball Handball
Team Handball Team Competition 14 6.837 3.558 0.254 6.288 7.386 3 7 NA Handball Handball Handball
Team Handball Team Competing - Rest 14 5.398 4.418 0.316 4.716 6.080 3 7 NA Handball Handball Handball
dfLongDif %>% ggplot(aes(y=value,x=name,color=name,fill=name))+
geom_jitter(width=0.25,alpha=0.15)+
  geom_boxplot(alpha=0.25)+
  geom_hline(yintercept = 0)+
  facet_grid(rows=vars(IT),cols=vars(Sport))  +
   theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust=1),legend.title=element_blank(),legend.position="top")

dfDifAgr0=dfLongDif %>% group_by(Clasificacion,Sport,IT,name) %>% 
  summarise(n=length(value),
            media=mean(value),
            dt=sd(value),
            ee=dt/n,
            ic1=media-qt(0.975,df=n-1)*ee,
            ic2=media+qt(0.975,df=n-1)*ee)%>% ungroup()
`summarise()` has grouped output by 'Clasificacion', 'Sport', 'IT'. You can
override using the `.groups` argument.
dfReferencia1=dfDifAgr0 %>% select(Sport,name,media) %>% filter(name %in% c("Rest")) %>%
  select(-name) %>% 
  group_by(Sport) %>% 
  summarise(vReferencia1=mean(media,na.rm=T)) %>% 
  mutate(vReferencia1=as.integer(ordered(vReferencia1))) %>% 
  arrange(vReferencia1)

dfReferencia2=dfDifAgr0 %>% select(Sport,name,media) %>% filter(name %in% c("Competition")) %>%
  select(-name) %>% 
  group_by(Sport) %>% 
  summarise(vReferencia2=mean(media,na.rm=T)) %>% 
  mutate(vReferencia2=as.integer(ordered(vReferencia2))) %>% 
  arrange(vReferencia2)

dfReferencia3=dfDifAgr0 %>% select(Sport,name,media) %>% filter(!name %in% c("Competition", "Rest")) %>%
  select(-name) %>% 
  group_by(Sport) %>% 
  summarise(vReferencia3=mean(media,na.rm=T)) %>% 
  mutate(vReferencia3=as.integer(ordered(vReferencia3))) %>% 
  arrange(vReferencia3)


dfDifAgr=dfDifAgr0%>% left_join(dfReferencia1) %>% left_join(dfReferencia2) %>% left_join(dfReferencia3)
Joining with `by = join_by(Sport)`
Joining with `by = join_by(Sport)`
Joining with `by = join_by(Sport)`
dfDifAgr$Sport1=dfDifAgr$Sport %>% forcats::fct_relevel(as.character(dfReferencia1$Sport))
dfDifAgr$Sport2=dfDifAgr$Sport %>% forcats::fct_relevel(as.character(dfReferencia2$Sport))
dfDifAgr$Sport3=dfDifAgr$Sport %>% forcats::fct_relevel(as.character(dfReferencia3$Sport))

dfLongDif=dfLongDif%>% left_join(dfReferencia1) %>% left_join(dfReferencia2) %>% left_join(dfReferencia3)
Joining with `by = join_by(Sport)`
Joining with `by = join_by(Sport)`
Joining with `by = join_by(Sport)`
dfLongDif$Sport1=dfLongDif$Sport %>% forcats::fct_relevel(as.character(dfReferencia1$Sport))
dfLongDif$Sport2=dfLongDif$Sport %>% forcats::fct_relevel(as.character(dfReferencia2$Sport))
dfLongDif$Sport3=dfLongDif$Sport %>% forcats::fct_relevel(as.character(dfReferencia3$Sport))

dfDifAgr%>% mutate_if(is_double,round %>% partial(digits=3) ) %>% knitr::kable()
Clasificacion Sport IT name n media dt ee ic1 ic2 vReferencia1 vReferencia2 vReferencia3 Sport1 Sport2 Sport3
Individual Swimming Individual Rest 20 1.622 1.748 0.087 1.439 1.805 5 1 1 Swimming Swimming Swimming
Individual Swimming Individual Competition 20 3.319 2.065 0.103 3.103 3.535 5 1 1 Swimming Swimming Swimming
Individual Swimming Individual Competing - Rest 20 1.697 2.271 0.114 1.459 1.935 5 1 1 Swimming Swimming Swimming
Individual Athletism Individual Rest 24 1.789 1.438 0.060 1.665 1.913 7 2 2 Athletism Athletism Athletism
Individual Athletism Individual Competition 24 3.647 1.941 0.081 3.480 3.814 7 2 2 Athletism Athletism Athletism
Individual Athletism Individual Competing - Rest 24 1.858 2.800 0.117 1.617 2.100 7 2 2 Athletism Athletism Athletism
Individual Judo Individual Rest 15 1.461 1.103 0.074 1.303 1.618 4 4 3 Judo Judo Judo
Individual Judo Individual Competition 15 4.526 2.082 0.139 4.228 4.824 4 4 3 Judo Judo Judo
Individual Judo Individual Competing - Rest 15 3.065 2.145 0.143 2.759 3.372 4 4 3 Judo Judo Judo
Individual Badminton Individual Rest 34 0.223 2.416 0.071 0.079 0.368 1 6 7 Badminton Badminton Badminton
Individual Badminton Individual Competition 34 6.321 3.961 0.116 6.084 6.558 1 6 7 Badminton Badminton Badminton
Individual Badminton Individual Competing - Rest 34 6.097 4.433 0.130 5.832 6.362 1 6 7 Badminton Badminton Badminton
Team Football Team Rest 77 0.355 2.877 0.037 0.280 0.429 2 3 4 Football Football Football
Team Football Team Competition 77 3.880 7.535 0.098 3.685 4.075 2 3 4 Football Football Football
Team Football Team Competing - Rest 77 3.525 8.463 0.110 3.306 3.744 2 3 4 Football Football Football
Team Hockey Team Rest 14 1.775 1.262 0.090 1.580 1.970 6 5 5 Hockey Hockey Hockey
Team Hockey Team Competition 14 5.664 2.286 0.163 5.312 6.017 6 5 5 Hockey Hockey Hockey
Team Hockey Team Competing - Rest 14 3.889 1.992 0.142 3.582 4.197 6 5 5 Hockey Hockey Hockey
Team Handball Team Rest 14 1.439 1.111 0.079 1.268 1.611 3 7 6 Handball Handball Handball
Team Handball Team Competition 14 6.837 3.558 0.254 6.288 7.386 3 7 6 Handball Handball Handball
Team Handball Team Competing - Rest 14 5.398 4.418 0.316 4.716 6.080 3 7 6 Handball Handball Handball
dfLongDif %>% ggplot(aes(y=value,x=Sport2,color=IT,fill=IT))+
geom_jitter(width=0.25,alpha=0.15)+
  geom_boxplot(alpha=0.25)+
  geom_hline(yintercept = 0)+
  facet_wrap(~name,ncol=1)+
   theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust=1),legend.position="top",legend.title=element_blank())

Aparentemente la variabilidad que existe intradia (m00 a m30) es muy pequeña los dias de descanso. En general se produce un aumento de Cortisol desde m00 a m30 los dias de competición. Si comparamos el aumento desde m00 a m30 entre los dias de competición y dias de descanso, se suele ver un aumento.

Se observa una heterogeneidad relacionada con el tipo de deporte. Aparentemente vamos a tener que separar los resultados por ellos. En los deportes donde compiten hombres y mujeres no parece que haya gran diferencias por sexos. Posiblemente tengamos derecho a no considerar el sexo, o si acaso considerarlo como una variable de control.

dfDifAgr=dfLongDif %>% 
  group_by(Sport2,IT,Clasificacion,name) %>% 
  summarise(n=length(value),
            media=mean(value),
            dt=sd(value),
            ee=dt/n,
            ic1=media-qt(0.975,df=n-1)*ee,
            ic2=media+qt(0.975,df=n-1)*ee
            ) %>% ungroup()
`summarise()` has grouped output by 'Sport2', 'IT', 'Clasificacion'. You can
override using the `.groups` argument.
dfDifAgr %>% mutate_if(is_double,round %>% partial(digits=3) )%>%  knitr::kable()
Sport2 IT Clasificacion name n media dt ee ic1 ic2
Swimming Individual Individual Rest 20 1.622 1.748 0.087 1.439 1.805
Swimming Individual Individual Competition 20 3.319 2.065 0.103 3.103 3.535
Swimming Individual Individual Competing - Rest 20 1.697 2.271 0.114 1.459 1.935
Athletism Individual Individual Rest 24 1.789 1.438 0.060 1.665 1.913
Athletism Individual Individual Competition 24 3.647 1.941 0.081 3.480 3.814
Athletism Individual Individual Competing - Rest 24 1.858 2.800 0.117 1.617 2.100
Football Team Team Rest 77 0.355 2.877 0.037 0.280 0.429
Football Team Team Competition 77 3.880 7.535 0.098 3.685 4.075
Football Team Team Competing - Rest 77 3.525 8.463 0.110 3.306 3.744
Judo Individual Individual Rest 15 1.461 1.103 0.074 1.303 1.618
Judo Individual Individual Competition 15 4.526 2.082 0.139 4.228 4.824
Judo Individual Individual Competing - Rest 15 3.065 2.145 0.143 2.759 3.372
Hockey Team Team Rest 14 1.775 1.262 0.090 1.580 1.970
Hockey Team Team Competition 14 5.664 2.286 0.163 5.312 6.017
Hockey Team Team Competing - Rest 14 3.889 1.992 0.142 3.582 4.197
Badminton Individual Individual Rest 34 0.223 2.416 0.071 0.079 0.368
Badminton Individual Individual Competition 34 6.321 3.961 0.116 6.084 6.558
Badminton Individual Individual Competing - Rest 34 6.097 4.433 0.130 5.832 6.362
Handball Team Team Rest 14 1.439 1.111 0.079 1.268 1.611
Handball Team Team Competition 14 6.837 3.558 0.254 6.288 7.386
Handball Team Team Competing - Rest 14 5.398 4.418 0.316 4.716 6.080
dfDifAgr   %>% ggplot(aes(x=Sport2,y=media,color=name))+
  geom_errorbar(aes(ymin=ic1,ymax=ic2),position = "dodge2",width=0.25)+
#  geom_col(position = "dodge2",fill="white",alpha=0.1,color="#00000033") +
    geom_point( position = position_dodge(width=0.25)) +
   geom_hline(yintercept = 0,lty=2,alpha=0.5)+
   theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust=1),legend.position = "top",legend.title=element_blank())

dfDifAgr   %>% ggplot(aes(x=Sport2,y=media,color=name))+
  geom_errorbar(aes(ymin=ic1,ymax=ic2),position = "dodge2",width=0.25)+
#  geom_col(position = "dodge2",fill="white",alpha=0.1,color="#00000033") +
    geom_point( position = position_dodge(width=0.25)) +
   geom_hline(yintercept = 0,lty=2,alpha=0.5)+
  facet_wrap(~name,ncol=1)+
   theme(axis.text.x = element_text(angle = 90, vjust = 1, hjust=1),legend.position = "none")