1 Initialization

rm(list=ls())
library(relativeVariability)
library(rsurveyutils)
library(here)
library(tidyverse)
library(corrplot)
# library(ggthemr)
# theme_set(theme_bw())
# ggthemr("fresh")

library(lmerTest)
library(sjPlot)

# library(aTSA)
library(tidylog)

2 Preprocessing

2.1 Read data

filepath <- here("data/ESM_W2_WITH_MISSING_V1_no exclusions.csv")
df_raw <- read_csv(filepath) 
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
##   dat <- vroom(...)
##   problems(dat)

2.2 Process data

df_emos <- df_raw %>% 
  select(ID, timeStampSent, matches("panas.*scale.*beep"), -matches("new")) %>% 
  # TODO: what is panas scale new
  rename(
    panas_neg = PANAS_negativescale_beep,
    panas_pos = PANAS_positivescale_beep
  )

df_er <- df_raw %>% 
  select(ID, timeStampSent, matches("Emotionregulation_[a-z]+$"),
         -Emotionregulation_selfcompassion1,
         -Emotionregulation_selfcompassion2,
         -Emotionregulation_selfcompassion,
         -Emotionregulation_engagement) %>% 
  rename_all(~str_replace(., "Emotionregulation_", "er_"))

df_indiff <- df_raw %>% 
  select(ID, Sex, Birth_year, Birth_month, Ethnicity, 
         matches("SCARED.*scale"), matches("SMFQ.*scale"),
         # matches("panas"),
         -matches("omit")) %>% 
  rename_all(~str_remove(., "_scale_w2")) %>% 
  distinct() %>%
  left_join(
    df_emos %>% 
      filter(!is.na(panas_neg) & !is.na(panas_pos)) %>% 
      group_by(ID) %>% 
      summarize(
        panas_neg = mean(panas_neg, na.rm=T),
        panas_pos = mean(panas_pos, na.rm=T),
        n_beeps = n()
      )
  ) %>% 
  mutate_at(vars(SCARED, SMFQ, panas_neg, panas_pos), list(z=scale)) 
# confirm 1 row per person
df_indiff %>% 
  count(ID) %>% 
  arrange(desc(n))
## # A tibble: 265 × 2
##    ID        n
##    <chr> <int>
##  1 10015     1
##  2 10016     1
##  3 10017     1
##  4 10018     1
##  5 10020     1
##  6 10021     1
##  7 10022     1
##  8 10026     1
##  9 10027     1
## 10 10028     1
## # ℹ 255 more rows
df_indiff_2 <- df_raw %>% 
  select(ID, Sex, Birth_year, Birth_month, Ethnicity, 
         matches("SCARED.*scale"), matches("SMFQ.*scale"),
         # matches("panas"),
         -matches("omit")) %>% 
  rename_all(~str_remove(., "_scale_w2")) %>% 
  distinct() %>%
  left_join(
    df_emos # %>% 
      # filter(!is.na(panas_neg) & !is.na(panas_pos)) %>% 
  ) %>% 
  mutate_at(vars(SCARED, SMFQ, panas_neg, panas_pos), list(z=scale)) 

2.3 Calculate Metrics

2.3.1 Mean ER

df_mean_er_strat <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating) %>% 
  group_by(ID, strat) %>%
  summarize(
    mean_er = mean(rating)
  ) %>%
  ungroup

2.3.2 Relative Within SD

d <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating)

d %>% 
  group_by(ID, strat) %>% 
  summarize(
    n = n()
  ) %>%
  # arrange(desc(n))
  arrange(n)
## # A tibble: 1,325 × 3
## # Groups:   ID [265]
##    ID    strat                n
##    <chr> <chr>            <int>
##  1 1029  er_distraction       1
##  2 1029  er_reappraisal       1
##  3 1029  er_rumination        1
##  4 1029  er_socialsupport     1
##  5 1029  er_suppresion        1
##  6 8048  er_distraction       1
##  7 8048  er_reappraisal       1
##  8 8048  er_rumination        1
##  9 8048  er_socialsupport     1
## 10 8048  er_suppresion        1
## # ℹ 1,315 more rows
df_rwsd <- d %>% 
  group_by(ID, strat) %>% 
  mutate(n = n()) %>% 
  filter(n > 1) %>% 
  filter(mean(rating) < 7) %>%
  filter(mean(rating) > 1) %>%
  summarize(
    rwsd = relativeSD(rating, 1, 7),
    n = n()
  ) %>% 
  summarize(
    rwsd = mean(rwsd),
    n = mean(n)
  ) %>% 
  ungroup

hist(df_rwsd$rwsd)

# rwsd for each ER strat
df_rwsd_st <- d %>% 
  group_by(ID, strat) %>% 
  mutate(n = n()) %>% 
  filter(n > 1) %>% 
  filter(mean(rating) < 7) %>%
  filter(mean(rating) > 1) %>%
  summarize(
    rwsd = relativeSD(rating, 1, 7),
    n = n()
  )

2.3.3 Relative Between SD

d <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating)

d %>% 
  group_by(ID, timeStampSent) %>% 
  summarize(
    n = n()
  ) %>%
  # arrange(desc(n))
  arrange(n)
## # A tibble: 12,590 × 3
## # Groups:   ID [265]
##    ID    timeStampSent     n
##    <chr>         <dbl> <int>
##  1 7034     1652955304     2
##  2 11187    1653992106     3
##  3 11143    1653768014     4
##  4 11143    1653940813     4
##  5 11143    1654027212     4
##  6 11143    1654157103     4
##  7 11143    1654449309     4
##  8 11170    1653768014     4
##  9 2026     1650967206     4
## 10 2026     1651782618     4
## # ℹ 12,580 more rows
df_rbsd <- d %>% 
  group_by(ID, timeStampSent) %>% 
  mutate(n = n()) %>% 
  filter(n > 1) %>% 
  filter(mean(rating) > 1) %>%
  filter(mean(rating) < 7) %>%
  summarize(
    rbsd = relativeSD(rating, 1, 7),
    n = n()
  ) %>% 
  summarize(
    rbsd = mean(rbsd),
    n = mean(n)
  )

hist(df_rbsd$rbsd)

# rbsd across moments
df_rbsd_st <- d %>% 
  group_by(ID, timeStampSent) %>% 
  mutate(n = n()) %>% 
  filter(n > 1) %>% 
  filter(mean(rating) > 1) %>%
  filter(mean(rating) < 7) %>%
  summarize(
    rbsd = relativeSD(rating, 1, 7),
    n = n()
  )

2.3.4 Successive Difference

d <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating)

d %>% 
  group_by(ID, strat) %>% 
  summarize(
    n = n()
  ) %>%
  # arrange(desc(n))
  arrange(n)
## # A tibble: 1,325 × 3
## # Groups:   ID [265]
##    ID    strat                n
##    <chr> <chr>            <int>
##  1 1029  er_distraction       1
##  2 1029  er_reappraisal       1
##  3 1029  er_rumination        1
##  4 1029  er_socialsupport     1
##  5 1029  er_suppresion        1
##  6 8048  er_distraction       1
##  7 8048  er_reappraisal       1
##  8 8048  er_rumination        1
##  9 8048  er_socialsupport     1
## 10 8048  er_suppresion        1
## # ℹ 1,315 more rows
df_rwrmssd <- d %>% 
  group_by(ID, strat) %>% 
  mutate(n = n()) %>% 
  filter(n > 1) %>% 
  filter(mean(rating) < 7) %>%
  filter(mean(rating) > 1) %>%
  summarize(
    rwrmssd = relativeRMSSD(rating, 1, 7),
    n = n()
  ) %>% 
  summarize(
    rwrmssd = mean(rwrmssd),
    n = mean(n)
  ) %>% 
  ungroup

