• Load Packages & Data
    • Subject-level Data
    • Time Series Data
    • Resource Discoveries Data
    • Resource Discoveries Data: Voluntary Payoff condition
    • Session Information
  • Demographics and data filtering
    • Count excluded participants on each step of data cleaning
    • Sex
    • Age
    • Approvals
    • Duplicates (time steps when the participant was not moving)
  • Collected Points
    • Model 1
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Model 2
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Model Comparison
    • Model 3
      • Model fitting
      • Model predictions
      • Condition comparisons
      • Figure
    • Model 4: Collected Points by Epoch
      • Model specification
      • Model fitting
      • Condition comparisons
      • Model figure
  • Tracking Time
    • Model 1
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Model 2
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Model Comparison
  • Tracking Efficiency
    • Model 1
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Model 2
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Model Comparison
  • Tracking Time vs. Tracking Efficiency Combined Plot
  • Average Median Distance to Resource
    • Data Preparation
      • Step 1: Compute per-participant average distance from time series
      • Step 2: Map participants to groups
      • Step 3: Compute group-level median distance time series for interacting groups
      • Step 4: Construct nominal groups from solo participants
      • Step 5: Combine all data
    • Descriptive Statistics
    • Descriptive Plots
      • Average Median Distance by Condition
      • Distribution Comparison
    • Statistical Model
      • Data for modelling
      • Model specification
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Combined comparison table
      • Model figure
  • Average Median Distance to Resource by Epoch
    • Data Preparation (Epoch)
      • Step 1: Compute per-participant average distance
      • Step 2: Map participants to groups
      • Step 3: Compute group-level median distance time series for interacting groups
      • Step 4: Construct nominal groups from solo participants
      • Step 5: Combine all data
    • Statistical Model (Epoch)
      • Data for modelling
      • Model specification
      • Model fitting
      • Condition comparisons
      • Condition comparison table (Epoch)
      • Model figure
  • Static Connecitvity
    • In-degree model
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Out-degree model
      • Prior predictive checks
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
    • Correlation
  • Adaptive Connectivity
    • Social Information Quality Model
      • Model diagnostics
      • Model predictions
      • Condition comparisons
      • Figure
  • Resouece Discoveries
    • Fast
      • Probability of staying on resource
      • Probability of staying on resource VP
      • Probability of reaching resource
      • Probability of reaching resource VP
      • Out degree
      • Out degree (Discoverer)
      • Out degree VP
      • In degree
      • In degree (Others)
      • In degree VP
      • Combine plot
      • Combine plot (in/out degree full)
      • Combine plot VP
    • Slow
      • Probability of staying on resource
      • Probability of staying on resource VP
      • Probability of reaching on resource
      • Probability of reaching resource VP
      • Out degree
      • Out degree (Discoverer)
      • Out degree VP
      • In degree
      • In degree (Others)
      • In degree VP
      • Combine plot
      • Combine plot (in/out degree full)
      • Combine plot VP
  • Degree and Rank
    • Rotation per condition
    • Model In-Degree
      • Model fitting
      • Model diagnostics
      • Figure
    • Model Out-Degree
      • Model fitting
      • Model diagnostics
      • Figure
    • Combined figures
  • Roation Magnitude (Tracking)
    • Prior predictive checks
    • Model fitting (~9.5h)
    • Model diagnostics
    • Model predictions
    • Figures
    • Random Effects
      • Model Tracking Efficiency
      • Model Score
      • Random Effects Correlations
      • Random Effects Visualization
    • Model 2: Temporal Dynamics
    • Temporal Figures
      • Temporal Condition Comparisons
    • Model 3: Social Cohesion & Group Spread Effects (OutDegree > 1)
      • Model 3: New Feature Posterior Contrasts
      • Summary Table
      • Figures
  • Roation Magnitude (Search)
    • Prior predictive checks
    • Model fitting (~9.5h)
    • Model diagnostics
    • Model predictions
    • Random Effects
      • Model Tracking Time
      • Random Effects Correlations
      • Random Effects Visualization
    • Model 2: Temporal Dynamics
    • Temporal Figures
      • Temporal Condition Comparisons
    • Model 3: Social Cohesion & OutDegree Effects (OutDegree > 1)
      • Model 3: New Feature Posterior Contrasts
      • Summary Table
      • Figures
    • Model 4: Peer Distance Moderation of Social Features (OutDegree == 1)
      • Model 4: Social Feature Posterior Contrasts
      • Summary Table
      • Figures
  • Rotation Direction (Tracking)
    • Detector Change
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Figure
    • Social Information
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Figure
  • FOV Dynamics
    • FOV Percentages Table
    • FOV Percentages Plot
  • Voluntary Payoff Sharing
    • Sharing actions count
    • Count Model
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition draws
    • Count vs Score model
    • Total Sharing
    • Total Sharing Model
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Condition draws
    • Total Sharing vs Score Model
    • Sharing Probability: Resource, State, Time, Distance
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Figure
      • Statistical Comparisons
    • Sharing Probability: Resource, Distance
      • Model fitting
      • Model diagnostics
      • Model predictions
      • Figure

Collective Resource Tracking Statistical Analysis

Roation Magnitude (Search)

m.RotationMagnitude.search.data <- time_series_data %>%
  filter(State == "searching") %>%
  mutate(SocQual = as.numeric(case_when(
    OutDegree == 0 ~ 0,
    SocInfoQualityBin == 1 ~ 1,
    SocInfoQualityBin == 0 ~ -1,
    .default = -1
  ))) %>%
  mutate(withSocInfo = factor(ifelse(OutDegree > 0, 1, 0), levels = c(0, 1))) %>%
  mutate(Rotation = Rotation / 150) %>%
  mutate(SocMovDir = ifelse(withSocInfo == 0, 0, (abs(SocialMovementDirection / max(abs(SocialMovementDirection), na.rm = T)) - 0.5) * 2)) %>%
  mutate(RotationAbs = abs(Rotation) + 0.01) %>%
  mutate(DistFromRes = (OwnDistFromResource - 200) / 200) %>%
  mutate(SocPosInFOV = ifelse(withSocInfo == 0, 0, (abs(VisPlayersDirection / max(abs(VisPlayersDirection), na.rm = T)) - 0.5) * 2)) %>%
  select(Participant, Time, SignalingType, ResourceSpeed, RotationAbs, withSocInfo, DistFromRes, SocPosInFOV, SocMovDir, SocQual)

head(m.RotationMagnitude.search.data)

m.RotationMagnitude.search.1.formula <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed +
    SignalingType:ResourceSpeed:withSocInfo:SocPosInFOV +
    SignalingType:ResourceSpeed:withSocInfo:SocMovDir +
    SignalingType:ResourceSpeed:withSocInfo:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:withSocInfo:SocQual:SocMovDir +
    (1 + withSocInfo:SocPosInFOV + withSocInfo:SocMovDir + withSocInfo:SocQual:SocPosInFOV + withSocInfo:SocQual:SocMovDir | Participant),
  family = exponential()
)

m.RotationMagnitude.search.1.formula_comparison <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed +
    SignalingType:ResourceSpeed:withSocInfo:SocPosInFOV +
    SignalingType:ResourceSpeed:withSocInfo:SocMovDir +
    SignalingType:ResourceSpeed:withSocInfo:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:withSocInfo:SocQual:SocMovDir,
  family = exponential()
)

Prior predictive checks

m.RotationMagnitude.search.1.fit_prior <- brm(
  formula = m.RotationMagnitude.search.1.formula,
  data = m.RotationMagnitude.search.data,
  prior = m.RotationMagnitude.search.1.priors,
  chains = 4,
  cores = 4,
  seed = 42,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_search_1_prior.rds"),
  sample_prior = "only",
  backend = "cmdstanr",
  threads = threading(100),
  control = list(adapt_delta = 0.95),
  save_pars = save_pars(all = TRUE)
)

m.RotationMagnitude.search.1.y <- m.RotationMagnitude.search.data$RotationAbs
pp_check(m.RotationMagnitude.search.1.fit_prior, prefix = "ppd", ndraw = 20)

Model fitting (~9.5h)

