Common Humanity & Mindfulness 2023

Physiological signals anlysis, Mixed Model

Author

Álvaro Rivera-Rei

Published

2025-02-24, Monday

Code
cat('\014')     # clean terminal
Code
rm(list = ls()) # clean workspace
library(tidyverse)
library(afex)
library(emmeans)
library(GGally)
library(EnvStats)
library(easystats)
library(RLRsim)
Code
theme_set(
  theme_minimal()
)

a_posteriori <- function(lmer_object, sig_level = .05) {
  suppressWarnings(rr <- r2(lmer_object))
  print(rr)
  if (!is.na(rr[[1]])) {
    cat(rep('_', 60), '\n', sep = '')
    suppressWarnings(print(icc(lmer_object)))
    cat(rep('_', 60), '\n', sep = '')
    frmla <- lmer_object@call$formula
    frmla1 <- update.formula(frmla, . ~ sex + age + (1 | duo))
    frmla0 <- update.formula(frmla, . ~ sex + age)
    datas <- lmer_object@call$data
    human1 <- lmer(eval(frmla1), subset(eval(datas), group == 'humanity'))
    human0 <- lm  (eval(frmla0), subset(eval(datas), group == 'humanity'))
    try({
      suppressMessages(human <- exactLRT(human1, human0))
      names(human$statistic) <- 'humanity LRT'
      print(human)
    }, silent = TRUE)
    cat(rep('_', 60), '\n', sep = '')
    mindf1 <- lmer(eval(frmla1), subset(eval(datas), group == 'mindfulness'))
    mindf0 <- lm  (eval(frmla0), subset(eval(datas), group == 'mindfulness'))
    try({
      suppressMessages(mindf <- exactLRT(mindf1, mindf0))
      names(mindf$statistic) <- 'mindfulness LRT'
      print(mindf)
    }, silent = TRUE)
  }
  factors  <- list('group', 'sex', NA, c('group' ,'sex'))
  p_values <- anova(lmer_object)$`Pr(>F)`
  if (p_values[3] <= sig_level) {
    cat(rep('_', 60), '\n', sep = '')
    print(paste('Slope for age =', lmer_object@beta[4]))
  }
  for (i in c(1:2, 4)) {
    if (p_values[i] <= sig_level) {
      cat(rep('_', 60), '\n', sep = '')
      print(emmeans(lmer_object, factors[[i]], contr = 'pairwise'))
    }
  }
}
Code
a_df_age <- read_csv('../../analysis_apt/data/df_age_2023_data_clean.csv', col_types = cols())

a_df_hrv <- read_csv('../data/hrv_hrf_hra_rsa_rrv_neurokit2.csv', col_types = cols()) |>
  rename(id    = sbj) |> 
  rename(group = grp) |> 
  left_join(y = a_df_age[c('id', 'age')], by = c('id')) |>
  mutate(heart_rate    = 60000 / HRV_MeanNN) |> 
  mutate(rsp_rate      = 60000 / RRV_MeanBB) |> 
  mutate(HRV_lnLF_lnHF = log(HRV_LFn) - log(HRV_HFn)) |> 
  mutate(hr_to_hrv     = heart_rate / HRV_LFn) |> 
  mutate(sex = if_else(sex == 'f', 'female', 'male')) |> 
  mutate(log10_HRV_RMSSD = log10(HRV_RMSSD)) |> 
  mutate(log10_HRF_PAS   = log10(HRF_PAS)) |> 
  mutate(log10_RRV_RMSSD = log10(RRV_RMSSD)) |> 
  mutate_if(is.character, as.factor)
a_df_pow_peaks <- read_csv('../data/power_peaks.csv', col_types = cols()) |>
  separate_wider_delim(
    subj,
    delim = '_',
    names = c('duo', 'id')
  ) |> 
  filter(peak_size == 1) |> 
  left_join(y = a_df_hrv[c('id', 'sex', 'group', 'age')], by = c('id')) |>
  mutate_if(is.character, as.factor)
a_df_aperiodic <- read_csv('../data/aperiodic_params.csv', col_types = cols()) |>
  separate_wider_delim(
    subj,
    delim = '_',
    names = c('duo', 'id')
  ) |> 
  mutate(log_knee = log(knee)) |> 
  left_join(y = a_df_hrv[c('id', 'sex', 'group', 'age')], by = c('id')) |>
  mutate_if(is.character, as.factor)
a_df_ccoh <- read_csv('../data/ccoh_ave.csv', col_types = cols()) |>
  rename(id    = sbj) |> 
  rename(group = grp) |> 
  mutate(sex = if_else(sex == 'f', 'female', 'male')) |> 
  left_join(y = a_df_hrv[c('id', 'age')], by = c('id')) |>
  mutate_if(is.character, as.factor)
a_df_rsa_angular <- read_csv('../data/rsa_angular_diff_rhrv.csv', col_types = cols()) |>
  rename(id    = sbj) |> 
  rename(group = grp) |> 
  mutate(sex = if_else(sex == 'f', 'female', 'male')) |> 
  mutate(log_wallraff_chi = log(wallraff_chi)) |> 
  mutate(log_f_aov        = log(f_aov)) |> 
  mutate(log_watson_f     = log(watson_f)) |> 
  left_join(y = a_df_hrv[c('id', 'age')], by = c('id')) |>
  mutate_if(is.character, as.factor)
a_df_rsa_cyclic <- read_csv('../data/rsa_cycles_params.csv', col_types = cols()) |>
  rename(id    = sbj) |> 
  rename(group = grp) |> 
  mutate(sex = if_else(sex == 'f', 'female', 'male')) |> 
  left_join(y = a_df_hrv[c('id', 'age')], by = c('id')) |>
  mutate_if(is.character, as.factor)
a_df_clumpiness <- read_csv('../data/hp_clumpiness.csv', col_types = cols()) |>
  rename(id    = sbj) |> 
  rename(group = grp) |> 
  mutate(sex = if_else(sex == 'f', 'female', 'male')) |> 
  left_join(y = a_df_hrv[c('id', 'age')], by = c('id')) |>
  mutate_if(is.character, as.factor)

1 Summary

Code
addmargins(table(a_df_hrv$group, a_df_hrv$sex))
             
              female male Sum
  humanity        16   16  32
  mindfulness     16   16  32
  Sum             32   32  64