hist(df_rwrmssd$rwrmssd)

# rwrmssd for each ER strat
df_rwrmssd_st <- d %>% 
  group_by(ID, strat) %>% 
  mutate(n = n()) %>% 
  filter(n > 1) %>% 
  filter(mean(rating) < 7) %>%
  filter(mean(rating) > 1) %>%
  summarize(
    rwrmssd = relativeRMSSD(rating, 1, 7),
    n = n()
  ) %>%
  ungroup

2.3.5 Bray-Curtis

d <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  group_by(ID, strat) %>% 
  arrange(timeStampSent) %>% 
  mutate(
    rating_abs_diff = abs(rating - lag(rating)),
    rating_sum = rating + lag(rating),
  ) %>%
  ungroup %>% 
  drop_na(rating_abs_diff)

# momentary level (state)
df_bc_st <- d %>% 
  group_by(ID, timeStampSent) %>%
  summarize(
    bc = sum(rating_abs_diff, na.rm=T)/sum(rating_sum, na.rm=T)
  )

hist(df_bc_st$bc)

# individual level (trait)
df_bc_tr <- d %>%
  group_by(ID) %>%
  summarize(
    bc = sum(rating_abs_diff, na.rm=T)/sum(rating_sum, na.rm=T),
    n = n()
  ) 

hist(df_bc_tr$bc)

# checking for a relationship between number of observations and bc
df_bc_tr %>% 
  ggplot(aes(x = n, y = bc)) +
  geom_smooth(se=F, size=.4, color="red") + 
  geom_smooth(method="lm") + 
  geom_point()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.

2.3.6 Wentropy (Emotion Regulation Diversity)

# momentary (state)
df_wentropy_st <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating) %>% 
  group_by(ID, timeStampSent) %>% 
  mutate(
    pr = rating/7,
    ln_pr = log(pr),
    pr_ln_pr = pr*ln_pr
    ) %>%
  summarize(
    wentropy = -sum(pr_ln_pr)
  ) %>% 
  ungroup

hist(df_wentropy_st$wentropy)

# individual (trait)
df_wentropy_tr <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating) %>% 
  group_by(ID, strat) %>% 
  summarize(
    pr = sum(rating)/(7*n()),
    ln_pr = log(pr),
    pr_ln_pr = pr*ln_pr
    ) %>%
  summarize(
    wentropy = -sum(pr_ln_pr)
  ) %>% 
  ungroup

hist(df_wentropy_tr$wentropy)

2.3.7 Entropy

# momentary (state)
df_entropy_st <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating) %>% 
  group_by(ID, timeStampSent) %>% 
  mutate(
    pr = rating/sum(rating),
    ln_pr = log(pr),
    pr_ln_pr = pr*ln_pr
    ) %>%
  summarize(
    entropy = -sum(pr_ln_pr)
  ) %>% 
  ungroup

hist(df_entropy_st$entropy, 50)

# individual (trait)
df_entropy_tr <- df_er %>% 
  pivot_longer(cols=starts_with("er_"), 
               names_to="strat", 
               values_to="rating") %>% 
  drop_na(rating) %>% 
  group_by(ID, strat) %>% 
  summarize(
    sum_strategy_rating = sum(rating),
    ) %>%
  mutate(
    pr = sum_strategy_rating/sum(sum_strategy_rating),
    ln_pr = log(pr),
    pr_ln_pr = pr*ln_pr
    ) %>%
  summarize(
    entropy = -sum(pr_ln_pr)
  ) %>% 
  ungroup

hist(df_entropy_tr$entropy, breaks=30)

3 Trait (between-person analysis)

3.1 Cor Between Metrics

d <- df_rwsd %>% 
  select(-n) %>% 
  full_join(df_rbsd %>% select(-n), by="ID") %>%
  full_join(df_rwrmssd %>% select(-n), by="ID") %>%
  full_join(df_bc_tr %>% select(-n), by="ID") %>%
  full_join(df_wentropy_tr, by="ID") %>%
  full_join(df_entropy_tr, by="ID") %>% 
  full_join(df_mean_er_strat, by="ID") %>%
  select(-ID) %>% 
  select(-strat)
## select: dropped one variable (n)
## select: dropped one variable (n)
## full_join: added one column (rbsd)
##            > rows only in x                         0
##            > rows only in df_rbsd %>% select(-n)    1
##            > matched rows                         253
##            >                                     =====
##            > rows total                           254
## select: dropped one variable (n)
## full_join: added one column (rwrmssd)
##            > rows only in x                            1
##            > rows only in df_rwrmssd %>% select(-n)    0
##            > matched rows                            253
##            >                                        =====
##            > rows total                              254
## select: dropped one variable (n)
## full_join: added one column (bc)
##            > rows only in x                          6
##            > rows only in df_bc_tr %>% select(-n)    9
##            > matched rows                          248
##            >                                      =====
##            > rows total                            263
## full_join: added one column (wentropy)
##            > rows only in x                 0
##            > rows only in df_wentropy_tr    2
##            > matched rows                 263
##            >                             =====
##            > rows total                   265
## full_join: added one column (entropy)
##            > rows only in x                0
##            > rows only in df_entropy_tr    0
##            > matched rows                265
##            >                            =====
##            > rows total                  265
## full_join: added 2 columns (strat, mean_er)
##            > rows only in x                     0
##            > rows only in df_mean_er_strat      0
##            > matched rows                   1,325    (includes duplicates)
##            >                               =======
##            > rows total                     1,325
## select: dropped one variable (ID)
## select: dropped one variable (strat)
corrplot::corrplot(cor(d, use="pairwise.complete.obs"))

cor(d, use="pairwise.complete.obs")
##                 rwsd        rbsd     rwrmssd          bc   wentropy     entropy
## rwsd      1.00000000  0.69307528  0.90168342 -0.01388751 -0.1229160 -0.05263748
## rbsd      0.69307528  1.00000000  0.64130309 -0.03940082 -0.2611491 -0.29040009
## rwrmssd   0.90168342  0.64130309  1.00000000 -0.11901781 -0.1643954  0.02033524
## bc       -0.01388751 -0.03940082 -0.11901781  1.00000000  0.5667578  0.01220801
## wentropy -0.12291598 -0.26114908 -0.16439543  0.56675784  1.0000000  0.21150563
## entropy  -0.05263748 -0.29040009  0.02033524  0.01220801  0.2115056  1.00000000
## mean_er  -0.44514455 -0.20574042 -0.55858523  0.21007821 -0.2679604 -0.16430195
##             mean_er
## rwsd     -0.4451445
## rbsd     -0.2057404
## rwrmssd  -0.5585852
## bc        0.2100782
## wentropy -0.2679604
## entropy  -0.1643019
## mean_er   1.0000000
pairwise_n <- matrix(NA, ncol = ncol(d), nrow = ncol(d))
colnames(pairwise_n) <- colnames(d)
rownames(pairwise_n) <- colnames(d)

for (i in 1:ncol(d)) {
  for (j in 1:ncol(d)) {
    pairwise_n[i, j] <- sum(!is.na(d[, i]) & !is.na(d[, j]))
  }
}