m.RotationMagnitude.search.1.fit <- brm(
  formula = m.RotationMagnitude.search.1.formula,
  data = m.RotationMagnitude.search.data,
  prior = m.RotationMagnitude.search.1.priors,
  chains = 4,
  cores = 4,
  seed = 4242,
  warmup = 2000,
  iter = 5000,
  file = paste0(fits_path, "rotation_magnitude_search_1.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = FALSE)
)
summary(m.RotationMagnitude.search.1.fit, ask = F)
##  Family: exponential 
##   Links: mu = log 
## Formula: RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:withSocInfo:SocPosInFOV + SignalingType:ResourceSpeed:withSocInfo:SocMovDir + SignalingType:ResourceSpeed:withSocInfo:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:withSocInfo:SocQual:SocMovDir + (1 + withSocInfo:SocPosInFOV + withSocInfo:SocMovDir + withSocInfo:SocQual:SocPosInFOV + withSocInfo:SocQual:SocMovDir | Participant) 
##    Data: m.RotationMagnitude.search.data (Number of observations: 242142) 
##   Draws: 4 chains, each with iter = 5000; warmup = 2000; thin = 1;
##          total post-warmup draws = 12000
## 
## Multilevel Hyperparameters:
## ~Participant (Number of levels: 603) 
##                                                                        Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)                                                              0.52      0.02     0.48     0.55 1.00     1703     3262
## sd(withSocInfo0:SocPosInFOV)                                               0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocPosInFOV)                                               0.35      0.02     0.32     0.38 1.00     6460     8907
## sd(withSocInfo0:SocMovDir)                                                 0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocMovDir)                                                 0.27      0.02     0.24     0.30 1.00     6644     9374
## sd(withSocInfo0:SocPosInFOV:SocQual)                                       0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocPosInFOV:SocQual)                                       0.25      0.01     0.22     0.28 1.00     6980     9514
## sd(withSocInfo0:SocMovDir:SocQual)                                         0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocMovDir:SocQual)                                         0.22      0.01     0.19     0.25 1.00     6407     9176
## cor(Intercept,withSocInfo0:SocPosInFOV)                                   -0.00      0.31    -0.60     0.60 1.00    26161     8417
## cor(Intercept,withSocInfo1:SocPosInFOV)                                    0.24      0.06     0.11     0.36 1.00     7366     8552
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocPosInFOV)                     0.07      0.31    -0.56     0.63 1.04       99      254
## cor(Intercept,withSocInfo0:SocMovDir)                                      0.00      0.32    -0.62     0.61 1.00    25882     7543
## cor(withSocInfo0:SocPosInFOV,withSocInfo0:SocMovDir)                       0.00      0.32    -0.59     0.61 1.00    19120     8019
## cor(withSocInfo1:SocPosInFOV,withSocInfo0:SocMovDir)                       0.00      0.31    -0.59     0.59 1.00    26413     7749
## cor(Intercept,withSocInfo1:SocMovDir)                                      0.47      0.06     0.35     0.58 1.00     8464     9471
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocMovDir)                       0.01      0.32    -0.61     0.60 1.02      225      648
## cor(withSocInfo1:SocPosInFOV,withSocInfo1:SocMovDir)                       0.02      0.07    -0.12     0.15 1.00     7700     9412
## cor(withSocInfo0:SocMovDir,withSocInfo1:SocMovDir)                         0.02      0.31    -0.58     0.61 1.01      298      931
## cor(Intercept,withSocInfo0:SocPosInFOV:SocQual)                            0.00      0.32    -0.60     0.61 1.00    30071     8288
## cor(withSocInfo0:SocPosInFOV,withSocInfo0:SocPosInFOV:SocQual)             0.00      0.32    -0.60     0.61 1.00    19344     8105
## cor(withSocInfo1:SocPosInFOV,withSocInfo0:SocPosInFOV:SocQual)             0.00      0.31    -0.59     0.59 1.00    25652     8338
## cor(withSocInfo0:SocMovDir,withSocInfo0:SocPosInFOV:SocQual)               0.00      0.31    -0.60     0.60 1.00    10360     8410
## cor(withSocInfo1:SocMovDir,withSocInfo0:SocPosInFOV:SocQual)               0.00      0.32    -0.61     0.61 1.00    28500     8223
## cor(Intercept,withSocInfo1:SocPosInFOV:SocQual)                            0.32      0.07     0.18     0.45 1.00     8887     8915
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocPosInFOV:SocQual)             0.02      0.31    -0.57     0.61 1.02      191      665
## cor(withSocInfo1:SocPosInFOV,withSocInfo1:SocPosInFOV:SocQual)             0.43      0.06     0.31     0.54 1.00     8328     9569
## cor(withSocInfo0:SocMovDir,withSocInfo1:SocPosInFOV:SocQual)              -0.02      0.31    -0.61     0.58 1.01      272      809
## cor(withSocInfo1:SocMovDir,withSocInfo1:SocPosInFOV:SocQual)              -0.00      0.08    -0.16     0.15 1.00     7321     9319
## cor(withSocInfo0:SocPosInFOV:SocQual,withSocInfo1:SocPosInFOV:SocQual)     0.02      0.32    -0.59     0.64 1.02      274     1177
## cor(Intercept,withSocInfo0:SocMovDir:SocQual)                              0.00      0.32    -0.60     0.61 1.00    30070     8290
## cor(withSocInfo0:SocPosInFOV,withSocInfo0:SocMovDir:SocQual)               0.00      0.31    -0.59     0.59 1.00    16718     8124
## cor(withSocInfo1:SocPosInFOV,withSocInfo0:SocMovDir:SocQual)              -0.00      0.33    -0.63     0.62 1.00    28060     8142
## cor(withSocInfo0:SocMovDir,withSocInfo0:SocMovDir:SocQual)                 0.00      0.31    -0.59     0.60 1.00    10615     8884
## cor(withSocInfo1:SocMovDir,withSocInfo0:SocMovDir:SocQual)                 0.00      0.32    -0.60     0.61 1.00    30970     8269
## cor(withSocInfo0:SocPosInFOV:SocQual,withSocInfo0:SocMovDir:SocQual)      -0.00      0.32    -0.61     0.61 1.00     7393     8536
## cor(withSocInfo1:SocPosInFOV:SocQual,withSocInfo0:SocMovDir:SocQual)       0.00      0.32    -0.60     0.60 1.00    26241     8764
## cor(Intercept,withSocInfo1:SocMovDir:SocQual)                              0.31      0.07     0.16     0.44 1.00     9769     8671
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocMovDir:SocQual)              -0.02      0.32    -0.61     0.59 1.01      243      511
## cor(withSocInfo1:SocPosInFOV,withSocInfo1:SocMovDir:SocQual)              -0.20      0.07    -0.34    -0.06 1.00     9765    10516
## cor(withSocInfo0:SocMovDir,withSocInfo1:SocMovDir:SocQual)                 0.02      0.31    -0.58     0.62 1.02      262      728
## cor(withSocInfo1:SocMovDir,withSocInfo1:SocMovDir:SocQual)                 0.67      0.05     0.57     0.76 1.00     5970     8825
## cor(withSocInfo0:SocPosInFOV:SocQual,withSocInfo1:SocMovDir:SocQual)       0.01      0.31    -0.59     0.60 1.00     1025     3408
## cor(withSocInfo1:SocPosInFOV:SocQual,withSocInfo1:SocMovDir:SocQual)      -0.08      0.08    -0.23     0.08 1.00     7781     9631
## cor(withSocInfo0:SocMovDir:SocQual,withSocInfo1:SocMovDir:SocQual)        -0.00      0.31    -0.61     0.59 1.00     1471     3648
## 
## Regression Coefficients:
##                                                                    Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept                                                             -1.65      0.06    -1.76    -1.55 1.01      683     1321
## SignalingTypeNP                                                        0.05      0.08    -0.12     0.21 1.01      465      969
## SignalingTypeVP                                                        0.14      0.08    -0.00     0.29 1.00      663     1657
## SignalingTypeFP                                                        0.58      0.08     0.42     0.74 1.00      758     1628
## ResourceSpeedslow                                                      0.15      0.08    -0.01     0.31 1.01      901     2080
## SignalingTypeNP:ResourceSpeedslow                                      0.22      0.12    -0.01     0.46 1.01      644     1548
## SignalingTypeVP:ResourceSpeedslow                                      0.28      0.12     0.06     0.51 1.00     1086     2346
## SignalingTypeFP:ResourceSpeedslow                                     -0.12      0.12    -0.36     0.12 1.00     1097     2240
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocPosInFOV              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocPosInFOV              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocPosInFOV              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocPosInFOV             0.24      0.04     0.15     0.33 1.00     4042     7007
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocPosInFOV             0.36      0.04     0.28     0.44 1.00     4519     7283
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocPosInFOV             0.52      0.04     0.43     0.61 1.00     6135     8339
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocPosInFOV              0.00      0.50    -0.97     0.98 1.00    28141     8698
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocPosInFOV             0.51      0.06     0.40     0.62 1.00     8110     9459
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocPosInFOV             0.57      0.06     0.45     0.68 1.00     9425     9036
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocPosInFOV             0.50      0.07     0.37     0.64 1.00     9395     9390
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocMovDir                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocMovDir                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocMovDir                0.01      0.50    -0.99     0.99 1.00    26943     8111
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocMovDir               0.11      0.04     0.04     0.18 1.00     1929     5102
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocMovDir               0.17      0.03     0.11     0.23 1.00     3185     6882
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocMovDir               0.44      0.04     0.37     0.51 1.00     3630     6117
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocMovDir                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocMovDir               0.26      0.05     0.17     0.35 1.00     6869     8845
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocMovDir               0.34      0.05     0.25     0.44 1.00     8222     8685
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocMovDir               0.35      0.06     0.23     0.46 1.00     8596     9945
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual     0.07      0.03     0.00     0.13 1.00     4214     7941
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual     0.23      0.03     0.17     0.29 1.00     5144     7947
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual     0.48      0.03     0.41     0.54 1.00     6255     8246
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual     0.26      0.05     0.17     0.35 1.00     9796     9217
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual     0.39      0.05     0.30     0.49 1.00    11144     9049
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual     0.41      0.06     0.30     0.53 1.00    11604     9740
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual      -0.01      0.03    -0.07     0.05 1.00     4046     7211
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual       0.02      0.03    -0.03     0.07 1.00     5742     7718
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual       0.24      0.03     0.18     0.30 1.00     6389     8751
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual       0.10      0.04     0.02     0.18 1.00    11206     8450
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual       0.09      0.04     0.00     0.18 1.00    10176    10158
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual       0.15      0.06     0.04     0.26 1.00    11595     8941
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

Model diagnostics

m.RotationMagnitude.search.1.yrep <- posterior_predict(m.RotationMagnitude.search.1.fit, draws = 10)
ppc_dens_overlay(m.RotationMagnitude.search.1.y, m.RotationMagnitude.search.1.yrep[1:100, ])

ppc_dens_overlay_grouped(m.RotationMagnitude.search.1.y,
  m.RotationMagnitude.search.1.yrep[1:100, ],
  group = m.RotationMagnitude.search.data$ResourceSpeed
)

ppc_dens_overlay_grouped(m.RotationMagnitude.search.1.y,
  m.RotationMagnitude.search.1.yrep[1:100, ],
  group = m.RotationMagnitude.search.data$SignalingType
)

group <- m.RotationMagnitude.search.data$SignalingType
mask <- m.RotationMagnitude.search.data$ResourceSpeed == "fast"

ppc_dens_overlay_grouped(m.RotationMagnitude.search.1.y[mask],
  m.RotationMagnitude.search.1.yrep[1:50, mask],
  group = group[mask]
)

group <- m.RotationMagnitude.search.data$SignalingType
mask <- m.RotationMagnitude.search.data$ResourceSpeed == "slow"

ppc_dens_overlay_grouped(m.RotationMagnitude.search.1.y[mask],
  m.RotationMagnitude.search.1.yrep[1:50, mask],
  group = group[mask]
)

Model predictions

m.RotationMagnitude.search.1.df_fit <- as.data.frame(m.RotationMagnitude.search.1.fit)
m.RotationMagnitude.search.1.tidy_draws <- m.RotationMagnitude.search.1.fit %>%
  tidy_draws() %>%
  gather_variables() %>%
  filter(grepl("b_Signaling", .variable) | grepl("b_Resource", .variable) | grepl("b_Intercept", .variable))
m.RotationMagnitude.search.1.tidy_draws2 <- m.RotationMagnitude.search.1.tidy_draws %>%
  # separate_wider_delim(.variable, delim = ":")
  filter(str_detect(.variable, "b_SignalingType")) %>%
  mutate(signaling = factor(case_when(
    str_detect(.variable, "b_SignalingTypeNP") ~ "NP",
    str_detect(.variable, "b_SignalingTypeVP") ~ "VP",
    str_detect(.variable, "b_SignalingTypeFP") ~ "FP"
  ), levels = c("NP", "VP", "FP"))) %>%
  mutate(resource = factor(case_when(
    str_detect(.variable, "ResourceSpeedfast") ~ "fast",
    str_detect(.variable, "ResourceSpeedslow") ~ "slow",
  ), levels = c("fast", "slow"))) %>%
  mutate(socInfo = case_when(
    str_detect(.variable, "withSocInfo0") ~ 0,
    str_detect(.variable, "withSocInfo1") ~ 1,
  )) %>%
  filter(((socInfo == 1) | is.na(socInfo)), ((signaling == "A") & is.na(socInfo)) | (signaling != "A")) %>%
  mutate(weight = factor(case_when(
    str_detect(.variable, ":SocPosInFOV:SocQual") ~ "Position x Quality",
    str_detect(.variable, ":SocMovDir:SocQual") ~ "Movement x Quality",
    str_detect(.variable, ":SocPosInFOV") ~ "Position",
    str_detect(.variable, ":SocMovDir") ~ "Movement",
  ), levels = c(
    "Position",
    "Movement",
    "Position x Quality",
    "Movement x Quality"
  )))

head(m.RotationMagnitude.search.1.tidy_draws2)
rotation_magnitude_searching_fig <- m.RotationMagnitude.search.1.tidy_draws2 %>%
  filter(!is.na(resource), !is.na(weight)) %>%
  ggplot(aes(y = signaling, x = .value, color = signaling, fill = signaling)) +
  stat_halfeye(alpha = 0.5) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  scale_color_manual(
    breaks = c("A", "NP", "VP", "FP"),
    aesthetics = c("colour", "fill"),
    values = c("#000000", "#DF536B", "#61D04F", "#2297E6"),
    guide = guide_legend(title = "Signaling"),
  ) +
  theme_nice(legend.pos = "bottom") +
  xlim(-0.2, NA) +
  facet_grid(cols = vars(weight), rows = vars(resource), axes = "all", axis.labels = "all_x", switch = "y") +
  labs(x = "Posterior Parameter Estimate", y = "")

rotation_magnitude_searching_fig

rotation_magnitude_searching_fig <- m.RotationMagnitude.search.1.tidy_draws2 %>%
  filter(!is.na(resource), !is.na(weight)) %>%
  ggplot(aes(
    y = signaling, x = .value, color = signaling, fill = signaling, shape = resource,
    group = interaction(signaling, resource)
  )) +
  stat_pointinterval(alpha = 1, .width = 0.9, position = position_dodge(width = .55), point_size = 3) +
  geom_vline(xintercept = 0, linetype = "dashed") +
  scale_y_discrete(limits = rev) +
  scale_color_manual(
    breaks = c("A", "NP", "VP", "FP"),
    aesthetics = c("colour", "fill"),
    values = c("#000000", "#DF536B", "#61D04F", "#2297E6"),
    guide = guide_legend(title = "Signaling"),
  ) +
  scale_x_continuous(
    limits  = c(-0.1, 0.6),
    breaks  = c(-0.1, 0.2, 0.4, 0.6),
    expand  = expansion(mult = c(0.02, 0.04)) # tiny margin left/right
  ) +
  theme_clean() +
  theme(legend.position = "none") +
  panel_border() +
  facet_wrap(vars(weight), ncol = 1) +
  labs(x = "Posterior parameter estimate", y = "")

rotation_magnitude_searching_fig

Random Effects

Model Tracking Time

m.RotationMagnitude.search.1.re.soc_pos.formula <- brmsformula(
  TrackingTime_0_1 ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:SocInfoPos_r_eff,
  phi ~ ResourceSpeed + SignalingType,
  family = Beta()
)

m.RotationMagnitude.search.1.re.soc_pos_qual.formula <- brmsformula(
  TrackingTime_0_1 ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:SocInfoQualityPos_r_eff,
  phi ~ ResourceSpeed + SignalingType,
  family = Beta()
)

m.RotationMagnitude.search.1.re.soc_mov.formula <- brmsformula(
  TrackingTime_0_1 ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:SocInfoMov_r_eff,
  phi ~ ResourceSpeed + SignalingType,
  family = Beta()
)

m.RotationMagnitude.search.1.re.soc_mov_qual.formula <- brmsformula(
  TrackingTime_0_1 ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:SocInfoQualityMov_r_eff,
  phi ~ ResourceSpeed + SignalingType,
  family = Beta()
)


m.RotationMagnitude.search.1.re.priors <-
  prior(normal(0, 0.5), class = b) +
  prior(normal(0, 1), class = Intercept) +
  prior(gamma(4, 0.1), class = Intercept, dpar = phi, lb = 0)