Code
summary(a_df_hrv)
      duo           id         sex             group      HRV_MeanNN    
 d01    : 2   s01    : 1   female:32   humanity   :32   Min.   : 601.0  
 d02    : 2   s02    : 1   male  :32   mindfulness:32   1st Qu.: 752.0  
 d03    : 2   s03    : 1                                Median : 834.9  
 d04    : 2   s04    : 1                                Mean   : 834.6  
 d05    : 2   s05    : 1                                3rd Qu.: 910.9  
 d06    : 2   s06    : 1                                Max.   :1146.2  
 (Other):52   (Other):58                                                
    HRV_SDNN        HRV_SDANN1      HRV_SDNNI1       HRV_RMSSD      
 Min.   : 22.12   Min.   :13.88   Min.   : 17.11   Min.   :  7.888  
 1st Qu.: 54.46   1st Qu.:23.50   1st Qu.: 49.85   1st Qu.: 29.549  
 Median : 75.73   Median :29.57   Median : 65.68   Median : 46.516  
 Mean   : 81.90   Mean   :34.63   Mean   : 72.24   Mean   : 51.833  
 3rd Qu.:108.64   3rd Qu.:43.21   3rd Qu.: 96.78   3rd Qu.: 66.324  
 Max.   :159.05   Max.   :81.25   Max.   :155.40   Max.   :176.077  
                                                                    
    HRV_SDSD         HRV_CVNN          HRV_CVSD        HRV_MedianNN   
 Min.   :  7.89   Min.   :0.03416   Min.   :0.01218   Min.   : 599.0  
 1st Qu.: 29.56   1st Qu.:0.07439   1st Qu.:0.03945   1st Qu.: 737.2  
 Median : 46.53   Median :0.09030   Median :0.05588   Median : 826.5  
 Mean   : 51.85   Mean   :0.09655   Mean   :0.06031   Mean   : 835.3  
 3rd Qu.: 66.35   3rd Qu.:0.12291   3rd Qu.:0.07282   3rd Qu.: 911.5  
 Max.   :176.14   Max.   :0.18570   Max.   :0.19013   Max.   :1157.0  
                                                                      
   HRV_MadNN        HRV_MCVNN         HRV_IQRNN       HRV_SDRMSSD    
 Min.   : 22.24   Min.   :0.03443   Min.   : 30.00   Min.   :0.7613  
 1st Qu.: 55.97   1st Qu.:0.07029   1st Qu.: 75.75   1st Qu.:1.4405  
 Median : 77.84   Median :0.08966   Median :105.50   Median :1.7400  
 Mean   : 83.20   Mean   :0.09824   Mean   :115.27   Mean   :1.7655  
 3rd Qu.:105.64   3rd Qu.:0.12389   3rd Qu.:144.94   3rd Qu.:2.0225  
 Max.   :189.77   Max.   :0.22379   Max.   :265.00   Max.   :2.9463  
                                                                     
  HRV_Prc20NN      HRV_Prc80NN       HRV_pNN50       HRV_pNN20     
 Min.   : 575.0   Min.   : 624.0   Min.   : 0.00   Min.   : 2.219  
 1st Qu.: 695.0   1st Qu.: 812.4   1st Qu.: 8.05   1st Qu.:46.858  
 Median : 751.0   Median : 905.0   Median :25.20   Median :60.567  
 Mean   : 763.3   Mean   : 905.7   Mean   :23.99   Mean   :55.342  
 3rd Qu.: 809.6   3rd Qu.:1008.8   3rd Qu.:33.58   3rd Qu.:68.542  
 Max.   :1064.2   Max.   :1242.0   Max.   :61.55   Max.   :84.320  
                                                                   
   HRV_MinNN       HRV_MaxNN         HRV_HTI          HRV_TINN    
 Min.   :392.0   Min.   : 716.0   Min.   : 6.619   Min.   :  0.0  
 1st Qu.:540.2   1st Qu.: 964.8   1st Qu.:15.616   1st Qu.:209.0  
 Median :590.0   Median :1059.0   Median :20.675   Median :332.0  
 Mean   :592.1   Mean   :1083.0   Mean   :21.067   Mean   :303.3  
 3rd Qu.:624.2   3rd Qu.:1224.8   3rd Qu.:27.192   3rd Qu.:416.0  
 Max.   :830.0   Max.   :1427.0   Max.   :39.000   Max.   :632.8  
                                                                  
    HRV_VLF              HRV_LF             HRV_HF             HRV_VHF         
 Min.   :0.0006637   Min.   :0.001261   Min.   :0.0003042   Min.   :1.095e-05  
 1st Qu.:0.0028007   1st Qu.:0.004354   1st Qu.:0.0016075   1st Qu.:4.098e-05  
 Median :0.0046367   Median :0.007936   Median :0.0026162   Median :1.008e-04  
 Mean   :0.0059340   Mean   :0.011116   Mean   :0.0052010   Mean   :3.053e-04  
 3rd Qu.:0.0087290   3rd Qu.:0.016586   3rd Qu.:0.0062517   3rd Qu.:1.743e-04  
 Max.   :0.0205487   Max.   :0.035360   Max.   :0.0309629   Max.   :9.837e-03  
                                                                               
     HRV_TP            HRV_LFHF          HRV_LFn          HRV_HFn       
 Min.   :0.002965   Min.   : 0.5302   Min.   :0.2272   Min.   :0.03533  
 1st Qu.:0.009898   1st Qu.: 1.2408   1st Qu.:0.3430   1st Qu.:0.09818  
 Median :0.019280   Median : 2.4597   Median :0.4237   Median :0.18924  
 Mean   :0.022556   Mean   : 3.9986   Mean   :0.4789   Mean   :0.21302  
 3rd Qu.:0.030619   3rd Qu.: 4.7435   3rd Qu.:0.5838   3rd Qu.:0.29783  
 Max.   :0.077930   Max.   :16.5303   Max.   :0.8859   Max.   :0.52422  
                                                                        
    HRV_LnHF         HRV_SD1           HRV_SD2         HRV_SD1SD2    
 Min.   :-8.098   Min.   :  5.579   Min.   : 30.79   Min.   :0.1722  
 1st Qu.:-6.434   1st Qu.: 20.901   1st Qu.: 74.69   1st Qu.:0.2554  
 Median :-5.946   Median : 32.905   Median :102.84   Median :0.3000  
 Mean   :-5.799   Mean   : 36.665   Mean   :109.33   Mean   :0.3210  
 3rd Qu.:-5.076   3rd Qu.: 46.919   3rd Qu.:142.58   3rd Qu.:0.3702  
 Max.   :-3.475   Max.   :124.553   Max.   :214.24   Max.   :0.8723  
                                                                     
     HRV_S            HRV_CSI         HRV_CVI      HRV_CSI_Modified
 Min.   :  539.7   Min.   :1.146   Min.   :3.439   Min.   : 543.2  
 1st Qu.: 5323.9   1st Qu.:2.702   1st Qu.:4.432   1st Qu.: 988.2  
 Median :11186.3   Median :3.333   Median :4.756   Median :1299.6  
 Mean   :14851.7   Mean   :3.373   Mean   :4.700   Mean   :1401.5  
 3rd Qu.:21386.1   3rd Qu.:3.915   3rd Qu.:5.037   3rd Qu.:1709.0  
 Max.   :55872.0   Max.   :5.807   Max.   :5.454   Max.   :2696.8  
                                                                   
    HRF_PIP          HRF_IALS         HRF_PSS          HRF_PAS        
 Min.   :0.2031   Min.   :0.1972   Min.   :0.1760   Min.   :0.002227  
 1st Qu.:0.3122   1st Qu.:0.3035   1st Qu.:0.3756   1st Qu.:0.014716  
 Median :0.3838   Median :0.3711   Median :0.5420   Median :0.032264  
 Mean   :0.3764   Mean   :0.3678   Mean   :0.5138   Mean   :0.036832  
 3rd Qu.:0.4445   3rd Qu.:0.4324   3rd Qu.:0.6482   3rd Qu.:0.051006  
 Max.   :0.5517   Max.   :0.5472   Max.   :0.8576   Max.   :0.156550  
                                                                      
     HRA_GI          HRA_SI          HRA_AI          HRA_PI     
 Min.   :49.41   Min.   :49.10   Min.   :49.63   Min.   :43.16  
 1st Qu.:49.88   1st Qu.:49.85   1st Qu.:49.91   1st Qu.:48.61  
 Median :49.96   Median :49.91   Median :50.02   Median :51.83  
 Mean   :49.97   Mean   :49.91   Mean   :50.02   Mean   :52.50  
 3rd Qu.:50.05   3rd Qu.:50.00   3rd Qu.:50.12   3rd Qu.:56.21  
 Max.   :50.41   Max.   :50.35   Max.   :50.61   Max.   :66.69  
                                                                
    HRA_C1d          HRA_C1a          HRA_SD1d         HRA_SD1a     
 Min.   :0.4149   Min.   :0.2371   Min.   : 4.055   Min.   : 3.833  
 1st Qu.:0.4986   1st Qu.:0.3818   1st Qu.:15.513   1st Qu.:14.168  
 Median :0.5683   Median :0.4317   Median :23.371   Median :22.701  
 Mean   :0.5660   Mean   :0.4340   Mean   :28.058   Mean   :23.411  
 3rd Qu.:0.6182   3rd Qu.:0.5014   3rd Qu.:36.411   3rd Qu.:29.076  
 Max.   :0.7629   Max.   :0.5851   Max.   :95.213   Max.   :80.299  
                                                                    
    HRA_C2d          HRA_C2a          HRA_SD2d         HRA_SD2a     
 Min.   :0.2817   Min.   :0.4544   Min.   : 21.81   Min.   : 21.73  
 1st Qu.:0.4151   1st Qu.:0.5011   1st Qu.: 51.06   1st Qu.: 55.32  
 Median :0.4498   Median :0.5502   Median : 71.15   Median : 75.39  
 Mean   :0.4516   Mean   :0.5484   Mean   : 72.13   Mean   : 81.90  
 3rd Qu.:0.4989   3rd Qu.:0.5849   3rd Qu.: 90.31   3rd Qu.:108.65  
 Max.   :0.5456   Max.   :0.7183   Max.   :120.87   Max.   :181.57  
                                                                    
     HRA_Cd           HRA_Ca         HRA_SDNNd       HRA_SDNNa     
 Min.   :0.3259   Min.   :0.4602   Min.   :15.69   Min.   : 15.60  
 1st Qu.:0.4398   1st Qu.:0.5027   1st Qu.:38.32   1st Qu.: 40.01  
 Median :0.4609   Median :0.5391   Median :53.52   Median : 55.25  
 Mean   :0.4641   Mean   :0.5359   Mean   :55.10   Mean   : 60.45  
 3rd Qu.:0.4973   3rd Qu.:0.5602   3rd Qu.:70.25   3rd Qu.: 81.10  
 Max.   :0.5398   Max.   :0.6741   Max.   :96.04   Max.   :130.51  
                                                                   
 HRV_DFA_alpha1   HRV_MFDFA_alpha1_Width HRV_MFDFA_alpha1_Peak
 Min.   :0.8514   Min.   :0.7717         Min.   :1.095        
 1st Qu.:1.1631   1st Qu.:1.8686         1st Qu.:1.366        
 Median :1.3425   Median :2.2010         Median :1.567        
 Mean   :1.3289   Mean   :2.1872         Mean   :1.595        
 3rd Qu.:1.5199   3rd Qu.:2.5620         3rd Qu.:1.839        
 Max.   :1.7277   Max.   :3.5068         Max.   :2.372        
                                                              
 HRV_MFDFA_alpha1_Mean HRV_MFDFA_alpha1_Max HRV_MFDFA_alpha1_Delta
 Min.   :1.371         Min.   :-3.5953      Min.   :-4.5656       
 1st Qu.:1.921         1st Qu.:-2.1805      1st Qu.:-2.6191       
 Median :2.092         Median :-1.6207      Median :-1.6314       
 Mean   :2.116         Mean   :-1.5024      Mean   :-1.7203       
 3rd Qu.:2.321         3rd Qu.:-0.7451      3rd Qu.:-0.9644       
 Max.   :2.795         Max.   : 0.7712      Max.   : 1.6485       
                                                                  
 HRV_MFDFA_alpha1_Asymmetry HRV_MFDFA_alpha1_Fluctuation
 Min.   :-0.91798           Min.   :0.0002369           
 1st Qu.:-0.33684           1st Qu.:0.0012840           
 Median :-0.27146           Median :0.0024144           
 Mean   :-0.27202           Mean   :0.0032722           
 3rd Qu.:-0.15625           3rd Qu.:0.0042287           
 Max.   :-0.01569           Max.   :0.0181720           
                                                        
 HRV_MFDFA_alpha1_Increment HRV_DFA_alpha2   HRV_MFDFA_alpha2_Width
 Min.   :0.04413            Min.   :0.3819   Min.   :0.06623       
 1st Qu.:0.21901            1st Qu.:0.7095   1st Qu.:0.18168       
 Median :0.34114            Median :0.7887   Median :0.29153       
 Mean   :0.38364            Mean   :0.7856   Mean   :0.32283       
 3rd Qu.:0.47796            3rd Qu.:0.8814   3rd Qu.:0.46350       
 Max.   :1.09029            Max.   :1.1064   Max.   :0.77810       
                                                                   
 HRV_MFDFA_alpha2_Peak HRV_MFDFA_alpha2_Mean HRV_MFDFA_alpha2_Max
 Min.   :0.4675        Min.   :0.4603        Min.   :-0.2978     
 1st Qu.:0.7356        1st Qu.:0.7775        1st Qu.: 0.3844     
 Median :0.8361        Median :0.8446        Median : 0.6177     
 Mean   :0.8224        Mean   :0.8392        Mean   : 0.6493     
 3rd Qu.:0.9130        3rd Qu.:0.9294        3rd Qu.: 0.9703     
 Max.   :1.2191        Max.   :1.1321        Max.   : 1.5636     
                                                                 
 HRV_MFDFA_alpha2_Delta HRV_MFDFA_alpha2_Asymmetry HRV_MFDFA_alpha2_Fluctuation
 Min.   :-1.06183       Min.   :-1.0000            Min.   :2.526e-06           
 1st Qu.:-0.47716       1st Qu.:-0.7395            1st Qu.:1.073e-05           
 Median :-0.16280       Median :-0.4684            Median :3.640e-05           
 Mean   :-0.17611       Mean   :-0.4864            Mean   :5.990e-05           
 3rd Qu.: 0.06308       3rd Qu.:-0.1799            3rd Qu.:7.050e-05           
 Max.   : 1.11061       Max.   : 0.0000            Max.   :3.030e-04           
                                                                               
 HRV_MFDFA_alpha2_Increment    HRV_ApEn        HRV_SampEn       HRV_ShanEn   
 Min.   :0.0004625          Min.   :0.8034   Min.   :0.6221   Min.   :6.414  
 1st Qu.:0.0028003          1st Qu.:1.0624   1st Qu.:0.9967   1st Qu.:7.656  
 Median :0.0065677          Median :1.2707   Median :1.2245   Median :8.039  
 Mean   :0.0084463          Mean   :1.2496   Mean   :1.2213   Mean   :7.981  
 3rd Qu.:0.0119822          3rd Qu.:1.3999   3rd Qu.:1.4094   3rd Qu.:8.398  
 Max.   :0.0312495          Max.   :1.5786   Max.   :1.6783   Max.   :8.773  
                                                                             
  HRV_FuzzyEn        HRV_MSEn        HRV_CMSEn       HRV_RCMSEn   
 Min.   :0.6638   Min.   :0.5883   Min.   :1.343   Min.   :1.838  
 1st Qu.:0.8023   1st Qu.:1.1264   1st Qu.:1.381   1st Qu.:2.044  
 Median :0.9330   Median :1.2900   Median :1.403   Median :2.097  
 Mean   :0.9419   Mean   :1.2467   Mean   :1.400   Mean   :2.096  
 3rd Qu.:1.0801   3rd Qu.:1.4056   3rd Qu.:1.420   3rd Qu.:2.173  
 Max.   :1.3261   Max.   :1.6275   Max.   :1.453   Max.   :2.294  
                                                                  
     HRV_CD         HRV_HFD         HRV_KFD         HRV_LZC      
 Min.   :1.220   Min.   :1.355   Min.   :2.367   Min.   :0.4583  
 1st Qu.:1.549   1st Qu.:1.593   1st Qu.:2.963   1st Qu.:0.6001  
 Median :1.655   Median :1.691   Median :3.292   Median :0.6643  
 Mean   :1.616   Mean   :1.692   Mean   :3.338   Mean   :0.6734  
 3rd Qu.:1.699   3rd Qu.:1.779   3rd Qu.:3.577   3rd Qu.:0.7357  
 Max.   :1.799   Max.   :1.923   Max.   :5.023   Max.   :0.9584  
                                                                 
  RSA_P2T_Mean    RSA_P2T_Mean_log   RSA_P2T_SD     RSA_P2T_NoRSA  
 Min.   : 18.38   Min.   :2.911    Min.   : 16.78   Min.   : 0.00  
 1st Qu.: 73.74   1st Qu.:4.299    1st Qu.: 47.09   1st Qu.: 0.00  
 Median :113.55   Median :4.732    Median : 69.43   Median : 1.00  
 Mean   :120.71   Mean   :4.616    Mean   : 76.52   Mean   : 2.25  
 3rd Qu.:162.91   3rd Qu.:5.093    3rd Qu.:108.27   3rd Qu.: 3.00  
 Max.   :353.91   Max.   :5.869    Max.   :173.61   Max.   :17.00  
                                                                   
 RSA_PorgesBohrer RSA_Gates_Mean  RSA_Gates_Mean_log  RSA_Gates_SD    
 Min.   :-7.287   Min.   :7.291   Min.   :1.987      Min.   :0.07904  
 1st Qu.:-5.658   1st Qu.:7.891   1st Qu.:2.066      1st Qu.:0.15099  
 Median :-4.861   Median :8.156   Median :2.099      Median :0.19904  
 Mean   :-5.109   Mean   :8.153   Mean   :2.097      Mean   :0.20784  
 3rd Qu.:-4.432   3rd Qu.:8.446   3rd Qu.:2.134      3rd Qu.:0.26238  
 Max.   :-3.297   Max.   :8.904   Max.   :2.186      Max.   :0.37965  
                                                                      
   RRV_RMSSD        RRV_MeanBB       RRV_SDBB         RRV_SDSD     
 Min.   : 959.8   Min.   : 3125   Min.   : 801.7   Min.   : 961.2  
 1st Qu.:2067.0   1st Qu.: 4555   1st Qu.:1872.0   1st Qu.:2072.3  
 Median :2803.1   Median : 5634   Median :2357.4   Median :2812.3  
 Mean   :3089.3   Mean   : 6081   Mean   :2546.9   Mean   :3097.9  
 3rd Qu.:3701.2   3rd Qu.: 7595   3rd Qu.:3174.9   3rd Qu.:3709.8  
 Max.   :8505.1   Max.   :10367   Max.   :5892.8   Max.   :8540.6  
                                                                   
    RRV_CVBB         RRV_CVSD       RRV_MedianBB     RRV_MadBB     
 Min.   :0.2087   Min.   :0.2425   Min.   : 2756   Min.   : 443.3  
 1st Qu.:0.3376   1st Qu.:0.3783   1st Qu.: 4190   1st Qu.:1071.5  
 Median :0.4068   Median :0.4980   Median : 4927   Median :1781.0  
 Mean   :0.4192   Mean   :0.5067   Mean   : 5603   Mean   :1783.0  
 3rd Qu.:0.4867   3rd Qu.:0.6008   3rd Qu.: 7266   3rd Qu.:2266.0  
 Max.   :0.6368   Max.   :0.8636   Max.   :10747   Max.   :4152.8  
                                                                   
   RRV_MCVBB         RRV_VLF              RRV_LF              RRV_HF         
 Min.   :0.1279   Min.   :0.0007644   Min.   :6.745e-05   Min.   :3.737e-07  
 1st Qu.:0.2448   1st Qu.:0.0055229   1st Qu.:1.275e-03   1st Qu.:1.708e-05  
 Median :0.2922   Median :0.0083958   Median :2.097e-03   Median :5.331e-05  
 Mean   :0.3114   Mean   :0.0090367   Mean   :2.953e-03   Mean   :1.005e-04  
 3rd Qu.:0.3895   3rd Qu.:0.0121473   3rd Qu.:3.741e-03   3rd Qu.:1.159e-04  
 Max.   :0.5676   Max.   :0.0216785   Max.   :1.188e-02   Max.   :1.086e-03  
                                                                             
    RRV_LFHF           RRV_LFn          RRV_HFn             RRV_SD1      
 Min.   :   9.542   Min.   :0.0484   Min.   :0.0001092   Min.   : 679.7  
 1st Qu.:  25.861   1st Qu.:0.1490   1st Qu.:0.0015639   1st Qu.:1465.4  
 Median :  43.844   Median :0.2123   Median :0.0052822   Median :1988.6  
 Mean   : 107.957   Mean   :0.2231   Mean   :0.0069891   Mean   :2190.5  
 3rd Qu.:  95.167   3rd Qu.:0.2834   3rd Qu.:0.0093055   3rd Qu.:2623.2  
 Max.   :1786.515   Max.   :0.4519   Max.   :0.0449068   Max.   :6039.1  
                                                                         
    RRV_SD2         RRV_SD2SD1        RRV_ApEn        RRV_SampEn   
 Min.   : 907.4   Min.   :0.9509   Min.   :0.5907   Min.   :0.752  
 1st Qu.:2125.1   1st Qu.:1.1221   1st Qu.:0.8709   1st Qu.:1.308  
 Median :2684.3   Median :1.2886   Median :0.9765   Median :1.521  
 Mean   :2831.0   Mean   :1.3644   Mean   :0.9549   Mean   :1.512  
 3rd Qu.:3432.7   3rd Qu.:1.5004   3rd Qu.:1.0686   3rd Qu.:1.747  
 Max.   :6948.5   Max.   :2.7890   Max.   :1.2668   Max.   :2.179  
                                                                   
 RRV_DFA_alpha2   RRV_MFDFA_alpha2_Width RRV_MFDFA_alpha2_Peak
 Min.   :0.3693   Min.   :0.06482        Min.   :0.4013       
 1st Qu.:0.6488   1st Qu.:0.41459        1st Qu.:0.7154       
 Median :0.7351   Median :0.69647        Median :0.8634       
 Mean   :0.7513   Mean   :0.68092        Mean   :0.8369       
 3rd Qu.:0.8617   3rd Qu.:0.88363        3rd Qu.:0.9423       
 Max.   :1.1308   Max.   :1.48613        Max.   :1.3574       
                                                              
 RRV_MFDFA_alpha2_Mean RRV_MFDFA_alpha2_Max RRV_MFDFA_alpha2_Delta
 Min.   :0.2565        Min.   :-0.4437      Min.   :-1.23020      
 1st Qu.:0.6953        1st Qu.: 0.2266      1st Qu.:-0.25577      
 Median :0.8609        Median : 0.4727      Median :-0.03016      
 Mean   :0.8421        Mean   : 0.4365      Mean   :-0.01535      
 3rd Qu.:0.9895        3rd Qu.: 0.6386      3rd Qu.: 0.27522      
 Max.   :1.4754        Max.   : 1.0826      Max.   : 1.07768      
                                                                  
 RRV_MFDFA_alpha2_Asymmetry RRV_MFDFA_alpha2_Fluctuation
 Min.   :-0.8910            Min.   :8.492e-07           
 1st Qu.:-0.6045            1st Qu.:4.380e-05           
 Median :-0.4857            Median :1.181e-04           
 Mean   :-0.4687            Mean   :1.893e-04           
 3rd Qu.:-0.3867            3rd Qu.:2.342e-04           
 Max.   : 0.0000            Max.   :1.707e-03           
                                                        
 RRV_MFDFA_alpha2_Increment RRV_DFA_alpha1   RRV_MFDFA_alpha1_Width
 Min.   :0.0007131          Min.   :0.4483   Min.   :0.6709        
 1st Qu.:0.0121300          1st Qu.:0.6195   1st Qu.:1.1946        
 Median :0.0262180          Median :0.7408   Median :1.5249        
 Mean   :0.0343030          Mean   :0.7403   Mean   :1.5342        
 3rd Qu.:0.0449049          3rd Qu.:0.8268   3rd Qu.:1.8591        
 Max.   :0.1970674          Max.   :1.0598   Max.   :2.3953        
                            NA's   :17       NA's   :17            
 RRV_MFDFA_alpha1_Peak RRV_MFDFA_alpha1_Mean RRV_MFDFA_alpha1_Max
 Min.   :0.6197        Min.   :0.4405        Min.   :-1.65554    
 1st Qu.:0.8896        1st Qu.:1.0492        1st Qu.:-0.75060    
 Median :0.9918        Median :1.2330        Median :-0.43390    
 Mean   :0.9744        Mean   :1.2145        Mean   :-0.40671    
 3rd Qu.:1.0540        3rd Qu.:1.3954        3rd Qu.:-0.04968    
 Max.   :1.2260        Max.   :1.7470        Max.   : 0.98519    
 NA's   :17            NA's   :17            NA's   :17          
 RRV_MFDFA_alpha1_Delta RRV_MFDFA_alpha1_Asymmetry RRV_MFDFA_alpha1_Fluctuation
 Min.   :-2.1389        Min.   :-0.89707           Min.   :0.000133            
 1st Qu.:-1.2574        1st Qu.:-0.43744           1st Qu.:0.000466            
 Median :-0.8318        Median :-0.34943           Median :0.000849            
 Mean   :-0.7130        Mean   :-0.35152           Mean   :0.001403            
 3rd Qu.:-0.2943        3rd Qu.:-0.24635           3rd Qu.:0.002143            
 Max.   : 1.2944        Max.   :-0.03072           Max.   :0.004655            
 NA's   :17             NA's   :17                 NA's   :17                  
 RRV_MFDFA_alpha1_Increment      age          heart_rate       rsp_rate     
 Min.   :0.02943            Min.   :18.00   Min.   :52.35   Min.   : 5.788  
 1st Qu.:0.08693            1st Qu.:21.00   1st Qu.:65.88   1st Qu.: 7.902  
 Median :0.16802            Median :22.00   Median :71.87   Median :10.649  
 Mean   :0.18746            Mean   :23.77   Mean   :73.26   Mean   :10.932  
 3rd Qu.:0.27977            3rd Qu.:25.00   3rd Qu.:79.79   3rd Qu.:13.171  
 Max.   :0.50396            Max.   :48.00   Max.   :99.84   Max.   :19.199  
 NA's   :17                                                                 
 HRV_lnLF_lnHF       hr_to_hrv      log10_HRV_RMSSD log10_HRF_PAS    
 Min.   :-0.6345   Min.   : 71.12   Min.   :0.897   Min.   :-2.6522  
 1st Qu.: 0.2157   1st Qu.:127.57   1st Qu.:1.471   1st Qu.:-1.8322  
 Median : 0.8977   Median :164.10   Median :1.668   Median :-1.4913  
 Mean   : 0.9513   Mean   :174.54   Mean   :1.643   Mean   :-1.5751  
 3rd Qu.: 1.5567   3rd Qu.:223.79   3rd Qu.:1.822   3rd Qu.:-1.2924  
 Max.   : 2.8052   Max.   :401.01   Max.   :2.246   Max.   :-0.8053  
                                                                     
 log10_RRV_RMSSD
 Min.   :2.982  
 1st Qu.:3.315  
 Median :3.448  
 Mean   :3.444  
 3rd Qu.:3.568  
 Max.   :3.930  
                