# Degrees of freedom = number of pairs - 2
df_matrix <- pairwise_n - 2

3.2 Relative Within SD

df_rwsd_outcomes <- df_rwsd %>% 
  left_join(df_indiff) 
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff ( 12)
## > matched rows 253
## > =====
## > rows total 253

3.2.1 Depression

fit <- lm(SMFQ ~ rwsd, data=df_rwsd_outcomes)
tab_model(fit)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.66 1.45 – 1.88 <0.001
rwsd -0.29 -0.57 – -0.01 0.039
Observations 245
R2 / R2 adjusted 0.017 / 0.013
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SMFQ ~ poly(rwsd, 3), data=df_rwsd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SMFQ ~ rwsd
## Model 2: SMFQ ~ poly(rwsd, 3)
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1    243 47.872                           
## 2    241 47.290  2   0.58157 1.4819 0.2293
tab_model(fit_2)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.45 1.39 – 1.50 <0.001
rwsd [1st degree] -0.93 -1.80 – -0.05 0.039
rwsd [2nd degree] -0.58 -1.46 – 0.30 0.194
rwsd [3rd degree] -0.51 -1.38 – 0.37 0.259
Observations 245
R2 / R2 adjusted 0.029 / 0.017

3.2.2 Anxiety

fit <- lm(SCARED ~ rwsd, data=df_rwsd_outcomes)
tab_model(fit)
  SCARED
Predictors Estimates CI p
(Intercept) 2.19 1.98 – 2.41 <0.001
rwsd -0.35 -0.63 – -0.06 0.017
Observations 244
R2 / R2 adjusted 0.023 / 0.019
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SCARED ~ poly(rwsd, 2), data=df_rwsd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SCARED ~ rwsd
## Model 2: SCARED ~ poly(rwsd, 2)
##   Res.Df    RSS Df Sum of Sq      F   Pr(>F)   
## 1    242 49.273                                
## 2    241 47.769  1    1.5037 7.5866 0.006329 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  SCARED
Predictors Estimates CI p
(Intercept) 1.94 1.88 – 1.99 <0.001
rwsd [1st degree] -1.11 -1.99 – -0.22 0.014
rwsd [2nd degree] -1.24 -2.12 – -0.35 0.006
Observations 244
R2 / R2 adjusted 0.053 / 0.045

3.2.3 Neg Affect

fit <- lm(panas_neg ~ rwsd, data=df_rwsd_outcomes)
tab_model(fit)
  panas_neg
Predictors Estimates CI p
(Intercept) 2.84 2.45 – 3.22 <0.001
rwsd -1.37 -1.88 – -0.87 <0.001
Observations 253
R2 / R2 adjusted 0.103 / 0.100
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_neg ~ poly(rwsd, 2), data=df_rwsd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_neg ~ rwsd
## Model 2: panas_neg ~ poly(rwsd, 2)
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1    251 162.85                                  
## 2    250 154.21  1    8.6441 14.014 0.0002252 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_neg
Predictors Estimates CI p
(Intercept) 1.83 1.73 – 1.92 <0.001
rwsd [1st degree] -4.33 -5.88 – -2.79 <0.001
rwsd [2nd degree] -2.94 -4.49 – -1.39 <0.001
Observations 253
R2 / R2 adjusted 0.151 / 0.144

3.2.4 Pos Affect

fit <- lm(panas_pos ~ rwsd, data=df_rwsd_outcomes)
tab_model(fit)
  panas_pos
Predictors Estimates CI p
(Intercept) 3.97 3.40 – 4.55 <0.001
rwsd 1.56 0.81 – 2.31 <0.001
Observations 253
R2 / R2 adjusted 0.062 / 0.059
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_pos ~ poly(rwsd, 2), data=df_rwsd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_pos ~ rwsd
## Model 2: panas_pos ~ poly(rwsd, 2)
##   Res.Df    RSS Df Sum of Sq      F   Pr(>F)   
## 1    251 363.14                                
## 2    250 349.03  1    14.112 10.108 0.001662 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_pos
Predictors Estimates CI p
(Intercept) 5.12 4.97 – 5.27 <0.001
rwsd [1st degree] 4.92 2.59 – 7.24 <0.001
rwsd [2nd degree] 3.76 1.43 – 6.08 0.002
Observations 253
R2 / R2 adjusted 0.099 / 0.092

3.3 Relative Between SD

df_rbsd_outcomes <- df_rbsd %>% 
  left_join(df_indiff) 
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff ( 11)
## > matched rows 254
## > =====
## > rows total 254

3.3.1 Depression

fit <- lm(SMFQ ~ rbsd, data=df_rbsd_outcomes)
tab_model(fit)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.55 1.40 – 1.70 <0.001
rbsd -0.16 -0.38 – 0.05 0.141
Observations 246
R2 / R2 adjusted 0.009 / 0.005
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SMFQ ~ poly(rbsd, 4), data=df_rbsd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SMFQ ~ rbsd
## Model 2: SMFQ ~ poly(rbsd, 4)
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1    244 48.424                           
## 2    241 47.303  3    1.1203 1.9025 0.1298
tab_model(fit_2)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.44 1.39 – 1.50 <0.001
rbsd [1st degree] -0.65 -1.52 – 0.23 0.149
rbsd [2nd degree] 0.24 -0.63 – 1.12 0.585
rbsd [3rd degree] -0.31 -1.19 – 0.58 0.493
rbsd [4th degree] -1.00 -1.88 – -0.12 0.027
Observations 246
R2 / R2 adjusted 0.032 / 0.016

3.3.2 Anxiety

fit <- lm(SCARED ~ rbsd, data=df_rbsd_outcomes)
tab_model(fit)
  SCARED
Predictors Estimates CI p
(Intercept) 2.03 1.87 – 2.19 <0.001
rbsd -0.14 -0.36 – 0.08 0.212
Observations 245
R2 / R2 adjusted 0.006 / 0.002
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.3.3 Neg Affect

fit <- lm(panas_neg ~ rbsd, data=df_rbsd_outcomes)
tab_model(fit)
  panas_neg
Predictors Estimates CI p
(Intercept) 2.23 1.94 – 2.51 <0.001
rbsd -0.61 -1.01 – -0.21 0.003
Observations 254
R2 / R2 adjusted 0.034 / 0.030
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_neg ~ poly(rbsd, 2), data=df_rbsd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_neg ~ rbsd
## Model 2: panas_neg ~ poly(rbsd, 2)
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1    252 175.43                                  
## 2    251 167.97  1    7.4575 11.144 0.0009712 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_neg
Predictors Estimates CI p
(Intercept) 1.83 1.72 – 1.93 <0.001
rbsd [1st degree] -2.49 -4.10 – -0.88 0.003
rbsd [2nd degree] -2.73 -4.34 – -1.12 0.001
Observations 254
R2 / R2 adjusted 0.075 / 0.068

3.3.4 Pos Affect

fit <- lm(panas_pos ~ rbsd, data=df_rbsd_outcomes)
tab_model(fit)
  panas_pos
Predictors Estimates CI p
(Intercept) 4.69 4.27 – 5.11 <0.001
rbsd 0.66 0.07 – 1.26 0.028
Observations 254
R2 / R2 adjusted 0.019 / 0.015
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.4 Successive Difference

df_rwrmssd_outcomes <- df_rwrmssd %>% 
  left_join(df_indiff) 
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff ( 12)
## > matched rows 253
## > =====
## > rows total 253