m.RotationMagnitude.search.1.re.soc_pos.fit <- brm(
  formula = m.RotationMagnitude.search.1.re.soc_pos.formula,
  data = m.RotationMagnitude.search.1.re.data %>% filter(SignalingType != "A"),
  prior = m.RotationMagnitude.search.1.re.priors,
  chains = 4,
  cores = 4,
  seed = 42,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_searching_1_random_effects_soc_pos.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = TRUE)
)

m.RotationMagnitude.search.1.re.soc_pos_qual.fit <- brm(
  formula = m.RotationMagnitude.search.1.re.soc_pos_qual.formula,
  data = m.RotationMagnitude.search.1.re.data %>% filter(SignalingType != "A"),
  prior = m.RotationMagnitude.search.1.re.priors,
  chains = 4,
  cores = 4,
  seed = 42,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_searching_1_random_effects_soc_pos_qual.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = TRUE)
)

m.RotationMagnitude.search.1.re.soc_mov.fit <- brm(
  formula = m.RotationMagnitude.search.1.re.soc_mov.formula,
  data = m.RotationMagnitude.search.1.re.data %>% filter(SignalingType != "A"),
  prior = m.RotationMagnitude.search.1.re.priors,
  chains = 4,
  cores = 4,
  seed = 42,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_searching_1_random_effects_soc_mov.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = TRUE)
)


m.RotationMagnitude.search.1.re.soc_mov_qual.fit <- brm(
  formula = m.RotationMagnitude.search.1.re.soc_mov_qual.formula,
  data = m.RotationMagnitude.search.1.re.data %>% filter(SignalingType != "A"),
  prior = m.RotationMagnitude.search.1.re.priors,
  chains = 4,
  cores = 4,
  seed = 42,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_searching_1_random_effects_soc_mov_qual.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = TRUE)
)
m.RotationMagnitude.search.1.re.tidy_draws <- bind_rows(
  m.RotationMagnitude.search.1.re.soc_pos.fit %>%
    tidy_draws() %>%
    gather_variables() %>%
    filter(grepl("SignalingType", .variable) | grepl("ResourceSpeed", .variable) | grepl("b_Intercept", .variable)),
  m.RotationMagnitude.search.1.re.soc_pos_qual.fit %>%
    tidy_draws() %>%
    gather_variables() %>%
    filter(grepl("SignalingType", .variable) | grepl("ResourceSpeed", .variable) | grepl("b_Intercept", .variable)),
  m.RotationMagnitude.search.1.re.soc_mov.fit %>%
    tidy_draws() %>%
    gather_variables() %>%
    filter(grepl("SignalingType", .variable) | grepl("ResourceSpeed", .variable) | grepl("b_Intercept", .variable)),
  m.RotationMagnitude.search.1.re.soc_mov_qual.fit %>%
    tidy_draws() %>%
    gather_variables() %>%
    filter(grepl("SignalingType", .variable) | grepl("ResourceSpeed", .variable) | grepl("b_Intercept", .variable))
)
m.RotationMagnitude.search.1.re.tidy_draws2 <- m.RotationMagnitude.search.1.re.tidy_draws %>%
  filter(str_detect(.variable, "SignalingType") & str_detect(.variable, "ResourceSpeed")) %>%
  mutate(signaling = factor(case_when(
    str_detect(.variable, "SignalingTypeNP") ~ "NP",
    str_detect(.variable, "SignalingTypeVP") ~ "VP",
    str_detect(.variable, "SignalingTypeFP") ~ "FP",
    str_detect(.variable, "SignalingTypeA") ~ "A",
  ), levels = c("A", "NP", "VP", "FP"))) %>%
  mutate(resource = factor(case_when(
    str_detect(.variable, "ResourceSpeedfast") ~ "fast",
    str_detect(.variable, "ResourceSpeedslow") ~ "slow",
  ), levels = c("fast", "slow"))) %>%
  mutate(weight = factor(case_when(
    str_detect(.variable, ":SocInfoQualityPos_r_eff") ~ "Position x Quality",
    str_detect(.variable, ":SocInfoQualityMov_r_eff") ~ "Movement Direction x Quality",
    str_detect(.variable, ":SocInfoPos_r_eff") ~ "Position of others",
    str_detect(.variable, ":SocInfoMov_r_eff") ~ "Movement direction of others",
    .default = "NONONONO"
  ), levels = c(
    "Intercept Rot Mag",
    "Position of others",
    "Position x Quality",
    "Movement direction of others",
    "Movement Direction x Quality",
    "NONONONO"
  ))) %>%
  filter(weight != "NONONONO", !((signaling == "A") & !(weight %in% c("Detector Sensitivity", "Intercept Rot Mag"))))

head(m.RotationMagnitude.search.1.re.tidy_draws2, 50)
rotation_magnitude_searching_random_effects_tracking_time_fig <- m.RotationMagnitude.search.1.re.tidy_draws2 %>%
  filter(!is.na(resource), !is.na(weight)) %>%
  mutate(weight = factor(weight, levels = c(
    "Position of others",
    "Position x Quality",
    "Movement direction of others",
    "Movement Direction x Quality"
  ))) %>%
  ggplot(aes(y = weight, x = .value, color = signaling, fill = signaling)) +
  stat_pointinterval(alpha = 0.5, .width = c(.90), point_interval = "mean_hdi", position = "dodge") +
  geom_vline(xintercept = 0, linetype = "dashed") +
  scale_color_manual(
    breaks = c("A", "NP", "VP", "FP"),
    aesthetics = c("colour", "fill"),
    values = c("#000000", "#DF536B", "#61D04F", "#2297E6"),
    guide = guide_legend(title = "Signaling"),
  ) +
  theme_nice(legend.pos = "bottom") +
  # Add horizontal lines at each weight level
  geom_hline(aes(yintercept = as.numeric(weight) + 0.5), color = "grey80", linetype = "solid") +
  scale_y_discrete(limits = rev) +
  facet_grid(cols = vars(resource)) +
  theme_clean() +
  panel_border() +
  theme(
    panel.grid.major = element_blank(), # Remove major grid lines
    panel.grid.minor = element_blank(), # Remove minor grid lines
    legend.position = "bottom"
  ) +
  labs(x = "Posterior parameter estimate", y = "", title = "") # , title = "Tracking Time ~ random effects"


rotation_magnitude_searching_random_effects_tracking_time_fig

Random Effects Correlations

mcmc_areas(
  m.RotationMagnitude.search.1.df_fit %>% dplyr::select(
    starts_with("cor_"),
    -contains("withSocInfo0"),
  ) %>%
    rename(
      `cor(Intercept, Position)` = `cor_Participant__Intercept__withSocInfo1:SocPosInFOV`,
      `cor(Intercept, Movement)` = `cor_Participant__Intercept__withSocInfo1:SocMovDir`,
      `cor(Intercept, Position x Quality)` = `cor_Participant__Intercept__withSocInfo1:SocPosInFOV:SocQual`,
      `cor(Intercept, Movement x Quality)` = `cor_Participant__Intercept__withSocInfo1:SocMovDir:SocQual`,
      `cor(Position, Movement)` = `cor_Participant__withSocInfo1:SocPosInFOV__withSocInfo1:SocMovDir`,
      `cor(Position, Position x Quality)` = `cor_Participant__withSocInfo1:SocPosInFOV__withSocInfo1:SocPosInFOV:SocQual`,
      `cor(Position, Movement x Quality)` = `cor_Participant__withSocInfo1:SocPosInFOV__withSocInfo1:SocMovDir:SocQual`,
      `cor(Movement, Position x Quality)` = `cor_Participant__withSocInfo1:SocMovDir__withSocInfo1:SocPosInFOV:SocQual`,
      `cor(Movement, Movement x Quality)` = `cor_Participant__withSocInfo1:SocMovDir__withSocInfo1:SocMovDir:SocQual`,
      `cor(Position x Quality, Movement x Quality)` = `cor_Participant__withSocInfo1:SocPosInFOV:SocQual__withSocInfo1:SocMovDir:SocQual`
    ) %>%
    dplyr::select( # Ensure the order is correct
      `cor(Intercept, Position)`,
      `cor(Intercept, Movement)`,
      `cor(Intercept, Position x Quality)`,
      `cor(Intercept, Movement x Quality)`,
      `cor(Position, Movement)`,
      `cor(Position, Position x Quality)`,
      `cor(Position, Movement x Quality)`,
      `cor(Movement, Position x Quality)`,
      `cor(Movement, Movement x Quality)`,
      `cor(Position x Quality, Movement x Quality)`
    ),
  prob = 0.95, # 95% intervals
  prob_outer = 0.99, # 99%
  point_est = "mean"
) + ggplot2::labs(
  title = "Posterior parameter distributions",
  subtitle = "with medians and 95% intervals"
)

Random Effects Visualization

# 1. Extract raw random effects for social features (SEARCH)
m.RotationMagnitude.search.1.r_effs_long <- m.RotationMagnitude.search.1.fit %>%
  spread_draws(r_Participant[Participant, term]) %>%
  # Filter for relevant social features from the search model
  filter(term %in% c(
    "withSocInfo1:SocPosInFOV", 
    "withSocInfo1:SocMovDir", 
    "withSocInfo1:SocPosInFOV:SocQual", 
    "withSocInfo1:SocMovDir:SocQual"
  )) %>%
  # Map to human-readable names
  mutate(term_label = case_when(
    term == "withSocInfo1:SocPosInFOV" ~ "Position",
    term == "withSocInfo1:SocMovDir" ~ "Movement",
    term == "withSocInfo1:SocPosInFOV:SocQual" ~ "Position x Quality",
    term == "withSocInfo1:SocMovDir:SocQual" ~ "Movement x Quality"
  )) %>%
  mutate(term_label = factor(term_label, levels = c(
    "Position", "Movement", "Position x Quality", "Movement x Quality"
  )))

# 2. Summarize draws and merge with condition metadata & tracking efficiency (Tracking Time)
m.RotationMagnitude.search.1.r_effs_data_plot <- m.RotationMagnitude.search.1.r_effs_long %>%
  group_by(Participant, term_label) %>%
  summarise(
    mean_val = mean(r_Participant),
    lower = quantile(r_Participant, 0.05),
    upper = quantile(r_Participant, 0.95),
    .groups = "drop"
  ) %>%
  left_join(subj_data %>% select(Participant, SignalingType, ResourceSpeed, PCR, TrackingTime), by = "Participant") %>%
  # Coloring logic: black if interval does not overlap with 0, gray otherwise
  mutate(hpdi_overlaps_0 = factor(ifelse(lower > 0 | upper < 0, "No", "Yes"),
    levels = c("Yes", "No") # Wait, checking user script consistency
  )) %>%
  # Wait, the user script said: ifelse(lower > 0 | upper < 0, "Yes", "No")
  # but their naming implies "Yes" = overlaps. 
  # Actually their script: ifelse(lower > 0 | upper < 0, "Yes", "No")
  # and scale: values = c("No" = "gray75", "Yes" = "black")
  # So I will follow their provided snippet exactly.
  mutate(hpdi_overlaps_0 = factor(ifelse(lower > 0 | upper < 0, "Yes", "No"),
    levels = c("No", "Yes")
  ))

# 3. Sort participants by tracking time (TrackingTime) within each condition
m.RotationMagnitude.search.1.r_effs_order <- m.RotationMagnitude.search.1.r_effs_data_plot %>%
  filter(term_label == "Position") %>%
  arrange(SignalingType, ResourceSpeed, TrackingTime) %>%
  mutate(sort_rank = row_number()) %>%
  select(Participant, sort_rank)

m.RotationMagnitude.search.1.r_effs_data_plot <- m.RotationMagnitude.search.1.r_effs_data_plot %>%
  left_join(m.RotationMagnitude.search.1.r_effs_order, by = "Participant") %>%
  mutate(Participant = reorder(Participant, sort_rank))
# 4. Generate the grouped Caterpillar plot for SEARCH
m.RotationMagnitude.search.1.social_strategy_caterpillar <- m.RotationMagnitude.search.1.r_effs_data_plot %>%
  filter(SignalingType != "A") %>% 
  ggplot(aes(y = Participant, x = mean_val, color = hpdi_overlaps_0)) +  # TrackingTime
  geom_pointinterval(aes(xmin = lower, xmax = upper), size = 0.01, fatten_point = 1.5) +
  geom_vline(xintercept = 0, linetype = "dashed", color = "red", alpha = 0.5) +
  # Grouping by Signaling and Speed; space="free_y" ensures unique rows per facet
  facet_grid(SignalingType + ResourceSpeed ~ term_label, scales = "free_y", space = "free_y") +
  scale_color_manual(
    values = c("No" = "gray75", "Yes" = "black"),
    guide = guide_legend(title = "90% HPDI overlaps with 0")
  ) +
  theme_clean() +
  panel_border() +
  theme(
    panel.grid.major = element_blank(),
    panel.grid.minor = element_blank(),
    axis.text.y = element_blank(),
    axis.ticks.y = element_blank(),
    legend.position = "bottom"
  ) +
  labs(
    x = "Raw Random Effect Estimate (Participant-level Offset)",
    y = "Participant (sorted by Tracking Time, high=top)"
  )