2 Time Domain Heart Rate Variability (HRV)

“Heart rate variability time-domain indices quantify the amount of HRV observed during monitoring periods that may range from <1 min to >24 h. These metrics include the SDNN, SDRR, SDANN, SDNN Index, RMSSD, NN50, pNN50, HR Max - HR Min, the HRV triangular index (HTI), and the Triangular Interpolation of the NN Interval Histogram” (Shaffer and Ginsberg 2017)

Code
some_params <- c('heart_rate', 'HRV_SDNN', 'HRV_CVNN', 'log10_HRV_RMSSD', 'HRV_IQRNN', 'HRV_HTI')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

2.1 Heart Rate (HR)

Code
heart_rate_lmer <- lmer(heart_rate ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  heart_rate_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 1: heart_rate
Code
anova(heart_rate_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
group       60.19   60.19     1    59  0.6805 0.4127314    
sex       1283.99 1283.99     1    59 14.5177 0.0003336 ***
age         74.44   74.44     1    59  0.8416 0.3626619    
group:sex   54.29   54.29     1    59  0.6139 0.4364625    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(heart_rate_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.196
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   77.8 1.68 28.1     74.4     81.3
 male     68.7 1.68 28.1     65.2     72.1

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate  SE   df t.ratio p.value
 female - male     9.15 2.4 28.8   3.805  0.0007

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

2.2 HRV_SDNN

Code
sdnn_lmer <- lmer(HRV_SDNN ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  sdnn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 2: HRV_SDNN
Code
anova(sdnn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
group       150.7   150.7     1 29.038  0.1911 0.665239   
sex       10452.6 10452.6     1 29.196 13.2536 0.001044 **
age         675.1   675.1     1 55.032  0.8561 0.358885   
group:sex   281.2   281.2     1 28.963  0.3566 0.555047   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(sdnn_lmer)
# R2 for Mixed Models

  Conditional R2: 0.297
     Marginal R2: 0.223
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.095
  Unadjusted ICC: 0.074
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.54129, p-value = 0.1721

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   67.6 5.52 28.1     56.3     78.9
 male     96.2 5.52 28.1     84.9    107.5

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -28.6 7.88 28.8  -3.636  0.0011

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

2.3 HRV_CVNN

Code
cvnn_lmer <- lmer(HRV_CVNN ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  cvnn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 3: HRV_CVNN
Code
anova(cvnn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF DenDF F value   Pr(>F)   
group     0.0011675 0.0011675     1    59  1.2494 0.268198   
sex       0.0088804 0.0088804     1    59  9.5037 0.003116 **
age       0.0020636 0.0020636     1    59  2.2084 0.142585   
group:sex 0.0000440 0.0000440     1    59  0.0471 0.829026   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(cvnn_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.194
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean      SE   df lower.CL upper.CL
 female 0.0845 0.00546 28.1   0.0733   0.0957
 male   0.1086 0.00546 28.1   0.0974   0.1198

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate      SE   df t.ratio p.value
 female - male  -0.0241 0.00781 28.8  -3.079  0.0045

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

2.4 log10_HRV_RMSSD

Code
log10_rmssd_lmer <- lmer(log10_HRV_RMSSD ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  log10_rmssd_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 4: log10_HRV_RMSSD
Code
anova(log10_rmssd_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value   Pr(>F)   
group     0.00203 0.00203     1    59  0.0327 0.857137   
sex       0.55994 0.55994     1    59  9.0334 0.003889 **
age       0.02437 0.02437     1    59  0.3932 0.533065   
group:sex 0.06048 0.06048     1    59  0.9756 0.327314   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(log10_rmssd_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.159
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean     SE   df lower.CL upper.CL
 female   1.55 0.0445 28.1     1.46     1.64
 male     1.74 0.0445 28.1     1.65     1.83

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate     SE   df t.ratio p.value
 female - male   -0.191 0.0636 28.8  -3.002  0.0055

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

2.5 HRV_IQRNN

Code
iqrnn_lmer <- lmer(HRV_IQRNN ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  iqrnn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 5: HRV_IQRNN
Code
anova(iqrnn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
group       524.2   524.2     1 29.067  0.2564 0.616412   
sex       18402.6 18402.6     1 29.221  9.0024 0.005469 **
age         878.8   878.8     1 54.084  0.4299 0.514808   
group:sex   356.5   356.5     1 28.993  0.1744 0.679303   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(iqrnn_lmer)
# R2 for Mixed Models

  Conditional R2: 0.274
     Marginal R2: 0.164
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.132
  Unadjusted ICC: 0.110
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 1.1236, p-value = 0.1092

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0, p-value = 0.3952

____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   95.6 9.21 28.1     76.7      114
 male    135.0 9.21 28.1    116.1      154

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -39.4 13.2 28.8  -2.997  0.0056

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

2.6 HRV_HTI

“HRVI is a simple geometrical measure of HRV that can be derived from standard ECG recordings and expresses overall HRV.17 Depressed HRVI reflects sympathovagal imbalance, but does not distinguish between particular changes in sympathetic and vagal activity.” (Hämmerle et al. 2020)

Code
hti_lmer <- lmer(HRV_HTI ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  hti_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 6: HRV_HTI
Code
anova(hti_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
group       9.328   9.328     1    59  0.1988 0.65730  
sex       312.018 312.018     1    59  6.6504 0.01243 *
age        71.140  71.140     1    59  1.5163 0.22307  
group:sex  13.667  13.667     1    59  0.2913 0.59141  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(hti_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.137
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   18.8 1.22 28.1     16.3     21.3
 male     23.3 1.22 28.1     20.8     25.8

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -4.51 1.75 28.8  -2.575  0.0154

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

3 Frequency Domain HRV

“Analogous to the electroencephalogram, we can use Fast Fourier Transformation (FFT) or autoregressive (AR) modeling to separate HRV into its component ULF, VLF, LF, and HF rhythms that operate within different frequency ranges. This is analogous to a prism that refracts light into its component wavelengths” (Shaffer and Ginsberg 2017)

Code
some_params <- c('HRV_LFn', 'HRV_HFn', 'HRV_lnLF_lnHF', 'hr_to_hrv')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

Code
rosnerTest(a_df_hrv$hr_to_hrv)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_hrv$hr_to_hrv

Sample Size:                     64

Test Statistics:                 R.1 = 3.206847
                                 R.2 = 3.482916
                                 R.3 = 2.674651

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     2

  i   Mean.i     SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 174.5414 70.62028 401.0099      46 3.206847   3.224177    TRUE
2 1 170.9467 65.01775 397.3981      35 3.482916   3.218230    TRUE
3 2 167.2942 58.67188 324.2210      39 2.674651   3.212165   FALSE
Code
ggpairs(a_df_hrv[a_df_hrv$hr_to_hrv < 397, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

3.1 HRV_LFn

Code
lfn_lmer <- lmer(HRV_LFn ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$hr_to_hrv < 397, ])
afex_plot(
  lfn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 7: HRV_LFn
Code
anova(lfn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.023012 0.023012     1 30.078  0.9551 0.33621  
sex       0.092410 0.092410     1 30.262  3.8356 0.05945 .
age       0.031864 0.031864     1 52.636  1.3226 0.25533  
group:sex 0.099780 0.099780     1 29.989  4.1415 0.05077 .
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(lfn_lmer)
# R2 for Mixed Models

  Conditional R2: 0.245
     Marginal R2: 0.169
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.091
  Unadjusted ICC: 0.076
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.061964, p-value = 0.3096

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0, p-value = 0.407

3.2 HRV_HFn

Code
hfn_lmer <- lmer(HRV_HFn ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$hr_to_hrv < 397, ])
afex_plot(
  hfn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 8: HRV_HFn
Code
anova(hfn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.034852 0.034852     1 29.562  2.4301 0.12966  
sex       0.068892 0.068892     1 29.752  4.8036 0.03637 *
age       0.000425 0.000425     1 53.704  0.0297 0.86390  
group:sex 0.070163 0.070163     1 29.471  4.8923 0.03488 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(hfn_lmer)
# R2 for Mixed Models

  Conditional R2: 0.219
     Marginal R2: 0.184
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.043
  Unadjusted ICC: 0.035
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 3.1742, p-value = 0.0274

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean     SE   df lower.CL upper.CL
 female  0.249 0.0232 29.4    0.202    0.297
 male    0.178 0.0224 26.8    0.132    0.224

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate     SE   df t.ratio p.value
 female - male   0.0714 0.0327 29.1   2.186  0.0370

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

____________________________________________________________
$emmeans
 group       sex    emmean     SE   df lower.CL upper.CL
 humanity    female  0.310 0.0314 26.3    0.246    0.375
 mindfulness female  0.188 0.0352 34.2    0.116    0.259
 humanity    male    0.167 0.0314 26.4    0.103    0.232
 mindfulness male    0.188 0.0314 26.4    0.124    0.253

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast                               estimate     SE   df t.ratio p.value
 humanity female - mindfulness female   0.122507 0.0479 31.5   2.559  0.0699
 humanity female - humanity male        0.143263 0.0442 26.0   3.241  0.0161
 humanity female - mindfulness male     0.122121 0.0442 26.0   2.763  0.0478
 mindfulness female - humanity male     0.020755 0.0480 31.7   0.432  0.9725
 mindfulness female - mindfulness male -0.000386 0.0480 31.6  -0.008  1.0000
 humanity male - mindfulness male      -0.021141 0.0442 26.0  -0.478  0.9632

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 4 estimates 

3.3 HRV_lnLF_lnHF

Code
lfhf_lmer <- lmer(HRV_lnLF_lnHF ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$hr_to_hrv < 397, ])
afex_plot(
  lfhf_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 9: HRV_lnLF_lnHF
Code
anova(lfhf_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
group     1.9973  1.9973     1 30.134  2.6413 0.11453  
sex       2.8800  2.8800     1 30.325  3.8085 0.06028 .
age       0.1704  0.1704     1 54.253  0.2253 0.63691  
group:sex 3.5085  3.5085     1 30.042  4.6396 0.03939 *
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(lfhf_lmer)
# R2 for Mixed Models

  Conditional R2: 0.193
     Marginal R2: 0.173
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.024
  Unadjusted ICC: 0.020
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.34642, p-value = 0.2181

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
$emmeans
 group       sex    emmean    SE   df lower.CL upper.CL
 humanity    female  0.309 0.224 26.3   -0.150    0.769
 mindfulness female  1.185 0.252 34.2    0.673    1.696
 humanity    male    1.262 0.224 26.4    0.801    1.722
 mindfulness male    1.140 0.224 26.4    0.680    1.600

Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast                              estimate    SE   df t.ratio p.value
 humanity female - mindfulness female   -0.8756 0.342 31.5  -2.563  0.0694
 humanity female - humanity male        -0.9525 0.315 26.0  -3.025  0.0267
 humanity female - mindfulness male     -0.8305 0.315 26.0  -2.638  0.0627
 mindfulness female - humanity male     -0.0768 0.343 31.8  -0.224  0.9960
 mindfulness female - mindfulness male   0.0451 0.343 31.7   0.132  0.9992
 humanity male - mindfulness male        0.1220 0.315 26.0   0.387  0.9798

Degrees-of-freedom method: kenward-roger 
P value adjustment: tukey method for comparing a family of 4 estimates 

3.4 HR to HRV Ratio

“The current findings revealed that Heart rate/LF non-linearly increased during incremental exercise along with noradrenaline and metabolic parameters, in contrast to LF/HF. In addition, Heart rate/LF was strongly correlated with noradrenaline and metabolic parameters from rest throughout the exercise stages, indicating that Heart rate/LF reflects sympathetic nervous activation during exercise. Thus, Heart rate/LF may provide as an index of sympathetic nervous activity in HRV.” (Tanoue et al. 2022)

Code
hr_to_hrv_lmer <- lmer(hr_to_hrv ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$hr_to_hrv < 397, ])
afex_plot(
  hr_to_hrv_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 10: hr_to_hrv
Code
anova(hr_to_hrv_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
group       2917    2917     1 30.176  1.2445 0.2734083    
sex        33068   33068     1 30.359 14.1096 0.0007327 ***
age         3001    3001     1 52.369  1.2805 0.2629602    
group:sex   9057    9057     1 30.088  3.8644 0.0586071 .  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(hr_to_hrv_lmer)
# R2 for Mixed Models

  Conditional R2: 0.355
     Marginal R2: 0.281
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.103
  Unadjusted ICC: 0.074
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.4024

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.026917, p-value = 0.3586

____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female    194 9.95 29.4      173      214
 male      141 9.59 26.9      122      161

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate SE   df t.ratio p.value
 female - male     52.4 14 29.1   3.747  0.0008

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

4 HR Periodic Components, greater peak (borrowed from EEG PSD analysis)

“In the frequency domain, oscillations manifest as narrow- band peaks of power above the aperiodic component (Fig. 1a) Examining predefined frequency regions in the power spectrum, or applying narrowband filtering (for example, 8-12 Hz for the alpha band) without parameterization, can lead to a misrepresentation and misinterpretation of physiological phenomena, because appar- ent changes in narrowband power can reflect several different phys- iological processes” (Donoghue et al. 2020)

Code
some_params <- c('frequency', 'power', 'bandwidth')
ggpairs(a_df_pow_peaks,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

No outliers:

Code
rosnerTest(a_df_pow_peaks$power)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_pow_peaks$power

Sample Size:                     64

Test Statistics:                 R.1 = 3.576880
                                 R.2 = 2.562102
                                 R.3 = 2.397863

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i    Mean.i      SD.i     Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 0.3754621 0.2039442 1.1049460      58 3.576880   3.224177    TRUE
2 1 0.3638830 0.1831525 0.8331384      32 2.562102   3.218230   FALSE
3 2 0.3563143 0.1744325 0.7745796      12 2.397863   3.212165   FALSE
Code
rosnerTest(a_df_pow_peaks$bandwidth)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_pow_peaks$bandwidth

Sample Size:                     64

Test Statistics:                 R.1 = 3.804966
                                 R.2 = 3.103980
                                 R.3 = 2.958843

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i     Mean.i       SD.i     Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 0.06569515 0.02327964 0.1542734      10 3.804966   3.224177    TRUE
2 1 0.06428915 0.02054565 0.1280624      63 3.103980   3.218230   FALSE
3 2 0.06326055 0.01900778 0.1195016       7 2.958843   3.212165   FALSE
Code
ggpairs(a_df_pow_peaks[a_df_pow_peaks$power < 1 & a_df_pow_peaks$bandwidth < .15, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

4.1 Frequency

Code
frequency_lmer <- lmer(frequency ~ group*sex + age + (1|duo), a_df_pow_peaks[a_df_pow_peaks$power < 1 & a_df_pow_peaks$bandwidth < .15, ])
afex_plot(
  frequency_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 11: frequency
Code
anova(frequency_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.0170664 0.0170664     1 29.360  3.1823 0.08478 .
sex       0.0114298 0.0114298     1 29.634  2.1313 0.15484  
age       0.0009756 0.0009756     1 52.606  0.1819 0.67147  
group:sex 0.0038904 0.0038904     1 29.235  0.7254 0.40129  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(frequency_lmer)
# R2 for Mixed Models

  Conditional R2: 0.225
     Marginal R2: 0.107
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.132
  Unadjusted ICC: 0.118
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.3979

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.19194, p-value = 0.2575

4.2 Power

Code
power_lmer <- lmer(power ~ group*sex + age + (1|duo), a_df_pow_peaks[a_df_pow_peaks$power < 1 & a_df_pow_peaks$bandwidth < .15, ])
afex_plot(
  power_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 12: power
Code
anova(power_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value Pr(>F)
group     0.0091871 0.0091871     1 26.615  0.2899 0.5948
sex       0.0116055 0.0116055     1 26.885  0.3662 0.5502
age       0.0015072 0.0015072     1 52.417  0.0476 0.8282
group:sex 0.0130448 0.0130448     1 26.496  0.4116 0.5267
Code
a_posteriori(power_lmer)
# R2 for Mixed Models

  Conditional R2: 0.128
     Marginal R2: 0.021
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.110
  Unadjusted ICC: 0.108
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 1.3493, p-value = 0.0992

4.3 bandwidth

Code
bandwidth_lmer <- lmer(bandwidth ~ group*sex + age + (1|duo), a_df_pow_peaks[a_df_pow_peaks$power < 1 & a_df_pow_peaks$bandwidth < .15, ])
afex_plot(
  bandwidth_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 13: bandwidth
Code
anova(bandwidth_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
              Sum Sq    Mean Sq NumDF  DenDF F value Pr(>F)
group     1.7162e-05 1.7162e-05     1 28.702  0.0443 0.8348
sex       2.2186e-05 2.2186e-05     1 28.978  0.0573 0.8126
age       8.1796e-05 8.1796e-05     1 52.206  0.2111 0.6478
group:sex 3.1311e-04 3.1311e-04     1 28.575  0.8081 0.3762
Code
a_posteriori(bandwidth_lmer)
# R2 for Mixed Models

  Conditional R2: 0.158
     Marginal R2: 0.021
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.140
  Unadjusted ICC: 0.137
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.4022

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.074103, p-value = 0.3053

5 HR Aperiodic Components (borrowed from EEG PSD analysis)

“In neural data, this aperiodic activity has a 1/f-like distribu- tion, with exponentially decreasing power across increasing fre- quencies. This component can be characterized by a 1/fχ function, whereby the χ parameter, hereafter referred to as the aperiodic exponent, reflects the pattern of aperiodic power across frequen- cies, and is equivalent to the negative slope of the power spectrum when measured in log-log space. The aperiodic component is additionally parameterized with an ‘offset’ parameter, which reflects the uniform shift of power across frequencies. This aperiodic com- ponent has traditionally been ignored, or is treated either as noise or as a nuisance variable to be corrected for, such as is done in spectral whitening, rather than a feature to be explicitly parameterized.” (Donoghue et al. 2020)

Code
some_params <- c('exponent', 'log_knee', 'offset')
ggpairs(a_df_aperiodic,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

No outliers

Code
rosnerTest(a_df_aperiodic$exponent)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_aperiodic$exponent

Sample Size:                     64

Test Statistics:                 R.1 = 3.972216
                                 R.2 = 2.396083
                                 R.3 = 2.134735

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i   Mean.i      SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 4.023082 1.0207330 8.077654      58 3.972216   3.224177    TRUE
2 1 3.958724 0.8884468 6.087516      43 2.396083   3.218230   FALSE
3 2 3.924389 0.8525188 5.744291      41 2.134735   3.212165   FALSE
Code
rosnerTest(a_df_aperiodic$log_knee)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_aperiodic$log_knee

Sample Size:                     64

Test Statistics:                 R.1 = 4.044837
                                 R.2 = 2.344964
                                 R.3 = 2.263906

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i    Mean.i      SD.i      Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 -8.657766 1.1211445  -4.122919      49 4.044837   3.224177    TRUE
2 1 -8.729748 0.9696819 -11.003617      23 2.344964   3.218230   FALSE
3 2 -8.693072 0.9325064  -6.581965      39 2.263906   3.212165   FALSE
Code
ggpairs(a_df_aperiodic[a_df_aperiodic$exponent < 8 & a_df_aperiodic$log_knee < -5, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

5.1 Exponent

Code
exponent_lmer <- lmer(exponent ~ group*sex + age + (1|duo), a_df_aperiodic[a_df_aperiodic$exponent < 8 & a_df_aperiodic$log_knee < -5, ])
afex_plot(
  exponent_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 14: exponent
Code
anova(exponent_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
group     0.86381 0.86381     1 28.968  1.4908 0.2319
sex       0.27189 0.27189     1 30.286  0.4692 0.4986
age       0.98028 0.98028     1 49.620  1.6918 0.1994
group:sex 0.23294 0.23294     1 29.828  0.4020 0.5309
Code
a_posteriori(exponent_lmer)
# R2 for Mixed Models

  Conditional R2: 0.295
     Marginal R2: 0.065
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.245
  Unadjusted ICC: 0.229
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.32882, p-value = 0.2113

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.67729, p-value = 0.165

5.2 log_knee

Code
if('log_knee' %in% colnames(a_df_aperiodic)) {
  #| label: fig-log_knee
  #| fig-cap: 'log_knee'
  #| warning: false
  log_knee_lmer <- lmer(log_knee ~ group*sex + age + (1|duo), a_df_aperiodic[a_df_aperiodic$exponent < 8 & a_df_aperiodic$log_knee < -5, ])
  afex_plot(
    log_knee_lmer,
    x     = 'sex',
    trace = 'group',
    error_arg = list(width = .15),
    dodge     = .3,
    data_arg  = list(
      position = 
        position_jitterdodge(
          jitter.width  = .1, 
          dodge.width   = 0.3  ## needs to be same as dodge
        )),
    mapping   = c('color'),
    point_arg = list(size = 4)
  )
} else {
  summary('Fitted with fixed mode, no knee parameter included.')
}
Aggregating data over: duo

Code
anova(log_knee_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
group     0.2295  0.2295     1 29.068  0.3382 0.565372   
sex       0.9431  0.9431     1 30.410  1.3895 0.247639   
age       6.6012  6.6012     1 51.508  9.7256 0.002973 **
group:sex 0.5544  0.5544     1 29.956  0.8168 0.373315   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(log_knee_lmer)
# R2 for Mixed Models

  Conditional R2: 0.317
     Marginal R2: 0.167
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.181
  Unadjusted ICC: 0.150
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 1.9652, p-value = 0.0685

____________________________________________________________
[1] "Slope for age = -0.0719043815721009"

5.3 Offset

Code
offset_lmer <- lmer(offset ~ group*sex + age + (1|duo), a_df_aperiodic[a_df_aperiodic$exponent < 8, ])
afex_plot(
  offset_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 15: offset
Code
anova(offset_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.49417 0.49417     1 28.631  1.6981 0.20292  
sex       1.54650 1.54650     1 28.909  5.3142 0.02853 *
age       0.86811 0.86811     1 54.640  2.9831 0.08979 .
group:sex 0.30467 0.30467     1 28.559  1.0469 0.31481  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(offset_lmer)
# R2 for Mixed Models

  Conditional R2: 0.244
     Marginal R2: 0.183
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.075
  Unadjusted ICC: 0.061
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.11848, p-value = 0.2979

____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean    SE   df lower.CL upper.CL
 female  0.315 0.106 28.4   0.0985    0.531
 male    0.659 0.104 27.5   0.4463    0.873

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male   -0.345 0.15 28.6  -2.301  0.0289

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

6 Poincaré Plot HRV

“A Poincaré plot (return map) is graphed by plotting every R-R interval against the prior interval, creating a scatter plot. Poincaré plot analysis allows researchers to visually search for patterns buried within a time series (a sequence of values from successive measurements). Unlike frequency-domain measurements, Poincaré plot analysis is insensitive to changes in trends in the R-R intervals” (Shaffer and Ginsberg 2017)

Code
some_params <- c('HRV_SD2', 'HRV_SD1SD2')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

No outliers:

Code
rosnerTest(a_df_hrv$HRV_SD1SD2)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_hrv$HRV_SD1SD2

Sample Size:                     64

Test Statistics:                 R.1 = 5.256081
                                 R.2 = 2.671331
                                 R.3 = 2.432261

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i    Mean.i       SD.i     Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 0.3209757 0.10489220 0.8722977      49 5.256081   3.224177    TRUE
2 1 0.3122246 0.07873690 0.5225569      41 2.671331   3.218230   FALSE
3 2 0.3088321 0.07459351 0.4902630      43 2.432261   3.212165   FALSE
Code
ggpairs(a_df_hrv[a_df_hrv$HRV_SD1SD2 < .8, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

6.1 HRV_SD2

Code
sd2_lmer <- lmer(HRV_SD2 ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRV_SD1SD2 < .8, ])
afex_plot(
  sd2_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 16: HRV_SD2
Code
anova(sd2_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
group       261.9   261.9     1 28.782  0.1956 0.661581   
sex       16527.3 16527.3     1 30.045 12.3430 0.001424 **
age        2584.9  2584.9     1 54.857  1.9304 0.170324   
group:sex    58.4    58.4     1 29.745  0.0436 0.836007   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(sd2_lmer)
# R2 for Mixed Models

  Conditional R2: 0.295
     Marginal R2: 0.236
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.077
  Unadjusted ICC: 0.059
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.59208, p-value = 0.1675

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   91.1 7.10 27.8     76.6      106
 male    127.2 7.22 28.8    112.4      142

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -36.1 10.3 29.3  -3.505  0.0015

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

6.2 HRV_SD1SD2

Code
sd1sd2_lmer <- lmer(HRV_SD1SD2 ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRV_SD1SD2 < .8, ])
afex_plot(
  sd1sd2_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 17: HRV_SD1SD2
Code
anova(sd1sd2_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value Pr(>F)
group     0.0064701 0.0064701     1 28.692  1.0921 0.3047
sex       0.0004992 0.0004992     1 29.969  0.0843 0.7736
age       0.0067814 0.0067814     1 56.219  1.1447 0.2892
group:sex 0.0139797 0.0139797     1 29.661  2.3597 0.1351
Code
a_posteriori(sd1sd2_lmer)
# R2 for Mixed Models

  Conditional R2: 0.101
     Marginal R2: 0.090
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.012
  Unadjusted ICC: 0.011
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.3994

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious

7 Heart Rate Fragmentation (HRF)

“A key aspect of the fragmentation paradigm is that dysfunction or actual breakdown of one or more system components allows for the emergence of high frequency fluctuations that compete with or even exceed the shortest-termmodulatory responsiveness of the vagal system. Therefore, a marker of this fragmentation on the surface ECG should be abrupt changes in the sign of heart rate acceleration, which may be periodic (as with classic sinus node alternans) or more random appearing (as with what has been termed “erratic sinus rhythm”). Such markers of fragmentation may be useful as correlates of cardiovascular aging and/or underlying organic heart disease.” (Costa, Davis, and Goldberger 2017)

Code
some_params <- c('HRF_PIP', 'HRF_IALS', 'HRF_PSS', 'HRF_PAS')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

Code
rosnerTest(a_df_hrv$HRF_PAS)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_hrv$HRF_PAS

Sample Size:                     64

Test Statistics:                 R.1 = 4.266096
                                 R.2 = 2.672123
                                 R.3 = 2.601687

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i     Mean.i       SD.i      Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 0.03683187 0.02806258 0.15654952      49 4.266096   3.224177    TRUE
2 1 0.03493159 0.02377760 0.09846827      61 2.672123   3.218230   FALSE
3 2 0.03390681 0.02252546 0.09251101      46 2.601687   3.212165   FALSE
Code
ggpairs(a_df_hrv[a_df_hrv$HRF_PAS < .15, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

7.1 Percentage of inflection points of the RR intervals series (PIP)

Code
pip_lmer <- lmer(HRF_PIP ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRF_PAS < .15, ])
afex_plot(
  pip_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 18: HRF_PIP
Code
anova(pip_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value Pr(>F)  
group     0.0185276 0.0185276     1 27.816  3.4093 0.0755 .
sex       0.0017608 0.0017608     1 29.021  0.3240 0.5736  
age       0.0052802 0.0052802     1 51.066  0.9716 0.3289  
group:sex 0.0084101 0.0084101     1 28.741  1.5476 0.2235  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(pip_lmer)
# R2 for Mixed Models

  Conditional R2: 0.302
     Marginal R2: 0.122
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.206
  Unadjusted ICC: 0.180
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.4112

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 1.5348, p-value = 0.0812

7.2 Inverse of the average length of the acceleration/deceleration segments (IALS)

Code
ials_lmer <- lmer(HRF_IALS ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRF_PAS < .15, ])
afex_plot(
  ials_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 19: HRF_IALS
Code
anova(ials_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value Pr(>F)  
group     0.0191394 0.0191394     1 27.930  3.4130 0.0753 .
sex       0.0013829 0.0013829     1 29.139  0.2466 0.6232  
age       0.0056012 0.0056012     1 51.323  0.9988 0.3223  
group:sex 0.0086806 0.0086806     1 28.857  1.5479 0.2235  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(ials_lmer)
# R2 for Mixed Models

  Conditional R2: 0.296
     Marginal R2: 0.121
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.199
  Unadjusted ICC: 0.174
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.402

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 1.3161, p-value = 0.1002

7.3 Percentage of short segments (PSS)

Code
pss_lmer <- lmer(HRF_PSS ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRF_PAS < .15, ])
afex_plot(
  pss_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 20: HRF_PSS
Code
anova(pss_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.067467 0.067467     1 28.322  3.4476 0.07377 .
sex       0.000376 0.000376     1 29.450  0.0192 0.89066  
age       0.016426 0.016426     1 48.142  0.8394 0.36414  
group:sex 0.053010 0.053010     1 29.192  2.7088 0.11052  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(pss_lmer)
# R2 for Mixed Models

  Conditional R2: 0.409
     Marginal R2: 0.145
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.309
  Unadjusted ICC: 0.264
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.4011

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 5.4025, p-value = 0.008

7.4 Percentage of NN intervals in alternation segments (PAS)

Code
pas_lmer <- lmer(log10_HRF_PAS ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRF_PAS < .15, ])
afex_plot(
  pas_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 21: HRF_PAS
Code
anova(pas_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value Pr(>F)
group     0.182901 0.182901     1 28.187  2.3208 0.1388
sex       0.003111 0.003111     1 29.166  0.0395 0.8439
age       0.008832 0.008832     1 43.688  0.1121 0.7394
group:sex 0.135700 0.135700     1 28.947  1.7219 0.1998
Code
a_posteriori(pas_lmer)
# R2 for Mixed Models

  Conditional R2: 0.503
     Marginal R2: 0.096
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.450
  Unadjusted ICC: 0.407
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 9.1283, p-value = 0.0017

8 Heart Rate Asymmetry (HRA)

“Previous studies have indicated that the Poincaré plot is physiologically asymmetric with respect to line of identity (the line on which the current heartbeat interval is identical to the preceding one) [14, 15] and this asymmetry changes in diseases, e.g., arrhythmia [19], heart failure [16], obstructive sleep apnea [20], myocardial infarction [21, 22], postoperative myocardial ischemia [23], and type 1 diabetes [24], etc., suggesting possibly an imbalance in autonomic control under those pathological conditions.” (Yan et al. 2017)

Code
some_params <- c('HRA_GI', 'HRA_SI', 'HRA_AI', 'HRA_PI', 'HRA_SDNNd', 'HRA_SDNNa')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

Code
rosnerTest(a_df_hrv$HRA_GI)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_hrv$HRA_GI

Sample Size:                     64

Test Statistics:                 R.1 = 3.728615
                                 R.2 = 3.245314
                                 R.3 = 2.930969

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     2

  i   Mean.i      SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 49.96597 0.1503305 49.40545      10 3.728615   3.224177    TRUE
2 1 49.97487 0.1334757 50.40804      64 3.245314   3.218230    TRUE
3 2 49.96788 0.1224018 50.32664      24 2.930969   3.212165   FALSE
Code
ggpairs(a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

8.1 Guzik’s Index (GI)

Code
gi_lmer <- lmer(HRA_GI ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ])
afex_plot(
  gi_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 22: HRA_GI
Code
anova(gi_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
group     0.040934 0.040934     1    57  2.6907 0.1064
sex       0.002482 0.002482     1    57  0.1631 0.6878
age       0.000012 0.000012     1    57  0.0008 0.9782
group:sex 0.002058 0.002058     1    57  0.1353 0.7144
Code
a_posteriori(gi_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.048

8.2 Slope Index (SI)

Code
si_lmer <- lmer(HRA_SI ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ])
afex_plot(
  si_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 23: HRA_SI
Code
anova(si_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF DenDF F value  Pr(>F)  
group     0.096285 0.096285     1    57  4.3516 0.04146 *
sex       0.009907 0.009907     1    57  0.4478 0.50610  
age       0.005111 0.005111     1    57  0.2310 0.63264  
group:sex 0.028091 0.028091     1    57  1.2696 0.26456  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(si_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.097
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 group       emmean     SE    df lower.CL upper.CL
 humanity     49.96 0.0275 28.46    49.90    50.02
 mindfulness  49.88 0.0265 26.52    49.83    49.93

Results are averaged over the levels of: sex 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast               estimate     SE   df t.ratio p.value
 humanity - mindfulness   0.0803 0.0386 28.1   2.081  0.0466

Results are averaged over the levels of: sex 
Degrees-of-freedom method: kenward-roger 

8.3 Area Index (AI)

Code
ai_lmer <- lmer(HRA_AI ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ])
afex_plot(
  ai_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 24: HRA_AI
Code
anova(ai_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
group     0.008994 0.008994     1    57  0.4397 0.5099
sex       0.045222 0.045222     1    57  2.2110 0.1425
age       0.003755 0.003755     1    57  0.1836 0.6699
group:sex 0.006084 0.006084     1    57  0.2975 0.5876
Code
a_posteriori(ai_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.059

8.4 Porta’s Index (PI)

Code
pi_lmer <- lmer(HRA_PI ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ])
afex_plot(
  pi_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 25: HRA_PI
Code
anova(pi_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
group      31.238  31.238     1 27.732  1.2535 0.27250  
sex       124.379 124.379     1 27.796  4.9909 0.03371 *
age         1.776   1.776     1 53.397  0.0713 0.79053  
group:sex   0.478   0.478     1 27.611  0.0192 0.89088  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(pi_lmer)
# R2 for Mixed Models

  Conditional R2: 0.186
     Marginal R2: 0.107
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.089
  Unadjusted ICC: 0.079
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.78685, p-value = 0.1477

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean    SE   df lower.CL upper.CL
 female   51.0 0.991 27.6     48.9     53.0
 male     54.1 0.992 27.7     52.1     56.2

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -3.16 1.42 28.3  -2.228  0.0340

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

8.5 Total variance of contributions of decelerations (SDNNd)

Code
sdnnd_lmer <- lmer(HRA_SDNNd ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ])
afex_plot(
  sdnnd_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 26: HRA_SDNNd
Code
anova(sdnnd_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
group       44.9    44.9     1 29.602  0.1465 0.704655   
sex       3247.4  3247.4     1 29.664 10.5883 0.002841 **
age        305.2   305.2     1 53.903  0.9953 0.322912   
group:sex  339.9   339.9     1 29.482  1.1083 0.301004   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(sdnnd_lmer)
# R2 for Mixed Models

  Conditional R2: 0.279
     Marginal R2: 0.212
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.085
  Unadjusted ICC: 0.067
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.27205, p-value = 0.2269

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   46.9 3.46 27.6     39.8     54.0
 male     63.0 3.47 27.7     55.9     70.1

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -16.1 4.95 28.3  -3.246  0.0030

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

8.6 Total variance of contributions of accelerations (SDNNa)

Code
sdnna_lmer <- lmer(HRA_SDNNa ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$HRA_GI > 49.5 & a_df_hrv$HRA_GI < 50.4, ])
afex_plot(
  sdnnd_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 27: HRA_SDNNa
Code
anova(sdnna_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF  DenDF F value   Pr(>F)   
group      184.6   184.6     1 29.585  0.3873 0.538495   
sex       5067.9  5067.9     1 29.658 10.6315 0.002793 **
age        621.0   621.0     1 53.463  1.3027 0.258806   
group:sex  253.4   253.4     1 29.460  0.5316 0.471697   
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(sdnna_lmer)
# R2 for Mixed Models

  Conditional R2: 0.296
     Marginal R2: 0.214
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.104
  Unadjusted ICC: 0.082
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.46514, p-value = 0.1915

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean  SE   df lower.CL upper.CL
 female   50.1 4.4 27.6     41.0     59.1
 male     70.5 4.4 27.7     61.5     79.5

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male    -20.5 6.29 28.3  -3.253  0.0030

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

9 Indices of HR Complexity

Code
some_params <- c('HRV_SampEn', 'HRV_ShanEn')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

9.1 HRV_SampEn

“Sample entropy was designed to provide a less biased and more reliable measure of signal regularity and complexity (92). SampEn values are interpreted and used like ApEn and may be calculated from a much shorter time series of fewer than 200 values” (Shaffer and Ginsberg 2017)

Code
sampen_lmer <- lmer(HRV_SampEn ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  sampen_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 28: HRV_SampEn
Code
anova(sampen_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value Pr(>F)
group     0.150995 0.150995     1 28.843  2.6294 0.1158
sex       0.010695 0.010695     1 29.003  0.1862 0.6693
age       0.000962 0.000962     1 55.888  0.0168 0.8975
group:sex 0.046398 0.046398     1 28.766  0.8080 0.3762
Code
a_posteriori(sampen_lmer)
# R2 for Mixed Models

  Conditional R2: 0.115
     Marginal R2: 0.061
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.058
  Unadjusted ICC: 0.054
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.0053143, p-value = 0.379

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0, p-value = 0.4059

9.2 HRV_ShanEn

Code
shanen_lmer <- lmer(HRV_ShanEn ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  shanen_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 29: HRV_ShanEn
Code
anova(shanen_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value    Pr(>F)    
group     0.11334 0.11334     1    59  0.5261 0.4711138    
sex       2.85157 2.85157     1    59 13.2366 0.0005787 ***
age       0.29870 0.29870     1    59  1.3865 0.2437196    
group:sex 0.00032 0.00032     1    59  0.0015 0.9694922    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(shanen_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.216
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean    SE   df lower.CL upper.CL
 female   7.77 0.083 28.1     7.60     7.94
 male     8.20 0.083 28.1     8.03     8.37

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate    SE   df t.ratio p.value
 female - male   -0.431 0.119 28.8  -3.633  0.0011

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

10 Respiratory Rate Variability (RRV)

“As compared to HRV, BRV can provide short‑term effect on anatomic nervous system meditation, while HRV shows long‑term effects. Improved autonomic function is one of the long‑term effects of meditation in which an increase in parasympathetic activity and decrease in sympathetic dominance are observed. In future works, BRV could also be used for measuring stress.” (Soni and Muniyandi 2019)

Code
some_params <- c('rsp_rate', 'log10_RRV_RMSSD', 'RRV_SD2', 'RRV_SD2SD1', 'RRV_ApEn', 'RRV_SampEn')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

Code
rosnerTest(a_df_hrv$RRV_SD2)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_hrv$RRV_SD2

Sample Size:                     64

Test Statistics:                 R.1 = 3.592618
                                 R.2 = 2.895863
                                 R.3 = 2.639238

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i   Mean.i      SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 2831.039 1146.0884 6948.496      54 3.592618   3.224177    TRUE
2 1 2765.682 1028.0667 5742.823      21 2.895863   3.218230   FALSE
3 2 2717.664  962.6023 5258.201      40 2.639238   3.212165   FALSE
Code
rosnerTest(a_df_hrv$RRV_SD2SD1)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_hrv$RRV_SD2SD1

Sample Size:                     64

Test Statistics:                 R.1 = 4.123644
                                 R.2 = 3.075219
                                 R.3 = 3.041633

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i   Mean.i      SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 1.364447 0.3454570 2.788989      54 4.123644   3.224177    TRUE
2 1 1.341836 0.2966731 2.254170      19 3.075219   3.218230   FALSE
3 2 1.327120 0.2749410 2.163390      23 3.041633   3.212165   FALSE
Code
ggpairs(a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

10.1 Respiratory Rate

Code
rsp_rate_lmer <- lmer(rsp_rate ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ])
afex_plot(
  rsp_rate_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 30: rsp_rate
Code
anova(rsp_rate_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
group     18.3754 18.3754     1 27.285  2.2927 0.1415
sex        0.4891  0.4891     1 27.410  0.0610 0.8067
age       16.0596 16.0596     1 46.555  2.0038 0.1636
group:sex  7.5244  7.5244     1 27.299  0.9388 0.3411
Code
a_posteriori(rsp_rate_lmer)
# R2 for Mixed Models

  Conditional R2: 0.394
     Marginal R2: 0.110
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.319
  Unadjusted ICC: 0.284
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 1.2335, p-value = 0.1095

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.74683, p-value = 0.1473

10.2 log10_RRV_RMSSD

Code
log10_rrmssd_lmer <- lmer(log10_RRV_RMSSD ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ])
afex_plot(
  log10_rrmssd_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 31: log10_RRV_RMSSD
Code
anova(log10_rrmssd_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF DenDF F value Pr(>F)
group     0.031879 0.031879     1    58  0.7406 0.3930
sex       0.004161 0.004161     1    58  0.0967 0.7570
age       0.040890 0.040890     1    58  0.9499 0.3338
group:sex 0.001026 0.001026     1    58  0.0238 0.8779
Code
a_posteriori(log10_rrmssd_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.036

10.3 RRV_SD2

Code
rrv_sd2_lmer <- lmer(RRV_SD2 ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ])
afex_plot(
  rrv_sd2_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 32: RRV_SD2
Code
anova(rrv_sd2_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
group     800159  800159     1    58  0.7297 0.3965
sex         2180    2180     1    58  0.0020 0.9646
age       500590  500590     1    58  0.4565 0.5019
group:sex 153268  153268     1    58  0.1398 0.7099
Code
a_posteriori(rrv_sd2_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.028

10.4 RRV_SD2SD1

Code
rrv_sd2sd1_lmer <- lmer(RRV_SD2SD1 ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ])
afex_plot(
  rrv_sd2sd1_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 33: RRV_SD2SD1
Code
anova(rrv_sd2sd1_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value Pr(>F)
group     0.006065 0.006065     1 29.211  0.0867 0.7705
sex       0.000992 0.000992     1 29.346  0.0142 0.9060
age       0.045805 0.045805     1 49.946  0.6551 0.4221
group:sex 0.079769 0.079769     1 29.243  1.1408 0.2942
Code
a_posteriori(rrv_sd2sd1_lmer)
# R2 for Mixed Models

  Conditional R2: 0.266
     Marginal R2: 0.029
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.245
  Unadjusted ICC: 0.238
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.18237, p-value = 0.2622

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.77105, p-value = 0.148

10.5 RRV_ApEn

Code
RRV_ApEn_lmer <- lmer(RRV_ApEn ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ])
afex_plot(
  RRV_ApEn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 34: RRV_ApEn
Code
anova(RRV_ApEn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value Pr(>F)
group     0.018367 0.018367     1 28.916  1.3429 0.2560
sex       0.018127 0.018127     1 29.038  1.3253 0.2590
age       0.016966 0.016966     1 46.757  1.2405 0.2711
group:sex 0.031894 0.031894     1 28.925  2.3319 0.1376
Code
a_posteriori(RRV_ApEn_lmer)
# R2 for Mixed Models

  Conditional R2: 0.426
     Marginal R2: 0.123
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.346
  Unadjusted ICC: 0.303
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.88592, p-value = 0.1331

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 1.8321, p-value = 0.0707

10.6 RRV_SampEn

Code
RRV_SampEn_lmer <- lmer(RRV_SampEn ~ group*sex + age + (1|duo), a_df_hrv[a_df_hrv$RRV_SD2 < 6948, ])
afex_plot(
  RRV_SampEn_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 35: RRV_SampEn
Code
anova(RRV_SampEn_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)  
group     0.05312 0.05312     1 28.192  0.6547 0.4252  
sex       0.00276 0.00276     1 28.329  0.0340 0.8551  
age       0.33274 0.33274     1 50.157  4.1010 0.0482 *
group:sex 0.03956 0.03956     1 28.229  0.4876 0.4907  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(RRV_SampEn_lmer)
# R2 for Mixed Models

  Conditional R2: 0.297
     Marginal R2: 0.098
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.222
  Unadjusted ICC: 0.200
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 2.9644, p-value = 0.0327

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
[1] "Slope for age = 0.0153099700755632"

11 Respiratory Sinus Arrhythmia (RSA)

Code
some_params <- c('RSA_P2T_Mean', 'RSA_PorgesBohrer', 'RSA_Gates_Mean')
ggpairs(a_df_hrv,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

11.1 RSA_P2T_Mean

“The peak to trough method measures the statistical range in ms of the heart period oscillation associated with synchronous respiration. Operationally, subtracting the shortest heart period during inspiration from the longest heart period during expiration produces an estimate of RSA during each breath. The peak-to-trough method makes no statistical assumption or correction (e.g., adaptive filtering) regarding other sources of variance in the heart period time series that may confound, distort, or interact with the metric such as slower periodicities and baseline trend.” (Lewis et al. 2012)

Code
rsa_p2t_lmer <- lmer(RSA_P2T_Mean_log ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  rsa_p2t_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 36: RSA_P2T_Mean
Code
anova(rsa_p2t_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.16694 0.16694     1 29.079  0.4832 0.49251  
sex       1.30035 1.30035     1 29.231  3.7635 0.06209 .
age       0.00869 0.00869     1 53.816  0.0252 0.87455  
group:sex 0.06550 0.06550     1 29.006  0.1896 0.66650  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(rsa_p2t_lmer)
# R2 for Mixed Models

  Conditional R2: 0.209
     Marginal R2: 0.078
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.142
  Unadjusted ICC: 0.131
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0, p-value = 0.4013

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.23033, p-value = 0.2509

11.2 RSA_PorgesBohrer

Some bullshit (Lewis et al. 2012): “A Chebychev type I bandpass filter was applied to the residual series to remove any variance outside the bandwidth of spontaneous respiration (0.12-0.40 Hz).”

Code
rsa_pogboh_lmer <- lmer(RSA_PorgesBohrer ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  rsa_pogboh_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 37: RSA_PorgesBohrer
Code
anova(rsa_pogboh_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
group     0.47421 0.47421     1    59  0.5200 0.4737
sex       0.00155 0.00155     1    59  0.0017 0.9673
age       2.22185 2.22185     1    59  2.4363 0.1239
group:sex 0.13956 0.13956     1    59  0.1530 0.6971
Code
a_posteriori(rsa_pogboh_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.048

11.3 RSA_Gates_Mean

Same bullshit (Gates et al. 2015) as Section 11.2: “As with the traditional approach, the sum of the values (i.e., the squared sum of STFT estimates) in the frequency band of .12 to .40 Hz provides the power in the IBI series associated with respiration frequency for each epoch m.”

Code
rsa_gates_lmer <- lmer(RSA_Gates_Mean_log ~ group*sex + age + (1|duo), a_df_hrv)
afex_plot(
  rsa_gates_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 38: RSA_Gates_Mean
Code
anova(rsa_gates_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value    Pr(>F)    
group     0.0000043 0.0000043     1 29.118  0.0023 0.9621458    
sex       0.0252777 0.0252777     1 29.281 13.3713 0.0009969 ***
age       0.0000023 0.0000023     1 56.786  0.0012 0.9724516    
group:sex 0.0009141 0.0009141     1 29.039  0.4835 0.4923551    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(rsa_gates_lmer)
# R2 for Mixed Models

  Conditional R2: 0.205
     Marginal R2: 0.190
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.019
  Unadjusted ICC: 0.015
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.13472, p-value = 0.2774

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean      SE   df lower.CL upper.CL
 female   2.08 0.00792 28.1     2.06     2.09
 male     2.12 0.00792 28.1     2.10     2.13

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate     SE   df t.ratio p.value
 female - male  -0.0413 0.0113 28.8  -3.652  0.0010

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

12 Cyclic RSA

Code
some_params <- c('rate_diff', 'rate_diff_t', 'rising_slope', 'decay_slope')
ggpairs(a_df_rsa_cyclic,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

No outliers:

Code
rosnerTest(a_df_rsa_cyclic$decay_slope)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_rsa_cyclic$decay_slope

Sample Size:                     64

Test Statistics:                 R.1 = 6.085288
                                 R.2 = 2.570064
                                 R.3 = 2.473754

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i   Mean.i     SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 5.363964 3.934402 29.30594      49 6.085288   3.224177    TRUE
2 1 4.983933 2.517337 11.45365      55 2.570064   3.218230   FALSE
3 2 4.879583 2.396585 10.80815      59 2.473754   3.212165   FALSE
Code
ggpairs(a_df_rsa_cyclic[a_df_rsa_cyclic$decay_slope < 29, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

12.1 rate_diff

Code
rate_diff_lmer <- lmer(rate_diff ~ group*sex + age + (1|duo), a_df_rsa_cyclic[a_df_rsa_cyclic$decay_slope < 29, ])
afex_plot(
  rate_diff_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 39: rate_diff
Code
anova(rate_diff_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
group     61.229  61.229     1    58  1.9806 0.1647
sex       25.001  25.001     1    58  0.8087 0.3722
age       79.405  79.405     1    58  2.5686 0.1144
group:sex 19.428  19.428     1    58  0.6285 0.4312
Code
a_posteriori(rate_diff_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.087

12.2 rate_diff_t

Code
rate_diff_t_lmer <- lmer(rate_diff_t ~ group*sex + age + (1|duo), a_df_rsa_cyclic[a_df_rsa_cyclic$decay_slope < 29, ])
afex_plot(
  rate_diff_t_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 40: rate_diff_t
Code
anova(rate_diff_t_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value Pr(>F)  
group       3.253   3.253     1    58  0.0902 0.7650  
sex       248.245 248.245     1    58  6.8830 0.0111 *
age        62.438  62.438     1    58  1.7312 0.1934  
group:sex 100.196 100.196     1    58  2.7781 0.1010  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(rate_diff_t_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.195
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean   SE   df lower.CL upper.CL
 female   25.7 1.08 27.8     23.5     27.9
 male     21.6 1.10 28.7     19.4     23.9

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate   SE   df t.ratio p.value
 female - male     4.11 1.57 29.3   2.616  0.0139

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

12.3 rising_slope

Code
rising_slope_lmer <- lmer(rising_slope ~ group*sex + age + (1|duo), a_df_rsa_cyclic[a_df_rsa_cyclic$decay_slope < 29, ])
afex_plot(
  rising_slope_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 41: rising_slope
Code
anova(rising_slope_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
group     0.0317  0.0317     1    58  0.0230 0.87990  
sex       1.3272  1.3272     1    58  0.9641 0.33025  
age       9.1393  9.1393     1    58  6.6387 0.01255 *
group:sex 0.0004  0.0004     1    58  0.0003 0.98627  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(rising_slope_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.108
____________________________________________________________
[1] "Slope for age = -0.0791753272376088"

12.4 decay_slope

Code
decay_slope_lmer <- lmer(decay_slope ~ group*sex + age + (1|duo), a_df_rsa_cyclic[a_df_rsa_cyclic$decay_slope < 29, ])
afex_plot(
  decay_slope_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 42: decay_slope
Code
anova(decay_slope_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
group      5.2813  5.2813     1    58  0.8729 0.35404  
sex        0.9363  0.9363     1    58  0.1547 0.69548  
age       29.5941 29.5941     1    58  4.8911 0.03095 *
group:sex  0.6606  0.6606     1    58  0.1092 0.74226  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(decay_slope_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.101
____________________________________________________________
[1] "Slope for age = -0.142473895327648"

13 Clumpiness RSA

Clumpiness (Zhang, Bradlow, and Small 2014) is just Shannon entropy with some makeup.

Code
some_params <- c('inspi_hp_clumpi', 'expi_hp_clumpi', 'inspi_entropy', 'expi_entropy',
                 'davies_bouldin_insp', 'davies_bouldin_exp', 'wasserstein_insp', 'wasserstein_exp')
ggpairs(a_df_clumpiness,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

No outliers:

Code
rosnerTest(a_df_clumpiness$inspi_hp_clumpi , k = 5)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_clumpiness$inspi_hp_clumpi

Sample Size:                     64

Test Statistics:                 R.1 = 3.403150
                                 R.2 = 3.506338
                                 R.3 = 3.574851
                                 R.4 = 3.563527
                                 R.5 = 2.436983

Test Statistic Parameter:        k = 5

Alternative Hypothesis:          Up to 5 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     4

  i     Mean.i       SD.i      Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 0.06339484 0.02352192 0.14344344      32 3.403150   3.224177    TRUE
2 1 0.06212422 0.02138253 0.13709860      33 3.506338   3.218230    TRUE
3 2 0.06091496 0.01926322 0.12977809      23 3.574851   3.212165    TRUE
4 3 0.05978606 0.01723151 0.12119100      24 3.563527   3.205977    TRUE
5 4 0.05876264 0.01539430 0.09627828      31 2.436983   3.199662   FALSE
Code
rosnerTest(a_df_clumpiness$wasserstein_insp, k = 5)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_clumpiness$wasserstein_insp

Sample Size:                     64

Test Statistics:                 R.1 = 3.299862
                                 R.2 = 3.242995
                                 R.3 = 3.522818
                                 R.4 = 2.073377
                                 R.5 = 2.079927

Test Statistic Parameter:        k = 5

Alternative Hypothesis:          Up to 5 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     3

  i   Mean.i     SD.i    Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 7.515140 3.206706 18.09683      33 3.299862   3.224177    TRUE
2 1 7.347177 2.934987 16.86532      24 3.242995   3.218230    TRUE
3 2 7.193659 2.691885 16.67668      58 3.522818   3.212165    TRUE
4 3 7.038199 2.417364 12.05031      63 2.073377   3.205977   FALSE
5 4 6.954664 2.347299 11.83687      17 2.079927   3.199662   FALSE
Code
ggpairs(a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

13.1 inspi_hp_clumpi

Code
inspi_hp_clumpi_lmer <- lmer(inspi_hp_clumpi ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  inspi_hp_clumpi_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 43: inspi_hp_clumpi
Code
anova(inspi_hp_clumpi_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
              Sum Sq    Mean Sq NumDF DenDF F value  Pr(>F)  
group     0.00007366 0.00007366     1    54  0.3275 0.56949  
sex       0.00081638 0.00081638     1    54  3.6298 0.06208 .
age       0.00011749 0.00011749     1    54  0.5224 0.47295  
group:sex 0.00000778 0.00000778     1    54  0.0346 0.85311  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(inspi_hp_clumpi_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.069

13.2 expi_hp_clumpi

Code
expi_hp_clumpi_lmer <- lmer(expi_hp_clumpi ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  expi_hp_clumpi_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 44: expi_hp_clumpi
Code
anova(expi_hp_clumpi_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
              Sum Sq    Mean Sq NumDF  DenDF F value  Pr(>F)  
group     4.5969e-05 4.5969e-05     1 27.901  1.1685 0.28898  
sex       1.1920e-04 1.1920e-04     1 28.422  3.0298 0.09257 .
age       6.3000e-08 6.3000e-08     1 48.779  0.0016 0.96814  
group:sex 2.0784e-05 2.0784e-05     1 27.520  0.5283 0.47347  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(expi_hp_clumpi_lmer)
# R2 for Mixed Models

  Conditional R2: 0.231
     Marginal R2: 0.086
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.159
  Unadjusted ICC: 0.145
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 1.6908, p-value = 0.0759

13.3 inspi_entropy

Code
inspi_entropy_lmer <- lmer(inspi_entropy ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  inspi_entropy_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 45: inspi_entropy
Code
anova(inspi_entropy_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)  
group     0.0000185 0.0000185     1    54  0.0031 0.9557  
sex       0.0179085 0.0179085     1    54  3.0072 0.0886 .
age       0.0035668 0.0035668     1    54  0.5990 0.4424  
group:sex 0.0002726 0.0002726     1    54  0.0458 0.8314  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(inspi_entropy_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.053

13.4 expi_entropy

Code
expi_entropy_lmer <- lmer(expi_entropy ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  expi_entropy_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 46: expi_entropy
Code
anova(expi_entropy_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
              Sum Sq    Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.00054207 0.00054207     1 26.711  1.6011 0.21668  
sex       0.00104752 0.00104752     1 27.286  3.0940 0.08979 .
age       0.00000436 0.00000436     1 52.184  0.0129 0.91014  
group:sex 0.00041042 0.00041042     1 26.297  1.2122 0.28087  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(expi_entropy_lmer)
# R2 for Mixed Models

  Conditional R2: 0.097
     Marginal R2: 0.093
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.004
  Unadjusted ICC: 0.003
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.66217, p-value = 0.1576

13.5 davies_bouldin_insp

One-dimensional clustering with Ckmeans (Wang and Song 2011). Davies-Bouldin Index of cluster similarity (Davies and Bouldin 1979).

Code
davies_bouldin_insp_lmer <- lmer(davies_bouldin_insp ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  davies_bouldin_insp_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 47: davies_bouldin_insp
Code
anova(davies_bouldin_insp_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF DenDF F value Pr(>F)
group     0.0000051 0.0000051     1    54  0.0030 0.9567
sex       0.0041827 0.0041827     1    54  2.4357 0.1244
age       0.0021193 0.0021193     1    54  1.2341 0.2715
group:sex 0.0002185 0.0002185     1    54  0.1273 0.7227
Code
a_posteriori(davies_bouldin_insp_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.054

13.6 davies_bouldin_exp

Code
davies_bouldin_exp_lmer <- lmer(davies_bouldin_exp ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  davies_bouldin_exp_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 48: davies_bouldin_exp
Code
anova(davies_bouldin_exp_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
              Sum Sq    Mean Sq NumDF DenDF F value Pr(>F)
group     0.00042797 0.00042797     1    54  0.2156 0.6442
sex       0.00295427 0.00295427     1    54  1.4886 0.2277
age       0.00277835 0.00277835     1    54  1.4000 0.2419
group:sex 0.00001181 0.00001181     1    54  0.0060 0.9388
Code
a_posteriori(davies_bouldin_exp_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.041

13.7 wasserstein_insp

Wasserstein transport distance (Panaretos and Zemel 2019).

Code
wasserstein_insp_lmer <- lmer(wasserstein_insp ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  wasserstein_insp_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 49: wasserstein_insp
Code
anova(wasserstein_insp_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
group     1.39884 1.39884     1 27.465  0.2415 0.6270
sex       0.12586 0.12586     1 28.008  0.0217 0.8839
age       0.14733 0.14733     1 50.019  0.0254 0.8739
group:sex 0.62920 0.62920     1 27.071  0.1086 0.7442
Code
a_posteriori(wasserstein_insp_lmer)
# R2 for Mixed Models

  Conditional R2: 0.112
     Marginal R2: 0.007
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.106
  Unadjusted ICC: 0.105
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.4811, p-value = 0.1876

13.8 wasserstein_exp

Code
wasserstein_exp_lmer <- lmer(wasserstein_exp ~ group*sex + age + (1|duo), a_df_clumpiness[a_df_clumpiness$inspi_hp_clumpi < .12 & a_df_clumpiness$wasserstein_insp < 16, ])
afex_plot(
  wasserstein_exp_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 50: wasserstein_exp
Code
anova(wasserstein_exp_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
group     0.00359 0.00359     1 27.951  0.0045 0.9471
sex       1.03624 1.03624     1 28.498  1.2940 0.2648
age       1.47339 1.47339     1 50.494  1.8399 0.1810
group:sex 0.10686 0.10686     1 27.554  0.1334 0.7177
Code
a_posteriori(wasserstein_exp_lmer)
# R2 for Mixed Models

  Conditional R2: 0.134
     Marginal R2: 0.046
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.092
  Unadjusted ICC: 0.087
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.837, p-value = 0.1498

____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious

14 Angular RSA

Code
some_params <- c('watson_u2', 'log_watson_f', 'log_wallraff_chi', 'rho_peak', 'rho_trough')
ggpairs(a_df_rsa_angular,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

No outliers:

Code
rosnerTest(a_df_rsa_angular$rho_trough)

Results of Outlier Test
-------------------------

Test Method:                     Rosner's Test for Outliers

Hypothesized Distribution:       Normal

Data:                            a_df_rsa_angular$rho_trough

Sample Size:                     64

Test Statistics:                 R.1 = 5.023125
                                 R.2 = 2.912373
                                 R.3 = 2.560962

Test Statistic Parameter:        k = 3

Alternative Hypothesis:          Up to 3 observations are not
                                 from the same Distribution.

Type I Error:                    5%

Number of Outliers Detected:     1

  i    Mean.i       SD.i     Value Obs.Num    R.i+1 lambda.i+1 Outlier
1 0 0.7864551 0.08558162 0.3565679      49 5.023125   3.224177    TRUE
2 1 0.7932787 0.06644050 0.5997792      30 2.912373   3.218230   FALSE
3 2 0.7963997 0.06215305 0.6372281      61 2.560962   3.212165   FALSE
Code
ggpairs(a_df_rsa_angular[a_df_rsa_angular$rho_trough > .36, ],
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

14.1 watson_u2

Code
watson_u2_lmer <- lmer(watson_u2 ~ group*sex + age + (1|duo), a_df_rsa_angular[a_df_rsa_angular$rho_trough > .36, ])
afex_plot(
  watson_u2_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 51: watson_u2
Code
anova(watson_u2_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
group     10.1549 10.1549     1    58  2.5573 0.1152
sex        9.9310  9.9310     1    58  2.5009 0.1192
age        1.7724  1.7724     1    58  0.4463 0.5067
group:sex  0.1411  0.1411     1    58  0.0355 0.8512
Code
a_posteriori(watson_u2_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.083

14.2 log_watson_f

Code
log_watson_f_lmer <- lmer(log_watson_f ~ group*sex + age + (1|duo), a_df_rsa_angular[a_df_rsa_angular$rho_trough > .36, ])
afex_plot(
  log_watson_f_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 52: log_watson_f
Code
anova(log_watson_f_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
           Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
group     0.03092 0.03092     1    58  0.0345 0.8533
sex       1.15269 1.15269     1    58  1.2863 0.2614
age       0.23956 0.23956     1    58  0.2673 0.6071
group:sex 0.00011 0.00011     1    58  0.0001 0.9911
Code
a_posteriori(log_watson_f_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.031

14.3 log_wallraff_chi

Code
log_wallraff_chi_lmer <- lmer(log_wallraff_chi ~ group*sex + age + (1|duo), a_df_rsa_angular[a_df_rsa_angular$rho_trough > .36, ])
afex_plot(
  log_wallraff_chi_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 53: log_wallraff_chi
Code
anova(log_wallraff_chi_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
          Sum Sq Mean Sq NumDF DenDF F value  Pr(>F)  
group     3.0577  3.0577     1    58  1.0074 0.31969  
sex       8.6897  8.6897     1    58  2.8630 0.09601 .
age       0.2553  0.2553     1    58  0.0841 0.77285  
group:sex 0.2504  0.2504     1    58  0.0825 0.77495  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(log_wallraff_chi_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.071

14.4 rho_peak

Code
rho_peak_lmer <- lmer(rho_peak ~ group*sex + age + (1|duo), a_df_rsa_angular[a_df_rsa_angular$rho_trough > .36, ])
afex_plot(
  rho_peak_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 54: rho_peak
Code
anova(rho_peak_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF  DenDF F value Pr(>F)
group     0.016191 0.016191     1 28.494  1.1922 0.2840
sex       0.004031 0.004031     1 29.735  0.2968 0.5899
age       0.036082 0.036082     1 53.256  2.6568 0.1090
group:sex 0.004926 0.004926     1 29.443  0.3627 0.5516
Code
a_posteriori(rho_peak_lmer)
# R2 for Mixed Models

  Conditional R2: 0.207
     Marginal R2: 0.080
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.138
  Unadjusted ICC: 0.127
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.39345, p-value = 0.203

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0, p-value = 0.4108

14.5 rho_trough

Code
rho_trough_lmer <- lmer(rho_trough ~ group*sex + age + (1|duo), a_df_rsa_angular[a_df_rsa_angular$rho_trough > .36, ])
afex_plot(
  rho_trough_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 55: rho_trough
Code
anova(rho_trough_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value Pr(>F)
group     0.0007723 0.0007723     1 27.350  0.1701 0.6833
sex       0.0008334 0.0008334     1 28.626  0.1835 0.6716
age       0.0019812 0.0019812     1 56.179  0.4363 0.5116
group:sex 0.0032072 0.0032072     1 28.319  0.7063 0.4077
Code
a_posteriori(rho_trough_lmer)
# R2 for Mixed Models

  Conditional R2: 0.036
     Marginal R2: 0.030
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.006
  Unadjusted ICC: 0.006
____________________________________________________________
boundary (singular) fit: see help('isSingular')
Warning in cov2cor(Vr): diag(V) had non-positive or NA entries; the non-finite
result may be dubious
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0.024295, p-value = 0.3445

15 Continuous Coherence RSA

Code
some_params <- c('ccoh_ave_lfhf', 'ccoh_ave_rsp')
ggpairs(a_df_ccoh,
        columns = some_params,
        aes(colour = group, alpha = .25),
        progress = FALSE,
        lower = list(continuous = wrap('points')))

15.1 ccoh_ave_lfhf

Code
ccoh_ave_lfhf_lmer <- lmer(ccoh_ave_lfhf ~ group*sex + age + (1|duo), a_df_ccoh)
afex_plot(
  ccoh_ave_lfhf_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 56: ccoh_ave_lfhf
Code
anova(ccoh_ave_lfhf_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
            Sum Sq  Mean Sq NumDF DenDF F value  Pr(>F)  
group     0.032436 0.032436     1    59  4.9566 0.02982 *
sex       0.035098 0.035098     1    59  5.3634 0.02406 *
age       0.000497 0.000497     1    59  0.0760 0.78379  
group:sex 0.005137 0.005137     1    59  0.7850 0.37921  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(ccoh_ave_lfhf_lmer)
Random effect variances not available. Returned R2 does not account for random effects.
# R2 for Mixed Models

  Conditional R2: NA
     Marginal R2: 0.155
____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 group       emmean     SE df lower.CL upper.CL
 humanity     0.570 0.0144 28    0.540    0.599
 mindfulness  0.524 0.0144 28    0.494    0.553

Results are averaged over the levels of: sex 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast               estimate     SE   df t.ratio p.value
 humanity - mindfulness   0.0459 0.0206 28.7   2.224  0.0342

Results are averaged over the levels of: sex 
Degrees-of-freedom method: kenward-roger 

____________________________________________________________
NOTE: Results may be misleading due to involvement in interactions
$emmeans
 sex    emmean     SE   df lower.CL upper.CL
 female  0.571 0.0145 28.1    0.541    0.600
 male    0.523 0.0145 28.1    0.493    0.552

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 
Confidence level used: 0.95 

$contrasts
 contrast      estimate     SE   df t.ratio p.value
 female - male   0.0478 0.0207 28.8   2.313  0.0281

Results are averaged over the levels of: group 
Degrees-of-freedom method: kenward-roger 

15.2 ccoh_ave_rsp

Code
ccoh_ave_rsp_lmer <- lmer(ccoh_ave_rsp ~ group*sex + age + (1|duo), a_df_ccoh)
afex_plot(
  ccoh_ave_rsp_lmer,
  x     = 'sex',
  trace = 'group',
  error_arg = list(width = .15),
  dodge     = .3,
  data_arg  = list(
    position = 
      position_jitterdodge(
        jitter.width  = .1, 
        dodge.width   = 0.3  ## needs to be same as dodge
      )),
  mapping   = c('color'),
  point_arg = list(size = 4)
)
Figure 57: ccoh_ave_rsp
Code
anova(ccoh_ave_rsp_lmer)
Type III Analysis of Variance Table with Satterthwaite's method
             Sum Sq   Mean Sq NumDF  DenDF F value  Pr(>F)  
group     0.0269503 0.0269503     1 28.272  3.7989 0.06127 .
sex       0.0246976 0.0246976     1 28.431  3.4814 0.07241 .
age       0.0000511 0.0000511     1 55.468  0.0072 0.93266  
group:sex 0.0000192 0.0000192     1 28.196  0.0027 0.95892  
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Code
a_posteriori(ccoh_ave_rsp_lmer)
# R2 for Mixed Models

  Conditional R2: 0.176
     Marginal R2: 0.114
____________________________________________________________
# Intraclass Correlation Coefficient

    Adjusted ICC: 0.070
  Unadjusted ICC: 0.062
____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
humanity LRT = 0.39419, p-value = 0.2077

____________________________________________________________

    simulated finite sample distribution of LRT. (p-value based on 10000
    simulated values)

data:  
mindfulness LRT = 0, p-value = 0.4132

16 References

Costa, Madalena D., Roger B. Davis, and Ary L. Goldberger. 2017. “Heart Rate Fragmentation: A New Approach to the Analysis of Cardiac Interbeat Interval Dynamics.” Frontiers in Physiology 8 (May): 263987. https://doi.org/10.3389/FPHYS.2017.00255/BIBTEX.
Davies, David L., and Donald W. Bouldin. 1979. “A Cluster Separation Measure.” IEEE Transactions on Pattern Analysis and Machine Intelligence PAMI-1: 224–27. https://doi.org/10.1109/TPAMI.1979.4766909.
Donoghue, Thomas, Matar Haller, Erik J. Peterson, Paroma Varma, Priyadarshini Sebastian, Richard Gao, Torben Noto, et al. 2020. “Parameterizing Neural Power Spectra into Periodic and Aperiodic Components.” Nature Neuroscience 23 (December): 1655–65. https://doi.org/10.1038/s41593-020-00744-x.
Gates, Kathleen M., Lisa M. Gatzke-Kopp, Maria Sandsten, and Alysia Y. Blandon. 2015. “Estimating Time-Varying RSA to Examine Psychophysiological Linkage of Marital Dyads.” Psychophysiology 52 (August): 1059–65. https://doi.org/10.1111/PSYP.12428.
Hämmerle, Peter, Christian Eick, Steffen Blum, Vincent Schlageter, Axel Bauer, Konstantinos D. Rizas, Ceylan Eken, et al. 2020. “Heart Rate Variability Triangular Index as a Predictor of Cardiovascular Mortality in Patients with Atrial Fibrillation.” Journal of the American Heart Association 9 (August). https://doi.org/10.1161/JAHA.120.016075/SUPPL_FILE/JAH35363-SUP-0001-SUPINFO.PDF.
Lewis, Gregory F., Senta A. Furman, Martha F. McCool, and Stephen W. Porges. 2012. “Statistical Strategies to Quantify Respiratory Sinus Arrhythmia: Are Commonly Used Metrics Equivalent?” Biological Psychology 89 (February): 349–64. https://doi.org/10.1016/J.BIOPSYCHO.2011.11.009.
Panaretos, Victor M., and Yoav Zemel. 2019. “Statistical Aspects of Wasserstein Distances.” Annual Review of Statistics and Its Application 6 (March): 405–31. https://doi.org/10.1146/ANNUREV-STATISTICS-030718-104938/CITE/REFWORKS.
Shaffer, Fred, and J. P. Ginsberg. 2017. “An Overview of Heart Rate Variability Metrics and Norms.” Frontiers in Public Health. https://doi.org/10.3389/fpubh.2017.00258.
Soni, and Manivannan Muniyandi. 2019. “Breath Rate Variability: A Novel Measure to Study the Meditation Effects.” International Journal of Yoga 12: 45. https://doi.org/10.4103/IJOY.IJOY_27_17.
Tanoue, Yukiya, Tomohiro Komatsu, Shihoko Nakashima, Takuro Matsuda, Ryoma Michishita, Yasuki Higaki, and Yoshinari Uehara. 2022. “The Ratio of Heart Rate to Heart Rate Variability Reflects Sympathetic Activity During Incremental Cycling Exercise.” European Journal of Sport Science 22 (November): 1714–23. https://doi.org/10.1080/17461391.2021.1994652.
Wang, Haizhou, and Mingzhou Song. 2011. “Ckmeans.1d.dp: Optimal k-Means Clustering in One Dimension by Dynamic Programming.” R Journal 3: 29–33. https://doi.org/10.32614/RJ-2011-015.
Yan, Chang, Peng Li, Lizhen Ji, Lianke Yao, Chandan Karmakar, and Changchun Liu. 2017. “Area Asymmetry of Heart Rate Variability Signal.” BioMedical Engineering Online 16 (September): 1–14. https://doi.org/10.1186/S12938-017-0402-3/FIGURES/9.
Zhang, Yao, Eric T. Bradlow, and Dylan S. Small. 2014. “Predicting Customer Value Using Clumpiness: From RFM to RFMC.” Https://Doi.org/10.1287/Mksc.2014.0873 34 (October): 195–208. https://doi.org/10.1287/MKSC.2014.0873.