3.4.1 Depression

fit <- lm(SMFQ ~ rwrmssd, data=df_rwrmssd_outcomes)
tab_model(fit)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.68 1.51 – 1.85 <0.001
rwrmssd -0.39 -0.65 – -0.13 0.004
Observations 245
R2 / R2 adjusted 0.034 / 0.030
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.4.2 Anxiety

fit <- lm(SCARED ~ rwrmssd, data=df_rwrmssd_outcomes)
tab_model(fit)
  SCARED
Predictors Estimates CI p
(Intercept) 2.24 2.07 – 2.40 <0.001
rwrmssd -0.49 -0.76 – -0.23 <0.001
Observations 244
R2 / R2 adjusted 0.053 / 0.049
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SCARED ~ poly(rwrmssd, 2), data=df_rwrmssd_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SCARED ~ rwrmssd
## Model 2: SCARED ~ poly(rwrmssd, 2)
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1    242 47.770                                  
## 2    241 45.115  1    2.6555 14.185 0.0002082 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  SCARED
Predictors Estimates CI p
(Intercept) 1.94 1.88 – 1.99 <0.001
rwrmssd [1st degree] -1.67 -2.54 – -0.80 <0.001
rwrmssd [2nd degree] -1.64 -2.50 – -0.78 <0.001
Observations 244
R2 / R2 adjusted 0.106 / 0.098

3.4.3 Neg Affect

fit <- lm(panas_neg ~ rwrmssd, data=df_rwrmssd_outcomes)
tab_model(fit)
  panas_neg
Predictors Estimates CI p
(Intercept) 2.78 2.49 – 3.08 <0.001
rwrmssd -1.58 -2.03 – -1.12 <0.001
Observations 253
R2 / R2 adjusted 0.156 / 0.153
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.4.4 Pos Affect

fit <- lm(panas_pos ~ rwrmssd, data=df_rwrmssd_outcomes)
tab_model(fit)
  panas_pos
Predictors Estimates CI p
(Intercept) 4.23 3.78 – 4.68 <0.001
rwrmssd 1.47 0.77 – 2.18 <0.001
Observations 253
R2 / R2 adjusted 0.064 / 0.060
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.5 Bray-Curtis

df_bc_tr_outcomes <- df_bc_tr %>% 
  left_join(df_indiff) 
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff ( 8)
## > matched rows 257
## > =====
## > rows total 257

3.5.1 Depression

fit <- lm(SMFQ ~ bc, data=df_bc_tr_outcomes)
tab_model(fit)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.37 1.27 – 1.47 <0.001
bc 0.45 -0.04 – 0.95 0.074
Observations 249
R2 / R2 adjusted 0.013 / 0.009
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SMFQ ~ poly(bc, 2), data=df_bc_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SMFQ ~ bc
## Model 2: SMFQ ~ poly(bc, 2)
##   Res.Df    RSS Df Sum of Sq     F  Pr(>F)  
## 1    247 48.279                             
## 2    246 47.509  1   0.77018 3.988 0.04693 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.44 1.39 – 1.50 <0.001
bc [1st degree] 0.81 -0.06 – 1.69 0.069
bc [2nd degree] -0.88 -1.75 – -0.01 0.047
Observations 249
R2 / R2 adjusted 0.029 / 0.021

3.5.2 Anxiety

fit <- lm(SCARED ~ bc, data=df_bc_tr_outcomes)
tab_model(fit)
  SCARED
Predictors Estimates CI p
(Intercept) 1.79 1.68 – 1.89 <0.001
bc 0.84 0.33 – 1.34 0.001
Observations 249
R2 / R2 adjusted 0.041 / 0.038
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SCARED ~ poly(bc, 2), data=df_bc_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SCARED ~ bc
## Model 2: SCARED ~ poly(bc, 2)
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1    247 50.105                                  
## 2    246 47.480  1    2.6258 13.605 0.0002777 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  SCARED
Predictors Estimates CI p
(Intercept) 1.93 1.87 – 1.98 <0.001
bc [1st degree] 1.50 0.63 – 2.38 0.001
bc [2nd degree] -1.63 -2.50 – -0.76 <0.001
Observations 249
R2 / R2 adjusted 0.092 / 0.084

3.5.3 Neg Affect

fit <- lm(panas_neg ~ bc, data=df_bc_tr_outcomes)
tab_model(fit)
  panas_neg
Predictors Estimates CI p
(Intercept) 1.38 1.20 – 1.56 <0.001
bc 2.51 1.62 – 3.40 <0.001
Observations 257
R2 / R2 adjusted 0.108 / 0.105
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_neg ~ poly(bc, 2), data=df_bc_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_neg ~ bc
## Model 2: panas_neg ~ poly(bc, 2)
##   Res.Df    RSS Df Sum of Sq      F    Pr(>F)    
## 1    255 164.24                                  
## 2    254 153.35  1    10.882 18.023 3.062e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_neg
Predictors Estimates CI p
(Intercept) 1.80 1.71 – 1.90 <0.001
bc [1st degree] 4.46 2.93 – 5.99 <0.001
bc [2nd degree] -3.30 -4.83 – -1.77 <0.001
Observations 257
R2 / R2 adjusted 0.167 / 0.161

3.5.4 Pos Affect

fit <- lm(panas_pos ~ bc, data=df_bc_tr_outcomes)
tab_model(fit)
  panas_pos
Predictors Estimates CI p
(Intercept) 5.66 5.39 – 5.93 <0.001
bc -2.97 -4.31 – -1.64 <0.001
Observations 257
R2 / R2 adjusted 0.070 / 0.066
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_pos ~ poly(bc, 2), data=df_bc_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_pos ~ bc
## Model 2: panas_pos ~ poly(bc, 2)
##   Res.Df    RSS Df Sum of Sq     F   Pr(>F)   
## 1    255 370.31                               
## 2    254 357.02  1    13.295 9.459 0.002331 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_pos
Predictors Estimates CI p
(Intercept) 5.16 5.02 – 5.31 <0.001
bc [1st degree] -5.28 -7.62 – -2.95 <0.001
bc [2nd degree] 3.65 1.31 – 5.98 0.002
Observations 257
R2 / R2 adjusted 0.104 / 0.096

3.6 Wentropy (Emotion Regulation Diversity)

df_wentropy_tr_outcomes <- df_wentropy_tr %>% 
  left_join(df_indiff) 
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff ( 0)
## > matched rows 265
## > =====
## > rows total 265

3.6.1 Depression

fit <- lm(SMFQ ~ wentropy, data=df_wentropy_tr_outcomes)
tab_model(fit)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.31 0.95 – 1.67 <0.001
wentropy 0.08 -0.15 – 0.32 0.497
Observations 257
R2 / R2 adjusted 0.002 / -0.002
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SMFQ ~ poly(wentropy, 4), data=df_wentropy_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SMFQ ~ wentropy
## Model 2: SMFQ ~ poly(wentropy, 4)
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)
## 1    255 49.912                           
## 2    252 48.909  3    1.0033 1.7231 0.1627
tab_model(fit_2)
  SMFQ
Predictors Estimates CI p
(Intercept) 1.43 1.38 – 1.49 <0.001
wentropy [1st degree] 0.30 -0.57 – 1.18 0.493
wentropy [2nd degree] 0.32 -0.55 – 1.20 0.470
wentropy [3rd degree] -0.14 -1.02 – 0.73 0.748
wentropy [4th degree] -0.94 -1.82 – -0.07 0.034
Observations 257
R2 / R2 adjusted 0.022 / 0.006