m.RotationMagnitude.search.1.social_strategy_caterpillar

Model 2: Temporal Dynamics

m.RotationMagnitude.search.temporal.data <- m.RotationMagnitude.search.data %>%
  mutate(Epoch = factor(ifelse(Time <= 440, "First Half", "Second Half"), levels = c("First Half", "Second Half")))
m.RotationMagnitude.search.temporal.formula <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed * Epoch +
    SignalingType:ResourceSpeed:withSocInfo:SocPosInFOV +
    SignalingType:ResourceSpeed:withSocInfo:SocMovDir +
    SignalingType:ResourceSpeed:withSocInfo:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:withSocInfo:SocQual:SocMovDir +

    SignalingType:ResourceSpeed:Epoch:withSocInfo:SocPosInFOV +
    SignalingType:ResourceSpeed:Epoch:withSocInfo:SocMovDir +
    SignalingType:ResourceSpeed:Epoch:withSocInfo:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:Epoch:withSocInfo:SocQual:SocMovDir +

    (1 + withSocInfo:SocPosInFOV + withSocInfo:SocMovDir + withSocInfo:SocQual:SocPosInFOV + withSocInfo:SocQual:SocMovDir | Participant),
  family = exponential()
)
m.RotationMagnitude.search.temporal.priors <-
  prior(normal(0, 1), class = "Intercept") +
  prior(normal(0, 0.1), class = "sd") +
  prior(normal(0, 0.5), class = b) +

  prior(constant(0), class = "sd", coef = "withSocInfo0:SocMovDir", group = "Participant") +
  prior(constant(0), class = "sd", coef = "withSocInfo0:SocPosInFOV", group = "Participant") +
  prior(constant(0), class = "sd", coef = "withSocInfo0:SocMovDir:SocQual", group = "Participant") +
  prior(constant(0), class = "sd", coef = "withSocInfo0:SocPosInFOV:SocQual", group = "Participant") +

  # base no soc info priors
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocMovDir") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocMovDir") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocPosInFOV") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocPosInFOV") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual") +

  # A priors
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocMovDir") +

  # epoch no-soc-info priors
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +

  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual") +

  # epoch A priors
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV") +
  prior(constant(0), class = b, coef = "SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir")
m.RotationMagnitude.search.temporal.fit <- brm(
  formula = m.RotationMagnitude.search.temporal.formula,
  data = m.RotationMagnitude.search.temporal.data,
  prior = m.RotationMagnitude.search.temporal.priors,
  chains = 4,
  cores = 4,
  seed = 4242,
  warmup = 1000,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_search_temporal.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = FALSE)
)
summary(m.RotationMagnitude.search.temporal.fit, ask = F)
##  Family: exponential 
##   Links: mu = log 
## Formula: RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed * Epoch + SignalingType:ResourceSpeed:withSocInfo:SocPosInFOV + SignalingType:ResourceSpeed:withSocInfo:SocMovDir + SignalingType:ResourceSpeed:withSocInfo:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:withSocInfo:SocQual:SocMovDir + SignalingType:ResourceSpeed:Epoch:withSocInfo:SocPosInFOV + SignalingType:ResourceSpeed:Epoch:withSocInfo:SocMovDir + SignalingType:ResourceSpeed:Epoch:withSocInfo:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:Epoch:withSocInfo:SocQual:SocMovDir + (1 + withSocInfo:SocPosInFOV + withSocInfo:SocMovDir + withSocInfo:SocQual:SocPosInFOV + withSocInfo:SocQual:SocMovDir | Participant) 
##    Data: m.RotationMagnitude.search.temporal.data (Number of observations: 242142) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~Participant (Number of levels: 603) 
##                                                                        Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)                                                              0.52      0.02     0.49     0.55 1.00      540     1031
## sd(withSocInfo0:SocPosInFOV)                                               0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocPosInFOV)                                               0.35      0.02     0.31     0.38 1.00     2012     2990
## sd(withSocInfo0:SocMovDir)                                                 0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocMovDir)                                                 0.27      0.02     0.24     0.30 1.00     1952     2669
## sd(withSocInfo0:SocPosInFOV:SocQual)                                       0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocPosInFOV:SocQual)                                       0.25      0.01     0.22     0.28 1.00     2121     2803
## sd(withSocInfo0:SocMovDir:SocQual)                                         0.00      0.00     0.00     0.00   NA       NA       NA
## sd(withSocInfo1:SocMovDir:SocQual)                                         0.23      0.01     0.20     0.26 1.00     2432     3067
## cor(Intercept,withSocInfo0:SocPosInFOV)                                    0.00      0.31    -0.60     0.61 1.00    10259     2552
## cor(Intercept,withSocInfo1:SocPosInFOV)                                    0.23      0.06     0.10     0.35 1.00     2288     2534
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocPosInFOV)                     0.02      0.29    -0.59     0.54 1.14       23       55
## cor(Intercept,withSocInfo0:SocMovDir)                                     -0.00      0.31    -0.60     0.61 1.00     9796     2782
## cor(withSocInfo0:SocPosInFOV,withSocInfo0:SocMovDir)                       0.00      0.31    -0.60     0.61 1.00     6274     2339
## cor(withSocInfo1:SocPosInFOV,withSocInfo0:SocMovDir)                       0.01      0.31    -0.60     0.61 1.00    11115     2971
## cor(Intercept,withSocInfo1:SocMovDir)                                      0.47      0.06     0.35     0.58 1.00     2459     3102
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocMovDir)                       0.02      0.30    -0.53     0.59 1.02       98      340
## cor(withSocInfo1:SocPosInFOV,withSocInfo1:SocMovDir)                       0.02      0.07    -0.12     0.16 1.00     2609     3170
## cor(withSocInfo0:SocMovDir,withSocInfo1:SocMovDir)                        -0.03      0.32    -0.59     0.59 1.05       69      310
## cor(Intercept,withSocInfo0:SocPosInFOV:SocQual)                            0.00      0.32    -0.60     0.62 1.00    12908     2404
## cor(withSocInfo0:SocPosInFOV,withSocInfo0:SocPosInFOV:SocQual)            -0.00      0.31    -0.60     0.61 1.00     6814     2447
## cor(withSocInfo1:SocPosInFOV,withSocInfo0:SocPosInFOV:SocQual)             0.00      0.31    -0.57     0.60 1.00     9742     2765
## cor(withSocInfo0:SocMovDir,withSocInfo0:SocPosInFOV:SocQual)               0.01      0.31    -0.59     0.58 1.00     4009     3027
## cor(withSocInfo1:SocMovDir,withSocInfo0:SocPosInFOV:SocQual)              -0.00      0.32    -0.61     0.60 1.00     9847     2514
## cor(Intercept,withSocInfo1:SocPosInFOV:SocQual)                            0.31      0.07     0.17     0.44 1.00     3577     3156
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocPosInFOV:SocQual)             0.04      0.30    -0.56     0.58 1.05       59      246
## cor(withSocInfo1:SocPosInFOV,withSocInfo1:SocPosInFOV:SocQual)             0.42      0.06     0.30     0.53 1.00     2548     3321
## cor(withSocInfo0:SocMovDir,withSocInfo1:SocPosInFOV:SocQual)               0.04      0.31    -0.53     0.62 1.05       73      415
## cor(withSocInfo1:SocMovDir,withSocInfo1:SocPosInFOV:SocQual)              -0.01      0.08    -0.16     0.14 1.00     2582     3318
## cor(withSocInfo0:SocPosInFOV:SocQual,withSocInfo1:SocPosInFOV:SocQual)    -0.05      0.30    -0.63     0.53 1.03      128      347
## cor(Intercept,withSocInfo0:SocMovDir:SocQual)                              0.00      0.32    -0.61     0.61 1.00    13803     2441
## cor(withSocInfo0:SocPosInFOV,withSocInfo0:SocMovDir:SocQual)              -0.00      0.32    -0.60     0.59 1.00     6203     3019
## cor(withSocInfo1:SocPosInFOV,withSocInfo0:SocMovDir:SocQual)              -0.00      0.32    -0.61     0.61 1.00    10423     2399
## cor(withSocInfo0:SocMovDir,withSocInfo0:SocMovDir:SocQual)                 0.00      0.32    -0.60     0.61 1.00     3457     2560
## cor(withSocInfo1:SocMovDir,withSocInfo0:SocMovDir:SocQual)                 0.00      0.32    -0.60     0.62 1.00    13493     2499
## cor(withSocInfo0:SocPosInFOV:SocQual,withSocInfo0:SocMovDir:SocQual)      -0.01      0.32    -0.60     0.61 1.00     2004     2796
## cor(withSocInfo1:SocPosInFOV:SocQual,withSocInfo0:SocMovDir:SocQual)      -0.01      0.32    -0.61     0.60 1.00     9694     2892
## cor(Intercept,withSocInfo1:SocMovDir:SocQual)                              0.34      0.07     0.19     0.47 1.00     2708     2926
## cor(withSocInfo0:SocPosInFOV,withSocInfo1:SocMovDir:SocQual)               0.02      0.29    -0.57     0.56 1.03       84      258
## cor(withSocInfo1:SocPosInFOV,withSocInfo1:SocMovDir:SocQual)              -0.18      0.07    -0.31    -0.04 1.00     3202     3251
## cor(withSocInfo0:SocMovDir,withSocInfo1:SocMovDir:SocQual)                -0.06      0.32    -0.62     0.59 1.03      104      140
## cor(withSocInfo1:SocMovDir,withSocInfo1:SocMovDir:SocQual)                 0.70      0.05     0.60     0.78 1.00     2173     3009
## cor(withSocInfo0:SocPosInFOV:SocQual,withSocInfo1:SocMovDir:SocQual)      -0.01      0.32    -0.64     0.59 1.01      217      653
## cor(withSocInfo1:SocPosInFOV:SocQual,withSocInfo1:SocMovDir:SocQual)      -0.07      0.08    -0.22     0.08 1.00     2737     3184
## cor(withSocInfo0:SocMovDir:SocQual,withSocInfo1:SocMovDir:SocQual)         0.00      0.32    -0.60     0.61 1.02      261     1499
## 
## Regression Coefficients:
##                                                                                    Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept                                                                             -1.57      0.06    -1.68    -1.45 1.04      169      446
## SignalingTypeNP                                                                       -0.05      0.08    -0.21     0.12 1.03      189      365
## SignalingTypeVP                                                                        0.04      0.08    -0.12     0.19 1.02      188      441
## SignalingTypeFP                                                                        0.47      0.08     0.30     0.62 1.03      195      375
## ResourceSpeedslow                                                                      0.12      0.08    -0.05     0.29 1.02      243      466
## EpochSecondHalf                                                                       -0.18      0.01    -0.20    -0.16 1.00     3307     3310
## SignalingTypeNP:ResourceSpeedslow                                                      0.20      0.12    -0.03     0.42 1.01      253      520
## SignalingTypeVP:ResourceSpeedslow                                                      0.35      0.12     0.13     0.59 1.01      282      609
## SignalingTypeFP:ResourceSpeedslow                                                     -0.10      0.12    -0.33     0.14 1.02      348      764
## SignalingTypeNP:EpochSecondHalf                                                        0.20      0.02     0.17     0.23 1.00     3849     3491
## SignalingTypeVP:EpochSecondHalf                                                        0.23      0.02     0.20     0.26 1.00     3985     3360
## SignalingTypeFP:EpochSecondHalf                                                        0.27      0.02     0.23     0.30 1.00     4053     3342
## ResourceSpeedslow:EpochSecondHalf                                                      0.08      0.02     0.04     0.12 1.00     3485     2871
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf                                      0.03      0.03    -0.04     0.09 1.00     4261     3081
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf                                     -0.17      0.04    -0.25    -0.10 1.00     4523     3469
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf                                     -0.10      0.04    -0.17    -0.02 1.00     4787     3184
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocPosInFOV                              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocPosInFOV                             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocPosInFOV                             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocPosInFOV                             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocPosInFOV                              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocPosInFOV                             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocPosInFOV                             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocPosInFOV                             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocPosInFOV                              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocPosInFOV                             0.16      0.05     0.07     0.26 1.00     1613     2524
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocPosInFOV                             0.33      0.04     0.24     0.41 1.00     1580     2366
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocPosInFOV                             0.45      0.05     0.36     0.55 1.00     2087     3057
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocPosInFOV                             -0.00      0.51    -1.04     1.02 1.00    12353     2617
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocPosInFOV                             0.54      0.06     0.42     0.67 1.00     3054     3222
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocPosInFOV                             0.59      0.07     0.45     0.72 1.00     3635     2783
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocPosInFOV                             0.45      0.08     0.30     0.60 1.00     3345     2869
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocMovDir                                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocMovDir                               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocMovDir                               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocMovDir                               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocMovDir                                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocMovDir                               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocMovDir                               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocMovDir                               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocMovDir                                0.00      0.50    -0.99     0.98 1.00    12054     3018
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocMovDir                               0.13      0.04     0.06     0.21 1.00     1337     2364
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocMovDir                               0.12      0.04     0.05     0.19 1.00      893     2078
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocMovDir                               0.40      0.04     0.31     0.48 1.00     1381     2313
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocMovDir                                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocMovDir                               0.15      0.05     0.04     0.25 1.00     3009     3221
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocMovDir                               0.40      0.06     0.28     0.52 1.00     3332     3324
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocMovDir                               0.44      0.07     0.31     0.58 1.00     2802     2979
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual                      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual                     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual                     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocPosInFOV:SocQual                     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual                      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual                     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual                     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocPosInFOV:SocQual                     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual                      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual                     0.04      0.04    -0.03     0.12 1.00     1985     2753
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual                     0.17      0.03     0.11     0.24 1.00     1915     2429
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocPosInFOV:SocQual                     0.41      0.04     0.33     0.48 1.00     2518     3030
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual                      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual                     0.30      0.05     0.19     0.40 1.00     3924     2891
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual                     0.33      0.06     0.21     0.45 1.00     3858     2779
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocPosInFOV:SocQual                     0.46      0.07     0.32     0.59 1.00     4353     3245
## SignalingTypeA:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual                        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual                       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual                       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:withSocInfo0:SocMovDir:SocQual                       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual                        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual                       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual                       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:withSocInfo0:SocMovDir:SocQual                       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual                        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual                      -0.01      0.04    -0.07     0.06 1.00     2407     3316
## SignalingTypeVP:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual                       0.02      0.03    -0.04     0.08 1.00     1815     2661
## SignalingTypeFP:ResourceSpeedfast:withSocInfo1:SocMovDir:SocQual                       0.23      0.04     0.15     0.30 1.00     1927     2259
## SignalingTypeA:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual                        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual                       0.03      0.05    -0.07     0.13 1.00     3807     3188
## SignalingTypeVP:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual                      -0.06      0.06    -0.18     0.05 1.00     3977     3038
## SignalingTypeFP:ResourceSpeedslow:withSocInfo1:SocMovDir:SocQual                       0.08      0.06    -0.04     0.21 1.00     3634     3206
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV             0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV              0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV             0.14      0.03     0.08     0.21 1.00     5457     3478
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV             0.07      0.03     0.02     0.13 1.00     6694     3230
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV             0.15      0.04     0.08     0.22 1.00     5834     3411
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV              0.01      0.50    -0.95     1.01 1.00    10191     3081
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV            -0.08      0.05    -0.19     0.01 1.00     7961     3294
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV            -0.03      0.07    -0.17     0.12 1.00     5871     3243
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV             0.11      0.07    -0.03     0.26 1.00     6280     3361
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir               0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir                0.00      0.49    -0.96     0.99 1.00    12456     2783
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir              -0.06      0.03    -0.12     0.00 1.00     5804     3569
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir               0.10      0.03     0.05     0.16 1.00     6078     2966
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir               0.09      0.04     0.02     0.16 1.00     6016     2965
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir                0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir               0.24      0.05     0.14     0.34 1.00     6985     3214
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir              -0.09      0.07    -0.22     0.04 1.00     6597     3491
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir              -0.18      0.07    -0.32    -0.04 1.00     6132     3092
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocPosInFOV:SocQual     0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual     0.04      0.03    -0.03     0.10 1.00     5311     3425
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual     0.10      0.03     0.04     0.15 1.00     6766     3185
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual     0.16      0.04     0.09     0.23 1.00     6279     3266
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual      0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual    -0.07      0.05    -0.17     0.03 1.00     7393     3183
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual     0.13      0.07    -0.02     0.27 1.00     5280     3064
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocPosInFOV:SocQual    -0.08      0.07    -0.22     0.06 1.00     6597     3491
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeVP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeFP:ResourceSpeedslow:EpochSecondHalf:withSocInfo0:SocMovDir:SocQual       0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeA:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual      -0.00      0.03    -0.07     0.06 1.00     6119     3105
## SignalingTypeVP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual      -0.00      0.03    -0.06     0.06 1.00     6336     3527
## SignalingTypeFP:ResourceSpeedfast:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual       0.04      0.04    -0.03     0.11 1.00     5707     2738
## SignalingTypeA:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual        0.00      0.00     0.00     0.00   NA       NA       NA
## SignalingTypeNP:ResourceSpeedslow:EpochSecondHalf:withSocInfo1:SocMovDir:SocQual       0.17      0.05     0.06     0.27 1.00     7786     3250
##  [ reached 'max' / getOption("max.print") -- omitted 2 rows ]
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

Temporal Figures

m.RotationMagnitude.search.temporal.tidy_draws <- m.RotationMagnitude.search.temporal.fit %>%
  tidy_draws() %>%
  gather_variables() %>%
  filter(grepl("b_SignalingType", .variable) & grepl("Epoch", .variable)) %>%
  filter(!grepl("Intercept", .variable) & grepl(":Epoch", .variable))

m.RotationMagnitude.search.temporal.tidy_draws2 <- m.RotationMagnitude.search.temporal.tidy_draws %>%
  mutate(signaling = factor(case_when(
    str_detect(.variable, "SignalingTypeNP") ~ "NP",
    str_detect(.variable, "SignalingTypeVP") ~ "VP",
    str_detect(.variable, "SignalingTypeFP") ~ "FP",
    str_detect(.variable, "SignalingTypeA") ~ "A",
  ), levels = c("A", "NP", "VP", "FP"))) %>%
  mutate(resource = factor(case_when(
    str_detect(.variable, "ResourceSpeedfast") ~ "fast",
    str_detect(.variable, "ResourceSpeedslow") ~ "slow",
  ), levels = c("fast", "slow"))) %>%
  mutate(epoch_term = factor(case_when(
    str_detect(.variable, "EpochFirstHalf") ~ "First Half",
    str_detect(.variable, "EpochSecondHalf") ~ "Second Half",
  ), levels = c("First Half", "Second Half"))) %>%
  mutate(socInfo = case_when(
    str_detect(.variable, "withSocInfo0") ~ 0,
    str_detect(.variable, "withSocInfo1") ~ 1,
  )) %>%
  filter(((socInfo == 1) | is.na(socInfo)), ((signaling == "A") & is.na(socInfo)) | (signaling != "A")) %>%
  mutate(weight = factor(case_when(
    str_detect(.variable, ":SocPosInFOV:SocQual") ~ "Position x Quality",
    str_detect(.variable, ":SocMovDir:SocQual") ~ "Movement x Quality",
    str_detect(.variable, ":SocPosInFOV") ~ "Position",
    str_detect(.variable, ":SocMovDir") ~ "Movement"
  ), levels = c("Position", "Movement", "Position x Quality", "Movement x Quality"))) %>%
  filter(!is.na(weight))
fig_temporal_combined

Temporal Condition Comparisons

m.RotationMagnitude.search.temporal.base_draws <- m.RotationMagnitude.search.temporal.fit %>%
  tidy_draws() %>%
  gather_variables() %>%
  filter(grepl("EpochSecondHalf", .variable) & !grepl("DistFromRes|SocPos|SocMov", .variable)) %>%
  filter(!grepl("Intercept|sigma|sd", .variable)) %>%
  mutate(
    signaling = factor(case_when(
      grepl("A", .variable) ~ "A",
      grepl("NP", .variable) ~ "NP",
      grepl("VP", .variable) ~ "VP",
      grepl("FP", .variable) ~ "FP",
      TRUE ~ "."
    ), levels = c(".", "A", "NP", "VP", "FP")),
    resource = factor(case_when(
      grepl("slow", .variable) ~ "slow",
      grepl("fast", .variable) ~ "fast",
      TRUE ~ "."
    ), levels = c(".", "fast", "slow")),
    weight = "."
  )

m.RotationMagnitude.search.temporal.base_summary <- m.RotationMagnitude.search.temporal.base_draws %>%
  group_by(resource, signaling, weight) %>%
  ggdist::mean_hdci(.value, .width = 0.9) %>%
  mutate(.value = round(.value, 2), .lower = round(.lower, 2), .upper = round(.upper, 2)) %>%
  ungroup()

m.RotationMagnitude.search.temporal.weights_summary <- m.RotationMagnitude.search.temporal.tidy_draws2 %>%
  group_by(resource, signaling, weight) %>%
  ggdist::mean_hdci(.value, .width = 0.9) %>%
  mutate(.value = round(.value, 2), .lower = round(.lower, 2), .upper = round(.upper, 2)) %>%
  ungroup()
# Arranging Table for Readability
m.RotationMagnitude.search.temporal.combined_table <- bind_rows(
  m.RotationMagnitude.search.temporal.base_summary,
  m.RotationMagnitude.search.temporal.weights_summary
) %>%
  filter(!(.value == 0 & .lower == 0 & .upper == 0)) %>%
  # Create sort factors
  mutate(
    weight_order = factor(weight, levels = c(
      ".", "Position", "Movement", "Position x Quality", "Movement x Quality"
    )),
    resource = factor(resource, levels = c(".", "slow", "fast")),
    signaling = factor(signaling, levels = c(".", "A", "NP", "VP", "FP"))
  ) %>%
  arrange(resource, signaling, weight_order) %>%
  mutate(contrast = "Second - First Half") %>%
  mutate(
    sig = (.lower * .upper) > 0,
    Estimate = sprintf("%.2f", .value),
    Estimate = ifelse(sig, paste0("\\textbf{", Estimate, "}"), Estimate),
    hpdi = sprintf("[%.2f, %.2f]", .lower, .upper),
    hpdi = ifelse(sig, paste0("\\textbf{", hpdi, "}"), hpdi)
  )
# Prepare kable
kbl_data <- m.RotationMagnitude.search.temporal.combined_table %>%
  select(resource, signaling, weight, contrast, Estimate, hpdi)

colnames(kbl_data) <- c(
  "Resource Speed", "Payoff Condition", "Decision Weight", "Contrast", "Mean", "90\\% HPDI"
)

kbl <- kable(
  kbl_data,
  format = "latex",
  booktabs = TRUE,
  align = c("l", "l", "l", "l", "r", "r"),
  caption = "Posterior Estimates for Temporal Dynamics (Second Half vs. First Half) - Search",
  escape = FALSE
) %>%
  kable_styling(latex_options = c("hold_position", "scale_down")) %>%
  row_spec(0, bold = TRUE)

# Group rows by Resource Speed
unique_speeds <- unique(kbl_data$`Resource Speed`)
curr_row <- 1
for (speed in unique_speeds) {
  n_rows <- sum(kbl_data$`Resource Speed` == speed)
  kbl <- group_rows(kbl, paste("Resource Speed:", speed), curr_row, curr_row + n_rows - 1)
  curr_row <- curr_row + n_rows
}

writeLines(kbl, paste0(comparisons, "rotation_magnitude_search_temporal_comparison_combined.tex"))

Model 3: Social Cohesion & OutDegree Effects (OutDegree > 1)

m.RotationMagnitude.search.3.data %>%
  count(ResourceSpeed) %>% # SignalingType,
  mutate(Percentage = (n / sum(n)) * 100)
table(m.RotationMagnitude.search.3.data$SocMovDirCohesion)
0     1 

25250 29814

m.RotationMagnitude.search.3.formula <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed +
    SignalingType:ResourceSpeed:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDir +
    SignalingType:ResourceSpeed:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:SocQual:SocMovDir +
    SignalingType:ResourceSpeed:OutDegree:SocPosInFOV +
    SignalingType:ResourceSpeed:OutDegree:SocMovDir +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocMovDir +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocQual:SocMovDir +
    (1 + SocPosInFOV + SocMovDir + SocQual:SocPosInFOV + SocQual:SocMovDir | Participant),
  family = exponential()
)

m.RotationMagnitude.search.3.formula_comparison <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed +
    SignalingType:ResourceSpeed:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDir +
    SignalingType:ResourceSpeed:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:SocQual:SocMovDir +
    SignalingType:ResourceSpeed:OutDegree:SocPosInFOV +
    SignalingType:ResourceSpeed:OutDegree:SocMovDir +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocMovDir +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDirCohesion:SocQual:SocMovDir,
  family = exponential()
)
m.RotationMagnitude.search.3.priors <-
  prior(normal(0, 1), class = "Intercept") +
  prior(normal(0, 0.1), class = "sd") +
  prior(normal(0, 0.5), class = b)