3.6.2 Anxiety

fit <- lm(SCARED ~ wentropy, data=df_wentropy_tr_outcomes)
tab_model(fit)
  SCARED
Predictors Estimates CI p
(Intercept) 1.71 1.33 – 2.09 <0.001
wentropy 0.13 -0.11 – 0.38 0.284
Observations 256
R2 / R2 adjusted 0.005 / 0.001
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(SCARED ~ poly(wentropy, 4), data=df_wentropy_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: SCARED ~ wentropy
## Model 2: SCARED ~ poly(wentropy, 4)
##   Res.Df    RSS Df Sum of Sq      F Pr(>F)  
## 1    254 53.950                             
## 2    251 52.519  3    1.4311 2.2799 0.0799 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  SCARED
Predictors Estimates CI p
(Intercept) 1.92 1.86 – 1.97 <0.001
wentropy [1st degree] 0.50 -0.40 – 1.41 0.275
wentropy [2nd degree] 0.56 -0.35 – 1.47 0.225
wentropy [3rd degree] -0.05 -0.96 – 0.86 0.910
wentropy [4th degree] -1.06 -1.97 – -0.16 0.022
Observations 256
R2 / R2 adjusted 0.031 / 0.015

3.6.3 Neg Affect

fit <- lm(panas_neg ~ wentropy, data=df_wentropy_tr_outcomes)
tab_model(fit)
  panas_neg
Predictors Estimates CI p
(Intercept) 0.89 0.21 – 1.57 0.010
wentropy 0.59 0.15 – 1.03 0.008
Observations 265
R2 / R2 adjusted 0.026 / 0.022
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_neg ~ poly(wentropy, 3), data=df_wentropy_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_neg ~ wentropy
## Model 2: panas_neg ~ poly(wentropy, 3)
##   Res.Df    RSS Df Sum of Sq      F  Pr(>F)  
## 1    263 182.27                              
## 2    261 176.09  2    6.1727 4.5744 0.01115 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_neg
Predictors Estimates CI p
(Intercept) 1.80 1.70 – 1.90 <0.001
wentropy [1st degree] 2.21 0.59 – 3.83 0.008
wentropy [2nd degree] 1.81 0.19 – 3.43 0.028
wentropy [3rd degree] 1.70 0.08 – 3.32 0.040
Observations 265
R2 / R2 adjusted 0.059 / 0.048

3.6.4 Pos Affect

fit <- lm(panas_pos ~ wentropy, data=df_wentropy_tr_outcomes)
tab_model(fit)
  panas_pos
Predictors Estimates CI p
(Intercept) 7.08 6.09 – 8.06 <0.001
wentropy -1.25 -1.88 – -0.61 <0.001
Observations 265
R2 / R2 adjusted 0.053 / 0.049
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.7 Entropy

df_entropy_tr_outcomes <- df_entropy_tr %>% 
  left_join(df_indiff) 
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff ( 0)
## > matched rows 265
## > =====
## > rows total 265

3.7.1 Depression

fit <- lm(SMFQ ~ entropy, data=df_entropy_tr_outcomes)
tab_model(fit)
  SMFQ
Predictors Estimates CI p
(Intercept) 3.78 2.13 – 5.42 <0.001
entropy -1.47 -2.51 – -0.44 0.005
Observations 257
R2 / R2 adjusted 0.030 / 0.026
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.7.2 Anxiety

fit <- lm(SCARED ~ entropy, data=df_entropy_tr_outcomes)
tab_model(fit)
  SCARED
Predictors Estimates CI p
(Intercept) 4.25 2.54 – 5.97 <0.001
entropy -1.47 -2.55 – -0.39 0.008
Observations 256
R2 / R2 adjusted 0.028 / 0.024
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

3.7.3 Neg Affect

fit <- lm(panas_neg ~ entropy, data=df_entropy_tr_outcomes)
tab_model(fit)
  panas_neg
Predictors Estimates CI p
(Intercept) 3.82 0.69 – 6.96 0.017
entropy -1.28 -3.25 – 0.70 0.204
Observations 265
R2 / R2 adjusted 0.006 / 0.002
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_neg ~ poly(entropy, 2), data=df_entropy_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_neg ~ entropy
## Model 2: panas_neg ~ poly(entropy, 2)
##   Res.Df    RSS Df Sum of Sq      F  Pr(>F)  
## 1    263 186.00                              
## 2    262 182.69  1    3.3111 4.7485 0.03021 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_neg
Predictors Estimates CI p
(Intercept) 1.80 1.70 – 1.90 <0.001
entropy [1st degree] -1.07 -2.71 – 0.57 0.201
entropy [2nd degree] -1.82 -3.46 – -0.18 0.030
Observations 265
R2 / R2 adjusted 0.024 / 0.016

3.7.4 Pos Affect

fit <- lm(panas_pos ~ entropy, data=df_entropy_tr_outcomes)
tab_model(fit)
  panas_pos
Predictors Estimates CI p
(Intercept) 2.60 -2.02 – 7.23 0.268
entropy 1.62 -1.29 – 4.53 0.274
Observations 265
R2 / R2 adjusted 0.005 / 0.001
plot_model(fit, type="slope")
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'

fit_2 <- lm(panas_pos ~ poly(entropy, 2), data=df_entropy_tr_outcomes)
anova(fit, fit_2)
## Analysis of Variance Table
## 
## Model 1: panas_pos ~ entropy
## Model 2: panas_pos ~ poly(entropy, 2)
##   Res.Df    RSS Df Sum of Sq      F  Pr(>F)  
## 1    263 404.50                              
## 2    262 399.99  1    4.5077 2.9526 0.08692 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
tab_model(fit_2)
  panas_pos
Predictors Estimates CI p
(Intercept) 5.18 5.03 – 5.33 <0.001
entropy [1st degree] 1.36 -1.07 – 3.79 0.272
entropy [2nd degree] 2.12 -0.31 – 4.56 0.087
Observations 265
R2 / R2 adjusted 0.016 / 0.008

4 Momentary (within-person analysis)

4.1 Cor Between Metrics

df_bc_st_mean <- df_bc_st %>% 
  group_by(ID) %>% 
  summarize(mean_bc = mean(bc, na.rm = TRUE))
## group_by: one grouping variable (ID)
## summarize: now 257 rows and 2 columns, ungrouped
df_wentropy_st_mean <- df_wentropy_st %>% 
  group_by(ID) %>% 
  summarize(mean_wentropy = mean(wentropy, na.rm = TRUE))
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
df_entropy_st_mean <- df_entropy_st %>% 
  group_by(ID) %>% 
  summarize(mean_entropy = mean(entropy, na.rm = TRUE))
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
d <- df_rwsd %>% 
  select(-n) %>% 
  full_join(df_rbsd %>% select(-n), by="ID") %>%
  full_join(df_rwrmssd %>% select(-n), by="ID") %>%
  full_join(df_bc_st_mean, by="ID") %>%
  full_join(df_wentropy_st_mean, by="ID") %>%
  full_join(df_entropy_st_mean, by="ID") %>% 
  full_join(df_mean_er_strat, by="ID") %>%
  select(-ID) %>% 
  select(-strat)
## select: dropped one variable (n)
## select: dropped one variable (n)
## full_join: added one column (rbsd)
##            > rows only in x                         0
##            > rows only in df_rbsd %>% select(-n)    1
##            > matched rows                         253
##            >                                     =====
##            > rows total                           254
## select: dropped one variable (n)
## full_join: added one column (rwrmssd)
##            > rows only in x                            1
##            > rows only in df_rwrmssd %>% select(-n)    0
##            > matched rows                            253
##            >                                        =====
##            > rows total                              254
## full_join: added one column (mean_bc)
##            > rows only in x                6
##            > rows only in df_bc_st_mean    9
##            > matched rows                248
##            >                            =====
##            > rows total                  263
## full_join: added one column (mean_wentropy)
##            > rows only in x                      0
##            > rows only in df_wentropy_st_mean    2
##            > matched rows                      263
##            >                                  =====
##            > rows total                        265
## full_join: added one column (mean_entropy)
##            > rows only in x                     0
##            > rows only in df_entropy_st_mean    0
##            > matched rows                     265
##            >                                 =====
##            > rows total                       265
## full_join: added 2 columns (strat, mean_er)
##            > rows only in x                     0
##            > rows only in df_mean_er_strat      0
##            > matched rows                   1,325    (includes duplicates)
##            >                               =======
##            > rows total                     1,325
## select: dropped one variable (ID)
## select: dropped one variable (strat)
corrplot::corrplot(cor(d, use="pairwise.complete.obs"))

cor(d, use="pairwise.complete.obs")
##                     rwsd        rbsd     rwrmssd     mean_bc mean_wentropy
## rwsd           1.0000000  0.69307528  0.90168342 -0.14082009   -0.23403019
## rbsd           0.6930753  1.00000000  0.64130309 -0.06915301   -0.36418921
## rwrmssd        0.9016834  0.64130309  1.00000000 -0.27621472   -0.05835954
## mean_bc       -0.1408201 -0.06915301 -0.27621472  1.00000000   -0.16626100
## mean_wentropy -0.2340302 -0.36418921 -0.05835954 -0.16626100    1.00000000
## mean_entropy  -0.0435414 -0.33794978  0.12736986 -0.48980349    0.43857187
## mean_er       -0.4451445 -0.20574042 -0.55858523  0.38774922   -0.57420085
##               mean_entropy    mean_er
## rwsd            -0.0435414 -0.4451445
## rbsd            -0.3379498 -0.2057404
## rwrmssd          0.1273699 -0.5585852
## mean_bc         -0.4898035  0.3877492
## mean_wentropy    0.4385719 -0.5742008
## mean_entropy     1.0000000 -0.3772359
## mean_er         -0.3772359  1.0000000
pairwise_n <- matrix(NA, ncol = ncol(d), nrow = ncol(d))
colnames(pairwise_n) <- colnames(d)
rownames(pairwise_n) <- colnames(d)

for (i in 1:ncol(d)) {
  for (j in 1:ncol(d)) {
    pairwise_n[i, j] <- sum(!is.na(d[, i]) & !is.na(d[, j]))
  }
}

# Degrees of freedom = number of pairs - 2
df_matrix <- pairwise_n - 2

4.2 Relative Within SD

# all ER strategies
df_rwsd_outcomes <- df_rwsd %>% 
  left_join(df_indiff_2) %>% 
  left_join(
    df_mean_er_strat %>%
      group_by(ID) %>%
      summarize(mean_ID_er = mean(mean_er, na.rm = TRUE)) %>%
      select(ID, mean_ID_er) %>% 
      ungroup() 
    )
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff_2 ( 836)
## > matched rows 17,573 (includes duplicates)
## > ========
## > rows total 17,573
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
## select: no changes
## ungroup: no grouping variables remain
## Joining with `by = join_by(ID)`
## left_join: added one column (mean_ID_er)
## > rows only in x 0
## > rows only in df_mean_er_strat %>% gr.. ( 12)
## > matched rows 17,573
## > ========
## > rows total 17,573

4.2.1 Neg Affect

fit <- df_rwsd_outcomes %>% 
  lmer(panas_neg_z ~ rwsd + (1|ID), data = .)
tab_model(fit)
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.95 0.61 – 1.30 <0.001
rwsd -1.24 -1.69 – -0.79 <0.001
Random Effects
σ2 0.45
τ00 ID 0.51
ICC 0.53
N ID 253
Observations 12099
Marginal R2 / Conditional R2 0.060 / 0.561
# controlling for mean ER
df_rwsd_outcomes %>% 
  lmer(panas_neg_z ~ rwsd + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.05 -0.44 – 0.55 0.828
rwsd -0.63 -1.13 – -0.13 0.013
mean ID er 0.18 0.11 – 0.25 <0.001
Random Effects
σ2 0.45
τ00 ID 0.47
ICC 0.51
N ID 253
Observations 12099
Marginal R2 / Conditional R2 0.106 / 0.563

relative within SD predicts less neg affect

4.2.2 Pos Affect

fit <- df_rwsd_outcomes %>% 
  lmer(panas_pos_z ~ rwsd + (1|ID), data = .)
tab_model(fit)
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.73 -1.08 – -0.39 <0.001
rwsd 0.95 0.49 – 1.40 <0.001
Random Effects
σ2 0.47
τ00 ID 0.51
ICC 0.52
N ID 253
Observations 12096
Marginal R2 / Conditional R2 0.035 / 0.538
# controlling for mean ER
df_rwsd_outcomes %>% 
  lmer(panas_pos_z ~ rwsd + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.80 -1.32 – -0.29 0.002
rwsd 0.99 0.47 – 1.51 <0.001
mean ID er 0.01 -0.06 – 0.09 0.717
Random Effects
σ2 0.47
τ00 ID 0.51
ICC 0.52
N ID 253
Observations 12096
Marginal R2 / Conditional R2 0.035 / 0.538

relative within SD predicts more pos affect

4.3 Relative Between SD

df_rbsd_outcomes <- df_rbsd_st %>% 
  left_join(df_indiff_2) %>% 
  left_join(
    df_mean_er_strat %>%
      group_by(ID) %>%
      summarize(mean_ID_er = mean(mean_er, na.rm = TRUE)) %>%
      select(ID, mean_ID_er) %>% 
      ungroup() 
    ) %>% 
  mutate(across(rbsd, ~scale(., scale = F), .names = "{.col}_pc")) %>% 
  mutate(across(rbsd_pc, ~scale(., scale = T), .names = "{.col}_z"))
## Joining with `by = join_by(ID, timeStampSent)`
## left_join: added 12 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff_2 (11,761)
## > matched rows 6,648
## > ========
## > rows total 6,648
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
## select: no changes
## ungroup: no grouping variables remain
## Joining with `by = join_by(ID)`
## left_join: added one column (mean_ID_er)
## > rows only in x 0
## > rows only in df_mean_er_strat %>% gr.. ( 11)
## > matched rows 6,648
## > =======
## > rows total 6,648
## mutate (grouped): new variable 'rbsd_pc' (double) with 3,128 unique values and
## 0% NA
## mutate (grouped): new variable 'rbsd_pc_z' (double) with 3,107 unique values
## and 1% NA

4.3.1 Neg Affect

fit <- df_rbsd_outcomes %>% 
  lmer(panas_neg_z ~ rbsd_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.33 0.23 – 0.44 <0.001
rbsd pc z -0.04 -0.06 – -0.03 <0.001
Random Effects
σ2 0.54
τ00 ID 0.60
ICC 0.53
N ID 231
Observations 6612
Marginal R2 / Conditional R2 0.002 / 0.528
# controlling for mean ER
df_rbsd_outcomes %>% 
  lmer(panas_neg_z ~ rbsd_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.18 -0.05 – 0.42 0.130
rbsd pc z -0.04 -0.06 – -0.03 <0.001
mean ID er 0.05 -0.02 – 0.13 0.167
Random Effects
σ2 0.54
τ00 ID 0.60
ICC 0.53
N ID 231
Observations 6612
Marginal R2 / Conditional R2 0.005 / 0.529

relative between SD predicts less neg affect (but effect size is really small)

4.3.2 Pos Affect

fit <- df_rbsd_outcomes %>% 
  lmer(panas_pos_z ~ rbsd_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.18 -0.27 – -0.09 <0.001
rbsd pc z 0.04 0.02 – 0.05 <0.001
Random Effects
σ2 0.49
τ00 ID 0.48
ICC 0.49
N ID 231
Observations 6610
Marginal R2 / Conditional R2 0.001 / 0.495
# controlling for mean ER
df_rbsd_outcomes %>% 
  lmer(panas_pos_z ~ rbsd_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.28 -0.49 – -0.06 0.011
rbsd pc z 0.04 0.02 – 0.05 <0.001
mean ID er 0.04 -0.03 – 0.10 0.322
Random Effects
σ2 0.49
τ00 ID 0.48
ICC 0.49
N ID 231
Observations 6610
Marginal R2 / Conditional R2 0.003 / 0.495

relative between SD predicts more pos affect (but effect size is really small)

4.4 Successive Difference

df_rwrmssd_outcomes <- df_rwrmssd %>% 
  left_join(df_indiff_2) %>% 
  left_join(
    df_mean_er_strat %>%
      group_by(ID) %>%
      summarize(mean_ID_er = mean(mean_er, na.rm = TRUE)) %>%
      select(ID, mean_ID_er) %>% 
      ungroup() 
    )
## Joining with `by = join_by(ID)`
## left_join: added 13 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff_2 ( 836)
## > matched rows 17,573 (includes duplicates)
## > ========
## > rows total 17,573
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
## select: no changes
## ungroup: no grouping variables remain
## Joining with `by = join_by(ID)`
## left_join: added one column (mean_ID_er)
## > rows only in x 0
## > rows only in df_mean_er_strat %>% gr.. ( 12)
## > matched rows 17,573
## > ========
## > rows total 17,573

4.4.1 Neg Affect

fit <- df_rwrmssd_outcomes %>% 
  lmer(panas_neg_z ~ rwrmssd + (1|ID), data = .)
tab_model(fit)
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.90 0.64 – 1.17 <0.001
rwrmssd -1.42 -1.83 – -1.02 <0.001
Random Effects
σ2 0.45
τ00 ID 0.48
ICC 0.52
N ID 253
Observations 12099
Marginal R2 / Conditional R2 0.092 / 0.562
# controlling for mean ER
df_rwrmssd_outcomes %>% 
  lmer(panas_neg_z ~ rwrmssd + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.21 -0.26 – 0.68 0.378
rwrmssd -0.86 -1.37 – -0.35 0.001
mean ID er 0.14 0.06 – 0.22 0.001
Random Effects
σ2 0.45
τ00 ID 0.46
ICC 0.51
N ID 253
Observations 12099
Marginal R2 / Conditional R2 0.116 / 0.564

successive differences predicts less neg affect

4.4.2 Pos Affect

fit <- df_rwrmssd_outcomes %>% 
  lmer(panas_pos_z ~ rwrmssd + (1|ID), data = .)
tab_model(fit)
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.58 -0.85 – -0.31 <0.001
rwrmssd 0.89 0.47 – 1.31 <0.001
Random Effects
σ2 0.47
τ00 ID 0.51
ICC 0.52
N ID 253
Observations 12096
Marginal R2 / Conditional R2 0.036 / 0.538
# controlling for mean ER
df_rwrmssd_outcomes %>% 
  lmer(panas_pos_z ~ rwrmssd + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.81 -1.31 – -0.32 0.001
rwrmssd 1.08 0.54 – 1.62 <0.001
mean ID er 0.05 -0.04 – 0.13 0.268
Random Effects
σ2 0.47
τ00 ID 0.51
ICC 0.52
N ID 253
Observations 12096
Marginal R2 / Conditional R2 0.038 / 0.539

successive differences predicts more pos affect (large effect size)

4.5 Bray-Curtis

df_bc_outcomes <- df_bc_st %>% 
  left_join(df_indiff_2) %>% 
  left_join(
    df_mean_er_strat %>%
      group_by(ID) %>%
      summarize(mean_ID_er = mean(mean_er, na.rm = TRUE)) %>%
      select(ID, mean_ID_er) %>% 
      ungroup() 
    ) %>% 
  mutate(across(bc, ~scale(., scale = F), .names = "{.col}_pc")) %>% 
  mutate(across(bc_pc, ~scale(., scale = T), .names = "{.col}_z"))
## Joining with `by = join_by(ID, timeStampSent)`
## left_join: added 12 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff_2 (8,410)
## > matched rows 9,999
## > =======
## > rows total 9,999
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
## select: no changes
## ungroup: no grouping variables remain
## Joining with `by = join_by(ID)`
## left_join: added one column (mean_ID_er)
## > rows only in x 0
## > rows only in df_mean_er_strat %>% gr.. ( 8)
## > matched rows 9,999
## > =======
## > rows total 9,999
## mutate (grouped): new variable 'bc_pc' (double) with 3,901 unique values and 0%
## NA
## mutate (grouped): new variable 'bc_pc_z' (double) with 3,901 unique values and
## 4% NA

4.5.1 Neg Affect

fit <- df_bc_outcomes %>% 
  lmer(panas_neg_z ~ bc_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.04 -0.06 – 0.14 0.421
bc pc z 0.10 0.09 – 0.11 <0.001
Random Effects
σ2 0.44
τ00 ID 0.59
ICC 0.58
N ID 244
Observations 9578
Marginal R2 / Conditional R2 0.009 / 0.580
# controlling for mean ER
df_bc_outcomes %>% 
  lmer(panas_neg_z ~ bc_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_neg_z
Predictors Estimates CI p
(Intercept) -0.51 -0.70 – -0.32 <0.001
bc pc z 0.10 0.09 – 0.11 <0.001
mean ID er 0.22 0.15 – 0.28 <0.001
Random Effects
σ2 0.44
τ00 ID 0.50
ICC 0.54
N ID 244
Observations 9578
Marginal R2 / Conditional R2 0.101 / 0.583

BC predicts MORE neg affect (effect size does not change when controlling for mean ER; small effect size)

4.5.2 Pos Affect

fit <- df_bc_outcomes %>% 
  lmer(panas_pos_z ~ bc_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.04 -0.14 – 0.05 0.381
bc pc z -0.05 -0.06 – -0.04 <0.001
Random Effects
σ2 0.46
τ00 ID 0.56
ICC 0.55
N ID 244
Observations 9575
Marginal R2 / Conditional R2 0.002 / 0.547
# controlling for mean ER
df_bc_outcomes %>% 
  lmer(panas_pos_z ~ bc_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_pos_z
Predictors Estimates CI p
(Intercept) 0.09 -0.11 – 0.29 0.382
bc pc z -0.05 -0.06 – -0.04 <0.001
mean ID er -0.05 -0.12 – 0.02 0.141
Random Effects
σ2 0.46
τ00 ID 0.55
ICC 0.54
N ID 244
Observations 9575
Marginal R2 / Conditional R2 0.008 / 0.548

BC predicts LESS pos affect (effect size does not change when controlling for mean ER; small effect size)

4.6 Wentropy (Emotion Regulation Diversity)

df_wentropy_outcomes <- df_wentropy_st %>% 
  left_join(df_indiff_2) %>% 
  left_join(
    df_mean_er_strat %>%
      group_by(ID) %>%
      summarize(mean_ID_er = mean(mean_er, na.rm = TRUE)) %>%
      select(ID, mean_ID_er) %>% 
      ungroup() 
    ) %>% 
  mutate(across(wentropy, ~scale(., scale = F), .names = "{.col}_pc")) %>% 
  mutate(across(wentropy_pc, ~scale(., scale = T), .names = "{.col}_z"))
## Joining with `by = join_by(ID, timeStampSent)`
## left_join: added 12 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff_2 ( 5,819)
## > matched rows 12,590
## > ========
## > rows total 12,590
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
## select: no changes
## ungroup: no grouping variables remain
## Joining with `by = join_by(ID)`
## left_join: added one column (mean_ID_er)
## > rows only in x 0
## > rows only in df_mean_er_strat %>% gr.. ( 0)
## > matched rows 12,590
## > ========
## > rows total 12,590
## mutate: new variable 'wentropy_pc' (double) with 436 unique values and 0% NA
## mutate: new variable 'wentropy_pc_z' (double) with 436 unique values and 0% NA

4.6.1 Neg Affect

fit <- df_wentropy_outcomes %>% 
  lmer(panas_neg_z ~ wentropy_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.02 -0.07 – 0.11 0.724
wentropy pc z -0.05 -0.07 – -0.03 <0.001
Random Effects
σ2 0.43
τ00 ID 0.56
ICC 0.56
N ID 265
Observations 12590
Marginal R2 / Conditional R2 0.003 / 0.566
# controlling for mean ER
df_wentropy_outcomes %>% 
  lmer(panas_neg_z ~ wentropy_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_neg_z
Predictors Estimates CI p
(Intercept) -0.52 -0.69 – -0.35 <0.001
wentropy pc z -0.05 -0.06 – -0.03 <0.001
mean ID er 0.22 0.16 – 0.28 <0.001
Random Effects
σ2 0.43
τ00 ID 0.47
ICC 0.52
N ID 265
Observations 12590
Marginal R2 / Conditional R2 0.107 / 0.574

Wentropy predicts less neg affect (but small effect size)

4.6.2 Pos Affect

fit <- df_wentropy_outcomes %>% 
  lmer(panas_pos_z ~ wentropy_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.00 -0.09 – 0.09 0.929
wentropy pc z -0.04 -0.06 – -0.02 <0.001
Random Effects
σ2 0.46
τ00 ID 0.54
ICC 0.54
N ID 265
Observations 12587
Marginal R2 / Conditional R2 0.002 / 0.542
# controlling for mean ER
df_wentropy_outcomes %>% 
  lmer(panas_pos_z ~ wentropy_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_pos_z
Predictors Estimates CI p
(Intercept) 0.23 0.04 – 0.41 0.016
wentropy pc z -0.04 -0.06 – -0.02 <0.001
mean ID er -0.09 -0.16 – -0.03 0.005
Random Effects
σ2 0.46
τ00 ID 0.53
ICC 0.53
N ID 265
Observations 12587
Marginal R2 / Conditional R2 0.013 / 0.541

Wentropy predicts LESS pos affecr (but small effect size)

4.7 Entropy

df_entropy_outcomes <- df_entropy_st %>% 
  left_join(df_indiff_2) %>% 
  left_join(
    df_mean_er_strat %>%
      group_by(ID) %>%
      summarize(mean_ID_er = mean(mean_er, na.rm = TRUE)) %>%
      select(ID, mean_ID_er) %>% 
      ungroup() 
    ) %>% 
  mutate(across(entropy, ~scale(., scale = F), .names = "{.col}_pc")) %>% 
  mutate(across(entropy_pc, ~scale(., scale = T), .names = "{.col}_z"))
## Joining with `by = join_by(ID, timeStampSent)`
## left_join: added 12 columns (Sex, Birth_year, Birth_month, Ethnicity, SCARED,
## …)
## > rows only in x 0
## > rows only in df_indiff_2 ( 5,819)
## > matched rows 12,590
## > ========
## > rows total 12,590
## group_by: one grouping variable (ID)
## summarize: now 265 rows and 2 columns, ungrouped
## select: no changes
## ungroup: no grouping variables remain
## Joining with `by = join_by(ID)`
## left_join: added one column (mean_ID_er)
## > rows only in x 0
## > rows only in df_mean_er_strat %>% gr.. ( 0)
## > matched rows 12,590
## > ========
## > rows total 12,590
## mutate: new variable 'entropy_pc' (double) with 416 unique values and 0% NA
## mutate: new variable 'entropy_pc_z' (double) with 416 unique values and 0% NA

4.7.1 Neg Affect

fit <- df_entropy_outcomes %>% 
  lmer(panas_neg_z ~ entropy_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_neg_z
Predictors Estimates CI p
(Intercept) 0.01 -0.08 – 0.10 0.748
entropy pc z -0.09 -0.11 – -0.07 <0.001
Random Effects
σ2 0.43
τ00 ID 0.54
ICC 0.56
N ID 265
Observations 12590
Marginal R2 / Conditional R2 0.008 / 0.562
# controlling for mean ER
df_entropy_outcomes %>% 
  lmer(panas_neg_z ~ entropy_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_neg_z
Predictors Estimates CI p
(Intercept) -0.51 -0.68 – -0.34 <0.001
entropy pc z -0.09 -0.10 – -0.07 <0.001
mean ID er 0.21 0.15 – 0.27 <0.001
Random Effects
σ2 0.43
τ00 ID 0.46
ICC 0.52
N ID 265
Observations 12590
Marginal R2 / Conditional R2 0.114 / 0.571

Entropy predicts less neg affect (but small effect size)

4.7.2 Pos Affect

fit <- df_entropy_outcomes %>% 
  lmer(panas_pos_z ~ entropy_pc_z + (1|ID), data = .)
tab_model(fit)
  panas_pos_z
Predictors Estimates CI p
(Intercept) -0.00 -0.09 – 0.08 0.918
entropy pc z 0.05 0.03 – 0.06 <0.001
Random Effects
σ2 0.46
τ00 ID 0.54
ICC 0.54
N ID 265
Observations 12587
Marginal R2 / Conditional R2 0.002 / 0.541
# controlling for mean ER
df_entropy_outcomes %>% 
  lmer(panas_pos_z ~ entropy_pc_z + mean_ID_er + (1|ID), data = .) %>% 
  tab_model()
  panas_pos_z
Predictors Estimates CI p
(Intercept) 0.17 -0.02 – 0.35 0.077
entropy pc z 0.05 0.03 – 0.06 <0.001
mean ID er -0.07 -0.13 – -0.00 0.037
Random Effects
σ2 0.46
τ00 ID 0.53
ICC 0.54
N ID 265
Observations 12587
Marginal R2 / Conditional R2 0.014 / 0.543

Entropy predicts more pos affect (but small effect size)