m.RotationMagnitude.search.3.fit <- brm(
  formula = m.RotationMagnitude.search.3.formula,
  data = m.RotationMagnitude.search.3.data,
  prior = m.RotationMagnitude.search.3.priors,
  chains = 4,
  cores = 4,
  seed = 4242,
  warmup = 1000,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_search_3.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = FALSE)
)
summary(m.RotationMagnitude.search.3.fit, ask = F)
##  Family: exponential 
##   Links: mu = log 
## Formula: RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:SocPosInFOV + SignalingType:ResourceSpeed:SocMovDir + SignalingType:ResourceSpeed:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:SocQual:SocMovDir + SignalingType:ResourceSpeed:OutDegree:SocPosInFOV + SignalingType:ResourceSpeed:OutDegree:SocMovDir + SignalingType:ResourceSpeed:SocMovDirCohesion:SocPosInFOV + SignalingType:ResourceSpeed:SocMovDirCohesion:SocMovDir + SignalingType:ResourceSpeed:SocMovDirCohesion:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:SocMovDirCohesion:SocQual:SocMovDir + (1 + SocPosInFOV + SocMovDir + SocQual:SocPosInFOV + SocQual:SocMovDir | Participant) 
##    Data: m.RotationMagnitude.search.3.data (Number of observations: 55064) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~Participant (Number of levels: 454) 
##                                            Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)                                  0.46      0.02     0.43     0.50 1.01      646     1274
## sd(SocPosInFOV)                                0.34      0.02     0.30     0.37 1.00     1674     2231
## sd(SocMovDir)                                  0.25      0.02     0.22     0.28 1.00     1262     2232
## sd(SocPosInFOV:SocQual)                        0.26      0.02     0.23     0.29 1.00     1479     2448
## sd(SocMovDir:SocQual)                          0.23      0.01     0.20     0.25 1.00     1596     2803
## cor(Intercept,SocPosInFOV)                     0.06      0.06    -0.07     0.17 1.00     1389     2013
## cor(Intercept,SocMovDir)                       0.40      0.06     0.28     0.51 1.00     1640     1948
## cor(SocPosInFOV,SocMovDir)                    -0.04      0.08    -0.19     0.12 1.00      932     1796
## cor(Intercept,SocPosInFOV:SocQual)             0.34      0.06     0.21     0.46 1.00     1360     2193
## cor(SocPosInFOV,SocPosInFOV:SocQual)           0.23      0.07     0.08     0.37 1.00     1062     2002
## cor(SocMovDir,SocPosInFOV:SocQual)            -0.00      0.08    -0.15     0.16 1.00      987     1671
## cor(Intercept,SocMovDir:SocQual)               0.36      0.07     0.23     0.48 1.00     1736     2499
## cor(SocPosInFOV,SocMovDir:SocQual)            -0.15      0.08    -0.30     0.01 1.00     1002     1715
## cor(SocMovDir,SocMovDir:SocQual)               0.56      0.06     0.42     0.68 1.00     1244     1895
## cor(SocPosInFOV:SocQual,SocMovDir:SocQual)     0.06      0.08    -0.10     0.22 1.00     1143     2318
## 
## Regression Coefficients:
##                                                                          Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept                                                                   -1.72      0.06    -1.83    -1.62 1.02      188      441
## SignalingTypeVP                                                              0.14      0.07    -0.01     0.27 1.01      257      426
## SignalingTypeFP                                                              0.52      0.08     0.37     0.66 1.01      294      582
## ResourceSpeedslow                                                           -0.00      0.08    -0.15     0.15 1.01      391      836
## SignalingTypeVP:ResourceSpeedslow                                            0.15      0.11    -0.06     0.36 1.00      489     1115
## SignalingTypeFP:ResourceSpeedslow                                           -0.45      0.12    -0.67    -0.21 1.01      418      624
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV                                0.43      0.05     0.34     0.53 1.00     1345     2303
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV                                0.58      0.04     0.49     0.67 1.00     1087     1938
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV                                0.67      0.05     0.57     0.78 1.00     1582     2238
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV                                0.60      0.07     0.47     0.74 1.00     2147     2760
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV                                0.48      0.08     0.33     0.63 1.00     2432     2783
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV                                0.45      0.09     0.28     0.61 1.00     1990     2262
## SignalingTypeNP:ResourceSpeedfast:SocMovDir                                  0.09      0.04     0.02     0.17 1.00     1179     1867
## SignalingTypeVP:ResourceSpeedfast:SocMovDir                                  0.08      0.04     0.01     0.16 1.00     1321     1935
## SignalingTypeFP:ResourceSpeedfast:SocMovDir                                  0.28      0.04     0.20     0.37 1.00     1590     2326
## SignalingTypeNP:ResourceSpeedslow:SocMovDir                                  0.06      0.06    -0.06     0.17 1.00     2401     2786
## SignalingTypeVP:ResourceSpeedslow:SocMovDir                                  0.24      0.07     0.11     0.37 1.00     2406     2609
## SignalingTypeFP:ResourceSpeedslow:SocMovDir                                  0.07      0.08    -0.08     0.22 1.00     2028     2616
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:SocQual                        0.10      0.04     0.02     0.18 1.00     1829     2594
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:SocQual                        0.22      0.04     0.15     0.30 1.00     1062     1852
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:SocQual                        0.48      0.05     0.38     0.56 1.00     1523     2356
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:SocQual                        0.20      0.06     0.08     0.31 1.00     2152     2586
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:SocQual                        0.37      0.07     0.23     0.50 1.00     2510     2982
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:SocQual                        0.27      0.08     0.12     0.43 1.00     2291     2711
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:SocQual                         -0.02      0.04    -0.09     0.06 1.00     1372     2059
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:SocQual                          0.00      0.03    -0.06     0.07 1.00     1516     2246
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:SocQual                          0.16      0.04     0.08     0.24 1.00     1740     2631
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:SocQual                          0.02      0.06    -0.09     0.13 1.00     2383     2790
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:SocQual                          0.09      0.07    -0.04     0.22 1.00     2278     2887
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:SocQual                          0.09      0.07    -0.05     0.23 1.00     2312     2755
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:OutDegree                      0.02      0.02    -0.02     0.07 1.00     4489     3395
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:OutDegree                     -0.01      0.02    -0.05     0.04 1.00     5970     2867
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:OutDegree                      0.09      0.03     0.03     0.14 1.00     4036     2647
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:OutDegree                      0.03      0.04    -0.06     0.11 1.00     4209     3051
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:OutDegree                     -0.01      0.05    -0.11     0.08 1.00     4318     2875
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:OutDegree                      0.09      0.05    -0.01     0.19 1.00     4445     3153
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:OutDegree                        0.03      0.02    -0.01     0.08 1.00     4884     2583
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:OutDegree                       -0.02      0.02    -0.06     0.02 1.00     4707     3023
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:OutDegree                        0.04      0.03    -0.02     0.09 1.00     4496     3001
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:OutDegree                        0.09      0.04     0.02     0.17 1.00     4044     2628
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:OutDegree                       -0.01      0.05    -0.11     0.09 1.00     4707     3082
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:OutDegree                        0.04      0.05    -0.05     0.14 1.00     4358     3038
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:SocMovDirCohesion1            -0.46      0.04    -0.53    -0.38 1.00     3577     3001
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:SocMovDirCohesion1            -0.48      0.03    -0.55    -0.41 1.00     4282     3330
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:SocMovDirCohesion1            -0.50      0.04    -0.58    -0.41 1.00     3601     2787
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:SocMovDirCohesion1            -0.62      0.06    -0.75    -0.50 1.00     3692     2544
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:SocMovDirCohesion1            -0.19      0.07    -0.34    -0.05 1.00     3763     2804
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:SocMovDirCohesion1            -0.51      0.08    -0.66    -0.35 1.00     4230     3116
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:SocMovDirCohesion1               0.01      0.04    -0.06     0.08 1.00     3680     3012
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:SocMovDirCohesion1               0.16      0.03     0.10     0.23 1.00     3740     3086
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:SocMovDirCohesion1               0.20      0.04     0.11     0.28 1.00     3700     3126
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:SocMovDirCohesion1               0.09      0.06    -0.03     0.21 1.00     3641     3151
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:SocMovDirCohesion1              -0.06      0.07    -0.20     0.08 1.00     3595     3231
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:SocMovDirCohesion1               0.02      0.08    -0.13     0.17 1.00     3805     2849
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:SocQual:SocMovDirCohesion1    -0.09      0.04    -0.16    -0.01 1.00     3851     3026
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:SocQual:SocMovDirCohesion1    -0.04      0.03    -0.10     0.02 1.00     4052     2899
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:SocQual:SocMovDirCohesion1    -0.04      0.04    -0.12     0.04 1.00     3898     3220
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:SocQual:SocMovDirCohesion1    -0.03      0.06    -0.15     0.09 1.00     3949     2909
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:SocQual:SocMovDirCohesion1    -0.18      0.07    -0.31    -0.04 1.00     3576     2942
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:SocQual:SocMovDirCohesion1     0.04      0.08    -0.11     0.18 1.00     3968     3133
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:SocQual:SocMovDirCohesion1      -0.05      0.04    -0.12     0.02 1.00     4015     3122
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:SocQual:SocMovDirCohesion1       0.05      0.03    -0.01     0.12 1.00     4225     2969
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:SocQual:SocMovDirCohesion1       0.18      0.04     0.10     0.26 1.00     3267     3014
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:SocQual:SocMovDirCohesion1      -0.02      0.06    -0.15     0.10 1.00     3635     3091
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:SocQual:SocMovDirCohesion1      -0.07      0.07    -0.21     0.08 1.00     3272     3217
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:SocQual:SocMovDirCohesion1      -0.11      0.08    -0.26     0.04 1.00     3820     2752
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

Model 3: New Feature Posterior Contrasts

m.RotationMagnitude.search.3.tidy_draws <- m.RotationMagnitude.search.3.fit %>%
  tidy_draws() %>%
  gather_variables() %>%
  filter(grepl("b_SignalingType", .variable)) %>%
  filter(grepl("SocMovDirCohesion1|OutDegree", .variable))
m.RotationMagnitude.search.3.tidy_draws2 <- m.RotationMagnitude.search.3.tidy_draws %>%
  mutate(signaling = factor(case_when(
    str_detect(.variable, "SignalingTypeNP") ~ "NP",
    str_detect(.variable, "SignalingTypeVP") ~ "VP",
    str_detect(.variable, "SignalingTypeFP") ~ "FP",
  ), levels = c("NP", "VP", "FP"))) %>%
  mutate(resource = factor(case_when(
    str_detect(.variable, "ResourceSpeedfast") ~ "fast",
    str_detect(.variable, "ResourceSpeedslow") ~ "slow",
  ), levels = c("fast", "slow"))) %>%
  mutate(weight = factor(case_when(
    # Cohesion x Quality interactions (3-way, check first)
    str_detect(.variable, "SocMovDirCohesion1") & str_detect(.variable, "SocPosInFOV") & str_detect(.variable, "SocQual") ~ "Cohesion x Position x Quality",
    str_detect(.variable, "SocMovDirCohesion1") & !str_detect(.variable, "SocPosInFOV") & str_detect(.variable, "SocQual") ~ "Cohesion x Movement x Quality",
    # Cohesion interactions (2-way)
    str_detect(.variable, "SocMovDirCohesion1") & str_detect(.variable, "SocPosInFOV") ~ "Cohesion x Position",
    str_detect(.variable, "SocMovDirCohesion1") & !str_detect(.variable, "SocPosInFOV") ~ "Cohesion x Movement",
    # OutDegree interactions
    str_detect(.variable, "OutDegree") & str_detect(.variable, "SocPosInFOV") ~ "OutDegree x Position",
    str_detect(.variable, "OutDegree") & str_detect(.variable, "SocMovDir") ~ "OutDegree x Movement",
  ), levels = c(
    "OutDegree x Position",
    "OutDegree x Movement",
    "Cohesion x Position",
    "Cohesion x Movement",
    "Cohesion x Position x Quality",
    "Cohesion x Movement x Quality"
  )))

head(m.RotationMagnitude.search.3.tidy_draws2)

Summary Table

m.RotationMagnitude.search.3.summary <- m.RotationMagnitude.search.3.tidy_draws2 %>%
  group_by(resource, signaling, weight) %>%
  ggdist::mean_hdci(.value, .width = 0.9) %>%
  mutate(.value = round(.value, 2), .lower = round(.lower, 2), .upper = round(.upper, 2)) %>%
  ungroup()

m.RotationMagnitude.search.3.summary %>%
  knitr::kable("html", digits = 2) %>%
  kable_classic(full_width = T, position = "center")
resource signaling weight .value .lower .upper .width .point .interval
fast NP OutDegree x Position 0.02 -0.01 0.06 0.9 mean hdci
fast NP OutDegree x Movement 0.03 -0.01 0.07 0.9 mean hdci
fast NP Cohesion x Position -0.46 -0.52 -0.39 0.9 mean hdci
fast NP Cohesion x Movement 0.01 -0.04 0.08 0.9 mean hdci
fast NP Cohesion x Position x Quality -0.09 -0.15 -0.03 0.9 mean hdci
fast NP Cohesion x Movement x Quality -0.05 -0.11 0.01 0.9 mean hdci
fast VP OutDegree x Position -0.01 -0.04 0.03 0.9 mean hdci
fast VP OutDegree x Movement -0.02 -0.05 0.02 0.9 mean hdci
fast VP Cohesion x Position -0.48 -0.54 -0.42 0.9 mean hdci
fast VP Cohesion x Movement 0.16 0.10 0.21 0.9 mean hdci
fast VP Cohesion x Position x Quality -0.04 -0.10 0.01 0.9 mean hdci
fast VP Cohesion x Movement x Quality 0.05 0.00 0.10 0.9 mean hdci
fast FP OutDegree x Position 0.09 0.04 0.14 0.9 mean hdci
fast FP OutDegree x Movement 0.04 -0.01 0.08 0.9 mean hdci
fast FP Cohesion x Position -0.50 -0.57 -0.43 0.9 mean hdci
fast FP Cohesion x Movement 0.20 0.13 0.26 0.9 mean hdci
fast FP Cohesion x Position x Quality -0.04 -0.11 0.02 0.9 mean hdci
fast FP Cohesion x Movement x Quality 0.18 0.10 0.24 0.9 mean hdci
slow NP OutDegree x Position 0.03 -0.04 0.10 0.9 mean hdci
slow NP OutDegree x Movement 0.09 0.03 0.16 0.9 mean hdci
slow NP Cohesion x Position -0.62 -0.72 -0.51 0.9 mean hdci
slow NP Cohesion x Movement 0.09 -0.02 0.19 0.9 mean hdci
slow NP Cohesion x Position x Quality -0.03 -0.13 0.07 0.9 mean hdci
slow NP Cohesion x Movement x Quality -0.02 -0.13 0.08 0.9 mean hdci
slow VP OutDegree x Position -0.01 -0.09 0.07 0.9 mean hdci
slow VP OutDegree x Movement -0.01 -0.09 0.07 0.9 mean hdci
slow VP Cohesion x Position -0.19 -0.31 -0.08 0.9 mean hdci
slow VP Cohesion x Movement -0.06 -0.18 0.05 0.9 mean hdci
slow VP Cohesion x Position x Quality -0.18 -0.30 -0.07 0.9 mean hdci
slow VP Cohesion x Movement x Quality -0.07 -0.19 0.05 0.9 mean hdci
slow FP OutDegree x Position 0.09 0.01 0.19 0.9 mean hdci
slow FP OutDegree x Movement 0.04 -0.03 0.13 0.9 mean hdci
slow FP Cohesion x Position -0.51 -0.65 -0.39 0.9 mean hdci
slow FP Cohesion x Movement 0.02 -0.11 0.14 0.9 mean hdci
slow FP Cohesion x Position x Quality 0.04 -0.09 0.16 0.9 mean hdci
slow FP Cohesion x Movement x Quality -0.11 -0.23 0.02 0.9 mean hdci
m.RotationMagnitude.search.3.latex_table <- m.RotationMagnitude.search.3.summary %>%
  mutate(
    sig = (.lower * .upper) > 0,
    Estimate = sprintf("%.2f", .value),
    Estimate = ifelse(sig, paste0("\\textbf{", Estimate, "}"), Estimate),
    hpdi = sprintf("[%.2f, %.2f]", .lower, .upper),
    hpdi = ifelse(sig, paste0("\\textbf{", hpdi, "}"), hpdi)
  ) %>%
  select(resource, signaling, weight, Estimate, hpdi)

colnames(m.RotationMagnitude.search.3.latex_table) <- c(
  "Resource Speed", "Payoff Condition", "Decision Weight", "Mean", "90\\% HPDI"
)

kbl <- kable(
  m.RotationMagnitude.search.3.latex_table,
  format = "latex",
  booktabs = TRUE,
  align = c("l", "l", "l", "r", "r"),
  caption = "Posterior Estimates for New Social Features (OutDegree \\& Cohesion Interactions, OutDegree > 1) - Search",
  escape = FALSE
) %>%
  kable_styling(latex_options = c("hold_position", "scale_down")) %>%
  row_spec(0, bold = TRUE)

unique_speeds <- unique(m.RotationMagnitude.search.3.latex_table$`Resource Speed`)
curr_row <- 1
for (speed in unique_speeds) {
  n_rows <- sum(m.RotationMagnitude.search.3.latex_table$`Resource Speed` == speed)
  kbl <- group_rows(kbl, paste("Resource Speed:", speed), curr_row, curr_row + n_rows - 1)
  curr_row <- curr_row + n_rows
}

writeLines(kbl, paste0(comparisons, "rotation_magnitude_search_3_new_features.tex"))

Figures

Model 4: Peer Distance Moderation of Social Features (OutDegree == 1)

time_series_data %>%
  filter(State == "searching", OutDegree == 1, MeanDistToVisibleNeighbors >= median(MeanDistToVisibleNeighbors, na.rm = T)) %>%
  summarise(
    Total_Points = n(), # Good to know how many points are in the group total
    Pct_Over_100 = round(mean(MeanDistToVisibleNeighbors > 100, na.rm = TRUE) * 100, 1),
    Pct_Over_150 = round(mean(MeanDistToVisibleNeighbors > 150, na.rm = TRUE) * 100, 1),
    Pct_Over_200 = round(mean(MeanDistToVisibleNeighbors > 200, na.rm = TRUE) * 100, 1),
    .groups = "drop"
  )
m.RotationMagnitude.search.4.formula <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed +
    SignalingType:ResourceSpeed:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDir +
    SignalingType:ResourceSpeed:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:SocQual:SocMovDir +
    SignalingType:ResourceSpeed:PeerDist:SocPosInFOV +
    SignalingType:ResourceSpeed:PeerDist:SocMovDir +
    SignalingType:ResourceSpeed:PeerDist:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:PeerDist:SocQual:SocMovDir +
    (1 + SocPosInFOV + SocMovDir + SocQual:SocPosInFOV + SocQual:SocMovDir | Participant),
  family = exponential()
)

m.RotationMagnitude.search.4.formula_comparison <- brmsformula(
  RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed +
    SignalingType:ResourceSpeed:SocPosInFOV +
    SignalingType:ResourceSpeed:SocMovDir +
    SignalingType:ResourceSpeed:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:SocQual:SocMovDir +
    SignalingType:ResourceSpeed:PeerDist:SocPosInFOV +
    SignalingType:ResourceSpeed:PeerDist:SocMovDir +
    SignalingType:ResourceSpeed:PeerDist:SocQual:SocPosInFOV +
    SignalingType:ResourceSpeed:PeerDist:SocQual:SocMovDir,
  family = exponential()
)
m.RotationMagnitude.search.4.priors <-
  prior(normal(0, 1), class = "Intercept") +
  prior(normal(0, 0.1), class = "sd") +
  prior(normal(0, 0.5), class = b)
m.RotationMagnitude.search.4.fit <- brm(
  formula = m.RotationMagnitude.search.4.formula,
  data = m.RotationMagnitude.search.4.data,
  prior = m.RotationMagnitude.search.4.priors,
  chains = 4,
  cores = 4,
  seed = 4242,
  warmup = 1000,
  iter = 2000,
  file = paste0(fits_path, "rotation_magnitude_search_4.rds"),
  backend = "cmdstanr",
  threads = threading(100),
  save_pars = save_pars(all = FALSE)
)
summary(m.RotationMagnitude.search.4.fit, ask = F)
##  Family: exponential 
##   Links: mu = log 
## Formula: RotationAbs | trunc(ub = 1.02) ~ SignalingType * ResourceSpeed + SignalingType:ResourceSpeed:SocPosInFOV + SignalingType:ResourceSpeed:SocMovDir + SignalingType:ResourceSpeed:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:SocQual:SocMovDir + SignalingType:ResourceSpeed:PeerDist:SocPosInFOV + SignalingType:ResourceSpeed:PeerDist:SocMovDir + SignalingType:ResourceSpeed:PeerDist:SocQual:SocPosInFOV + SignalingType:ResourceSpeed:PeerDist:SocQual:SocMovDir + (1 + SocPosInFOV + SocMovDir + SocQual:SocPosInFOV + SocQual:SocMovDir | Participant) 
##    Data: m.RotationMagnitude.search.4.data (Number of observations: 42418) 
##   Draws: 4 chains, each with iter = 2000; warmup = 1000; thin = 1;
##          total post-warmup draws = 4000
## 
## Multilevel Hyperparameters:
## ~Participant (Number of levels: 441) 
##                                            Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## sd(Intercept)                                  0.43      0.02     0.40     0.47 1.01      678     1093
## sd(SocPosInFOV)                                0.37      0.02     0.32     0.41 1.00     1187     2228
## sd(SocMovDir)                                  0.33      0.02     0.29     0.38 1.00     1204     2275
## sd(SocPosInFOV:SocQual)                        0.32      0.02     0.28     0.37 1.01      819     1690
## sd(SocMovDir:SocQual)                          0.32      0.02     0.27     0.36 1.00      938     1795
## cor(Intercept,SocPosInFOV)                     0.04      0.08    -0.11     0.20 1.00      929     1949
## cor(Intercept,SocMovDir)                       0.15      0.08    -0.01     0.31 1.00     1184     2191
## cor(SocPosInFOV,SocMovDir)                    -0.23      0.09    -0.40    -0.05 1.00      853     1442
## cor(Intercept,SocPosInFOV:SocQual)             0.18      0.08     0.02     0.34 1.00     1016     1974
## cor(SocPosInFOV,SocPosInFOV:SocQual)           0.69      0.05     0.59     0.78 1.00     1117     2177
## cor(SocMovDir,SocPosInFOV:SocQual)            -0.21      0.09    -0.38    -0.02 1.00      755     1528
## cor(Intercept,SocMovDir:SocQual)               0.01      0.08    -0.15     0.17 1.00     1100     2354
## cor(SocPosInFOV,SocMovDir:SocQual)            -0.33      0.09    -0.49    -0.16 1.00      960     1905
## cor(SocMovDir,SocMovDir:SocQual)               0.70      0.05     0.58     0.79 1.00      968     1656
## cor(SocPosInFOV:SocQual,SocMovDir:SocQual)    -0.34      0.09    -0.51    -0.15 1.00      797     1688
## 
## Regression Coefficients:
##                                                                   Estimate Est.Error l-95% CI u-95% CI Rhat Bulk_ESS Tail_ESS
## Intercept                                                            -1.60      0.05    -1.69    -1.50 1.01      209      467
## SignalingTypeVP                                                       0.10      0.07    -0.03     0.24 1.02      210      465
## SignalingTypeFP                                                       0.60      0.07     0.46     0.75 1.01      267      668
## ResourceSpeedslow                                                     0.20      0.08     0.04     0.34 1.01      310      979
## SignalingTypeVP:ResourceSpeedslow                                     0.08      0.11    -0.14     0.29 1.01      346      644
## SignalingTypeFP:ResourceSpeedslow                                    -0.52      0.12    -0.76    -0.29 1.01      380      875
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV                         0.18      0.06     0.05     0.30 1.00      998     1696
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV                         0.26      0.06     0.15     0.38 1.00     1034     2045
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV                         0.47      0.07     0.34     0.60 1.00     1267     1990
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV                         0.34      0.08     0.17     0.50 1.00     1455     2437
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV                         0.29      0.10     0.09     0.50 1.00     1509     2419
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV                         0.36      0.12     0.13     0.58 1.00     1607     2430
## SignalingTypeNP:ResourceSpeedfast:SocMovDir                           0.05      0.06    -0.07     0.16 1.00     1122     1983
## SignalingTypeVP:ResourceSpeedfast:SocMovDir                           0.13      0.06     0.02     0.24 1.00     1056     1874
## SignalingTypeFP:ResourceSpeedfast:SocMovDir                           0.24      0.06     0.12     0.37 1.00     1366     1970
## SignalingTypeNP:ResourceSpeedslow:SocMovDir                          -0.13      0.08    -0.30     0.03 1.00     1549     2522
## SignalingTypeVP:ResourceSpeedslow:SocMovDir                           0.02      0.10    -0.18     0.21 1.00     1621     2823
## SignalingTypeFP:ResourceSpeedslow:SocMovDir                           0.12      0.11    -0.10     0.34 1.00     1931     2754
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:SocQual                 0.10      0.06    -0.01     0.22 1.00     1103     1865
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:SocQual                 0.22      0.06     0.11     0.32 1.00     1060     2066
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:SocQual                 0.36      0.06     0.24     0.49 1.00     1136     1971
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:SocQual                 0.23      0.08     0.07     0.40 1.00     1668     2416
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:SocQual                 0.28      0.10     0.09     0.49 1.00     1425     2140
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:SocQual                 0.33      0.11     0.11     0.55 1.00     1747     2347
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:SocQual                  -0.04      0.06    -0.15     0.07 1.00     1102     1972
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:SocQual                  -0.02      0.06    -0.13     0.09 1.00      994     1804
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:SocQual                   0.04      0.06    -0.08     0.16 1.00     1430     2323
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:SocQual                  -0.28      0.08    -0.44    -0.12 1.00     1629     2542
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:SocQual                  -0.22      0.10    -0.42    -0.02 1.00     1657     2461
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:SocQual                  -0.07      0.11    -0.30     0.15 1.00     1907     2553
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:PeerDistfar            -0.19      0.06    -0.32    -0.07 1.00     1690     2597
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:PeerDistfar             0.07      0.06    -0.05     0.19 1.00     1732     2520
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:PeerDistfar             0.25      0.07     0.11     0.39 1.00     1994     2597
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:PeerDistfar            -0.26      0.09    -0.45    -0.08 1.00     2298     2724
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:PeerDistfar            -0.09      0.13    -0.35     0.17 1.00     1915     2494
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:PeerDistfar             0.15      0.15    -0.14     0.44 1.00     1616     2610
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:PeerDistfar               0.07      0.06    -0.05     0.19 1.00     1740     2559
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:PeerDistfar              -0.09      0.06    -0.21     0.02 1.00     1500     2474
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:PeerDistfar               0.36      0.08     0.21     0.51 1.00     1853     2774
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:PeerDistfar               0.36      0.10     0.17     0.57 1.00     2058     2341
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:PeerDistfar               0.21      0.13    -0.05     0.46 1.00     2082     2771
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:PeerDistfar               0.40      0.15     0.09     0.70 1.00     1998     2530
## SignalingTypeNP:ResourceSpeedfast:SocPosInFOV:SocQual:PeerDistfar    -0.19      0.06    -0.31    -0.06 1.00     1619     2451
## SignalingTypeVP:ResourceSpeedfast:SocPosInFOV:SocQual:PeerDistfar     0.02      0.06    -0.09     0.13 1.00     1786     2455
## SignalingTypeFP:ResourceSpeedfast:SocPosInFOV:SocQual:PeerDistfar     0.42      0.07     0.30     0.56 1.00     1909     2523
## SignalingTypeNP:ResourceSpeedslow:SocPosInFOV:SocQual:PeerDistfar    -0.16      0.09    -0.35     0.02 1.00     2213     2118
## SignalingTypeVP:ResourceSpeedslow:SocPosInFOV:SocQual:PeerDistfar    -0.00      0.13    -0.26     0.25 1.00     1995     2802
## SignalingTypeFP:ResourceSpeedslow:SocPosInFOV:SocQual:PeerDistfar     0.17      0.15    -0.11     0.47 1.00     1571     2918
## SignalingTypeNP:ResourceSpeedfast:SocMovDir:SocQual:PeerDistfar       0.15      0.06     0.03     0.27 1.00     1600     2192
## SignalingTypeVP:ResourceSpeedfast:SocMovDir:SocQual:PeerDistfar      -0.02      0.06    -0.14     0.10 1.00     1441     2437
## SignalingTypeFP:ResourceSpeedfast:SocMovDir:SocQual:PeerDistfar       0.32      0.07     0.17     0.46 1.00     1943     2559
## SignalingTypeNP:ResourceSpeedslow:SocMovDir:SocQual:PeerDistfar       0.31      0.10     0.12     0.50 1.00     2158     2568
## SignalingTypeVP:ResourceSpeedslow:SocMovDir:SocQual:PeerDistfar       0.34      0.13     0.09     0.59 1.00     2086     2706
## SignalingTypeFP:ResourceSpeedslow:SocMovDir:SocQual:PeerDistfar       0.49      0.16     0.19     0.80 1.00     1967     2788
## 
## Draws were sampled using sample(hmc). For each parameter, Bulk_ESS
## and Tail_ESS are effective sample size measures, and Rhat is the potential
## scale reduction factor on split chains (at convergence, Rhat = 1).

Model 4: Social Feature Posterior Contrasts

# 1. Extract the draws and format them
m.RotationMagnitude.search.4.tidy_draws2 <- as_draws_df(m.RotationMagnitude.search.4.fit) %>%
  as_tibble() %>% # Add this line to drop the class intentionally and silently
  select(starts_with("b_SignalingType")) %>%
  mutate(.draw = row_number()) %>%
  pivot_longer(cols = -.draw, names_to = ".variable", values_to = ".value") %>%
  
  # 2. Parse the parameters
  mutate(
    signaling = case_when(
      str_detect(.variable, "SignalingTypeNP") ~ "NP",
      str_detect(.variable, "SignalingTypeVP") ~ "VP",
      str_detect(.variable, "SignalingTypeFP") ~ "FP"
    ),
    resource = case_when(
      str_detect(.variable, "ResourceSpeedfast") ~ "fast",
      str_detect(.variable, "ResourceSpeedslow") ~ "slow"
    ),
    weight = case_when(
      str_detect(.variable, "SocPosInFOV") & str_detect(.variable, "SocQual") ~ "Position x Quality",
      str_detect(.variable, "SocMovDir") & str_detect(.variable, "SocQual") ~ "Movement x Quality",
      str_detect(.variable, "SocPosInFOV") ~ "Position",
      str_detect(.variable, "SocMovDir") ~ "Movement"
    ),
    # 3. Identify if this is the base term (near) or the contrast term (far - near)
    term_type = ifelse(str_detect(.variable, "PeerDistfar"), "far_diff", "near_base")
  ) %>%
  
  # Drop any intercept/main effects not matching our specific weight combinations
  filter(!is.na(weight), !is.na(signaling), !is.na(resource)) %>%
  
  # 4. Pivot wider to calculate the absolute estimates per draw
  select(.draw, signaling, resource, weight, term_type, .value) %>%
  pivot_wider(names_from = term_type, values_from = .value) %>%
  mutate(
    near = near_base,
    far = near_base + far_diff # Estimate for 'far' = Base + Difference
  ) %>%
  select(-near_base, -far_diff) %>%
  
  # 5. Pivot back to the long format needed for your ggdist plot
  pivot_longer(cols = c("near", "far"), names_to = "peer_dist", values_to = ".value") %>%
  mutate(
    peer_dist = factor(peer_dist, levels = c("near", "far")),
    signaling = factor(signaling, levels = c("NP", "VP", "FP")),
    resource = factor(resource, levels = c("fast", "slow")),
    weight = factor(weight, levels = c(
      "Position", "Movement", "Position x Quality", "Movement x Quality"
    ))
  )

head(m.RotationMagnitude.search.4.tidy_draws2)

Summary Table

m.RotationMagnitude.search.4.summary <- m.RotationMagnitude.search.4.tidy_draws2 %>%
  group_by(resource, signaling, peer_dist, weight) %>%
  ggdist::mean_hdci(.value, .width = 0.9) %>%
  mutate(.value = round(.value, 2), .lower = round(.lower, 2), .upper = round(.upper, 2)) %>%
  ungroup()

m.RotationMagnitude.search.4.summary %>%
  knitr::kable("html", digits = 2) %>%
  kable_classic(full_width = T, position = "center")
resource signaling peer_dist weight .value .lower .upper .width .point .interval
fast NP near Position 0.18 0.07 0.28 0.9 mean hdci
fast NP near Movement 0.05 -0.05 0.15 0.9 mean hdci
fast NP near Position x Quality 0.10 0.01 0.20 0.9 mean hdci
fast NP near Movement x Quality -0.04 -0.14 0.05 0.9 mean hdci
fast NP far Position -0.02 -0.11 0.08 0.9 mean hdci
fast NP far Movement 0.12 0.02 0.21 0.9 mean hdci
fast NP far Position x Quality -0.08 -0.17 0.01 0.9 mean hdci
fast NP far Movement x Quality 0.11 0.02 0.21 0.9 mean hdci
fast VP near Position 0.26 0.17 0.36 0.9 mean hdci
fast VP near Movement 0.13 0.04 0.23 0.9 mean hdci
fast VP near Position x Quality 0.22 0.13 0.31 0.9 mean hdci
fast VP near Movement x Quality -0.02 -0.11 0.07 0.9 mean hdci
fast VP far Position 0.33 0.24 0.43 0.9 mean hdci
fast VP far Movement 0.04 -0.06 0.13 0.9 mean hdci
fast VP far Position x Quality 0.24 0.15 0.32 0.9 mean hdci
fast VP far Movement x Quality -0.03 -0.12 0.06 0.9 mean hdci
fast FP near Position 0.47 0.36 0.58 0.9 mean hdci
fast FP near Movement 0.24 0.14 0.35 0.9 mean hdci
fast FP near Position x Quality 0.36 0.26 0.47 0.9 mean hdci
fast FP near Movement x Quality 0.04 -0.06 0.14 0.9 mean hdci
fast FP far Position 0.72 0.61 0.84 0.9 mean hdci
fast FP far Movement 0.60 0.48 0.73 0.9 mean hdci
fast FP far Position x Quality 0.79 0.68 0.89 0.9 mean hdci
fast FP far Movement x Quality 0.36 0.25 0.48 0.9 mean hdci
slow NP near Position 0.34 0.21 0.49 0.9 mean hdci
slow NP near Movement -0.13 -0.25 0.02 0.9 mean hdci
slow NP near Position x Quality 0.23 0.09 0.36 0.9 mean hdci
slow NP near Movement x Quality -0.28 -0.40 -0.13 0.9 mean hdci
slow NP far Position 0.08 -0.07 0.22 0.9 mean hdci
slow NP far Movement 0.24 0.09 0.39 0.9 mean hdci
slow NP far Position x Quality 0.07 -0.06 0.20 0.9 mean hdci
slow NP far Movement x Quality 0.03 -0.13 0.17 0.9 mean hdci
slow VP near Position 0.29 0.13 0.46 0.9 mean hdci
slow VP near Movement 0.02 -0.13 0.20 0.9 mean hdci
slow VP near Position x Quality 0.28 0.12 0.44 0.9 mean hdci
slow VP near Movement x Quality -0.22 -0.38 -0.05 0.9 mean hdci
slow VP far Position 0.20 0.03 0.40 0.9 mean hdci
slow VP far Movement 0.23 0.06 0.42 0.9 mean hdci
slow VP far Position x Quality 0.27 0.09 0.46 0.9 mean hdci
slow VP far Movement x Quality 0.12 -0.06 0.30 0.9 mean hdci
slow FP near Position 0.36 0.19 0.57 0.9 mean hdci
slow FP near Movement 0.12 -0.09 0.29 0.9 mean hdci
slow FP near Position x Quality 0.33 0.15 0.51 0.9 mean hdci
slow FP near Movement x Quality -0.07 -0.25 0.12 0.9 mean hdci
slow FP far Position 0.51 0.29 0.73 0.9 mean hdci
slow FP far Movement 0.52 0.31 0.75 0.9 mean hdci
slow FP far Position x Quality 0.50 0.27 0.72 0.9 mean hdci
slow FP far Movement x Quality 0.42 0.20 0.63 0.9 mean hdci
m.RotationMagnitude.search.4.latex_table <- m.RotationMagnitude.search.4.summary %>%
  mutate(
    sig = (.lower * .upper) > 0,
    Estimate = sprintf("%.2f", .value),
    Estimate = ifelse(sig, paste0("\\textbf{", Estimate, "}"), Estimate),
    hpdi = sprintf("[%.2f, %.2f]", .lower, .upper),
    hpdi = ifelse(sig, paste0("\\textbf{", hpdi, "}"), hpdi)
  ) %>%
  select(resource, signaling, peer_dist, weight, Estimate, hpdi)

colnames(m.RotationMagnitude.search.4.latex_table) <- c(
  "Resource Speed", "Payoff Condition", "Peer Distance", "Decision Weight", "Mean", "90\\% HPDI"
)

kbl <- kable(
  m.RotationMagnitude.search.4.latex_table,
  format = "latex",
  booktabs = TRUE,
  align = c("l", "l", "l", "l", "r", "r"),
  caption = "Posterior Estimates for Social Features by Peer Distance (OutDegree == 1) - Search",
  escape = FALSE
) %>%
  kable_styling(latex_options = c("hold_position", "scale_down")) %>%
  row_spec(0, bold = TRUE)

unique_speeds <- unique(m.RotationMagnitude.search.4.latex_table$`Resource Speed`)
curr_row <- 1
for (speed in unique_speeds) {
  n_rows <- sum(m.RotationMagnitude.search.4.latex_table$`Resource Speed` == speed)
  kbl <- group_rows(kbl, paste("Resource Speed:", speed), curr_row, curr_row + n_rows - 1)
  curr_row <- curr_row + n_rows
}

writeLines(kbl, paste0(comparisons, "rotation_magnitude_search_4_peer_distance.tex"))

Figures