Chapter 3 Other fitness landscapes

3.1 Setup

library(ggplot2)
library(tidyverse)
library(knitr)
library(cowplot)
library(viridis)
library(RColorBrewer)
library(rstatix)
library(ggsignif)
library(Hmisc)
library(kableExtra)
source("https://gist.githubusercontent.com/benmarwick/2a1bb0133ff568cbe28d/raw/fb53bd97121f7f9ce947837ef1a4c65a73bffb3f/geom_flat_violin.R")
library(readr)
library(stringr)
library(ggpubr)
library(infotheo)
library(osfr)
library(scales)

These analyses were conducted in the following computing environment:

print(version)
##                _                           
## platform       x86_64-apple-darwin17.0     
## arch           x86_64                      
## os             darwin17.0                  
## system         x86_64, darwin17.0          
## status                                     
## major          4                           
## minor          1.1                         
## year           2021                        
## month          08                          
## day            10                          
## svn rev        80725                       
## language       R                           
## version.string R version 4.1.1 (2021-08-10)
## nickname       Kick Things
# Labeler for stats annotations
p_label <- function(p_value) {
  threshold = 0.0001
  if (p_value < threshold) {
    return(paste0("p < ", threshold))
  } else {
    return(paste0("p = ", p_value))
  }
}

# Significance threshold
alpha <- 0.05

####### misc #######
# Configure our default graphing theme
theme_set(theme_cowplot())
osf_retrieve_file("p79hx") %>% osf_download(conflicts = "skip")  # Download data from osf
## # A tibble: 1 × 4
##   name                           id                       local_path     meta   
##   <chr>                          <chr>                    <chr>          <list> 
## 1 complex_fitness_landscapes.csv 612fe4d84e5ee5019e29292e ./complex_fit… <named…
data_loc <- "complex_fitness_landscapes.csv"

data <- read_csv(data_loc, na=c("NONE", "NA", ""))

data <- data %>% 
  filter(N==20, generation %%10 == 0) %>%
  mutate(
  selection_name = as.factor(case_when(
    SELECTION == 0 ~ "Tournament",
    SELECTION == 1 ~ "Fitness sharing",
    SELECTION == 2 ~ "Lexicase",
    SELECTION == 3 ~ "Eco-EA",
    SELECTION == 4 ~ "Random",
  )), 
  problem_name = as.factor(case_when(
    PROBLEM == 0 ~ "NK Landscape",
    PROBLEM == 1 ~ "Count Odds",
    PROBLEM == 2 ~ "Real-valued optimization",
    PROBLEM == 3 ~ "Sorting network",
    PROBLEM == 4 ~ "Logic-9"    
  ))
)

data <- filter(data, generation <= 2000)
final_data <- filter(data, generation==max(data$generation))

3.2 Performance

3.2.1 Over time

ggplot(
    data,
    aes(
      x=generation,
      y=max_performance,
      color=selection_name,
      fill=selection_name
    )
  ) +
  stat_summary(geom="line", fun=mean) +
  stat_summary(
    geom="ribbon",
    fun.data="mean_cl_boot",
    fun.args=list(conf.int=0.95),
    alpha=0.2,
    linetype=0
  ) +
  scale_y_continuous(
    name="Average trait performance"
  ) +
  scale_x_continuous(
    name="Generation"
  ) +
  scale_color_discrete("Selection") + 
  scale_fill_discrete("Selection") +
  facet_wrap(~problem_name, scales="free")

3.2.2 Final

# Compute manual labels for geom_signif
stat.test <- final_data %>%
  wilcox_test(max_performance ~ selection_name) %>%
  adjust_pvalue(method = "bonferroni") %>%
  add_significance() %>%
  add_xy_position(x="selection_name",step.increase=1)
#stat.test$manual_position <- stat.test$y.position * .5
#stat.test$manual_position <- c(110, 1100, 170, 170, 130, 110)
stat.test$label <- mapply(p_label,stat.test$p.adj)
ggplot(
    final_data,
    aes(
      x=selection_name,
      y=max_performance,
      fill=selection_name
    )
  ) +
  geom_boxplot() +
  scale_y_continuous(
    name="Average trait performance"
  ) +
  scale_x_discrete(
    name="Selection"
  ) +
  scale_fill_discrete(
    name="Selection"
  ) +
  scale_color_discrete(
    name="Selection"
  ) + 
  theme(legend.position="none") +
  facet_wrap(~problem_name, scales="free")

stat.test %>%
  kbl() %>%
  kable_styling(
    bootstrap_options = c(
      "striped",
      "hover",
      "condensed",
      "responsive"
    )
  ) %>%
  scroll_box(width="600px")
.y. group1 group2 n1 n2 statistic p p.adj p.adj.signif y.position groups xmin xmax label
max_performance Eco-EA Fitness sharing 240 240 28898.5 9.49e-01 1.00e+00 ns 102283.6 Eco-EA , Fitness sharing 1 2 p = 1
max_performance Eco-EA Lexicase 240 240 22536.0 3.25e-05 3.25e-04 *** 135739.0 Eco-EA , Lexicase 1 3 p = 0.000325
max_performance Eco-EA Random 240 240 38664.0 0.00e+00 0.00e+00 **** 169194.5 Eco-EA, Random 1 4 p < 1e-04
max_performance Eco-EA Tournament 240 240 28335.5 7.59e-01 1.00e+00 ns 202649.9 Eco-EA , Tournament 1 5 p = 1
max_performance Fitness sharing Lexicase 240 240 21248.5 7.00e-07 6.50e-06 **** 236105.4 Fitness sharing, Lexicase 2 3 p < 1e-04
max_performance Fitness sharing Random 240 240 40208.0 0.00e+00 0.00e+00 **** 269560.8 Fitness sharing, Random 2 4 p < 1e-04
max_performance Fitness sharing Tournament 240 240 26515.0 1.33e-01 1.00e+00 ns 303016.3 Fitness sharing, Tournament 2 5 p = 1
max_performance Lexicase Random 240 240 44119.5 0.00e+00 0.00e+00 **** 336471.7 Lexicase, Random 3 4 p < 1e-04
max_performance Lexicase Tournament 240 240 35022.0 3.93e-05 3.93e-04 *** 369927.2 Lexicase , Tournament 3 5 p = 0.000393
max_performance Random Tournament 240 240 17928.5 0.00e+00 0.00e+00 **** 403382.6 Random , Tournament 4 5 p < 1e-04

3.3 Phylogenetic diversity

3.3.1 Relationship between different types of pylogenetic diversity

First, to get a big-picture overview, we make correlation matrices of all the different phylogenetic diversity metrics:

final_data %>% 
  transmute(MinPD=min_phenotype_pairwise_distance, 
            MeanPD=mean_phenotype_pairwise_distance, 
            MaxPD=max_phenotype_pairwise_distance, 
            VarPD=variance_phenotype_pairwise_distance, 
            MinED = min_phenotype_evolutionary_distinctiveness,
            MeanED= mean_phenotype_evolutionary_distinctiveness,
            MaxED=max_phenotype_evolutionary_distinctiveness,
            VarED=variance_phenotype_evolutionary_distinctiveness,
            PD=phenotype_current_phylogenetic_diversity,  # See Faith 1992
            MRCA=phenotype_mrca_depth,  # Phylogenetic depth of most recent common ancestor
            N=phenotype_num_taxa     # Number of taxonomically-distinct phenotypes
  ) %>%
  cor_mat() %>% 
  pull_lower_triangle() %>% 
  cor_plot()

However, these correlations may well vary by selection scheme and by problem, and even over time within a selection scheme and problem. Let’s take a look at some scatter plots.

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=mean_phenotype_pairwise_distance,
        x=variance_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=mean_phenotype_pairwise_distance,
        x=max_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=variance_phenotype_pairwise_distance,
        x=max_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==500),
    aes(
        y=mean_phenotype_pairwise_distance,
        x=variance_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==500),
    aes(
        y=mean_phenotype_pairwise_distance,
        x=max_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=variance_phenotype_pairwise_distance,
        x=max_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=mean_phenotype_evolutionary_distinctiveness,
        x=variance_phenotype_evolutionary_distinctiveness,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=mean_phenotype_evolutionary_distinctiveness,
        x=max_phenotype_evolutionary_distinctiveness,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=mean_phenotype_evolutionary_distinctiveness,
        x=min_phenotype_evolutionary_distinctiveness,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==500),
    aes(
        y=mean_phenotype_evolutionary_distinctiveness,
        x=variance_phenotype_evolutionary_distinctiveness,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==500),
    aes(
        y=mean_phenotype_evolutionary_distinctiveness,
        x=max_phenotype_evolutionary_distinctiveness,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==500),
    aes(
        y=mean_phenotype_evolutionary_distinctiveness,
        x=min_phenotype_evolutionary_distinctiveness,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
  scale_x_continuous(
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

3.3.2 Over time

ggplot(
    data,
    aes(
      x=generation,
      y=mean_phenotype_pairwise_distance,
      color=selection_name,
      fill=selection_name
    )
  ) +
  stat_summary(geom="line", fun=mean) +
  stat_summary(
    geom="ribbon",
    fun.data="mean_cl_boot",
    fun.args=list(conf.int=0.95),
    alpha=0.2,
    linetype=0
  ) +
  scale_y_log10(
    name="Mean pairwise distance"
  ) +
  scale_x_continuous(
    name="Generation"
  ) +
  scale_color_discrete("Selection") +
  scale_fill_discrete("Selection") +
  facet_wrap(~problem_name, scales = "free")

3.3.3 Final

# Compute manual labels for geom_signif
stat.test <- final_data %>%
  wilcox_test(mean_phenotype_pairwise_distance ~ selection_name) %>%
  adjust_pvalue(method = "bonferroni") %>%
  add_significance() %>%
  add_xy_position(x="selection_name",step.increase=1)
#stat.test$manual_position <- stat.test$y.position * .5
#stat.test$manual_position <- c(110, 150, 170, 170, 130, 110)
stat.test$label <- mapply(p_label,stat.test$p.adj)
ggplot(
    final_data,
    aes(
      x=selection_name,
      y=mean_phenotype_pairwise_distance,
      fill=selection_name
    )
  ) +
  geom_boxplot() +
  scale_y_log10(
    name="Mean pairwise distance"
  ) +
  scale_x_discrete(
    name="Selection"
  ) +
  scale_fill_discrete(
    name="Selection"
  ) +
  scale_color_discrete(
    name="Selection"
  ) + 
  theme(legend.position = "none") +
    facet_wrap(~problem_name, scales = "free")

stat.test %>%
  kbl() %>%
  kable_styling(
    bootstrap_options = c(
      "striped",
      "hover",
      "condensed",
      "responsive"
    )
  ) %>%
  scroll_box(width="600px")
.y. group1 group2 n1 n2 statistic p p.adj p.adj.signif y.position groups xmin xmax label
mean_phenotype_pairwise_distance Eco-EA Fitness sharing 240 240 2486.0 0.00e+00 0.00e+00 **** 2900.227 Eco-EA , Fitness sharing 1 2 p < 1e-04
mean_phenotype_pairwise_distance Eco-EA Lexicase 240 240 23590.0 6.07e-04 6.07e-03 ** 4498.579 Eco-EA , Lexicase 1 3 p = 0.00607
mean_phenotype_pairwise_distance Eco-EA Random 240 240 8274.0 0.00e+00 0.00e+00 **** 6096.931 Eco-EA, Random 1 4 p < 1e-04
mean_phenotype_pairwise_distance Eco-EA Tournament 240 240 43940.0 0.00e+00 0.00e+00 **** 7695.284 Eco-EA , Tournament 1 5 p < 1e-04
mean_phenotype_pairwise_distance Fitness sharing Lexicase 240 240 35067.0 3.72e-05 3.72e-04 *** 9293.636 Fitness sharing, Lexicase 2 3 p = 0.000372
mean_phenotype_pairwise_distance Fitness sharing Random 240 240 37442.0 0.00e+00 1.00e-07 **** 10891.988 Fitness sharing, Random 2 4 p < 1e-04
mean_phenotype_pairwise_distance Fitness sharing Tournament 240 240 57033.0 0.00e+00 0.00e+00 **** 12490.340 Fitness sharing, Tournament 2 5 p < 1e-04
mean_phenotype_pairwise_distance Lexicase Random 240 240 26406.0 1.15e-01 1.00e+00 ns 14088.693 Lexicase, Random 3 4 p = 1
mean_phenotype_pairwise_distance Lexicase Tournament 240 240 36500.5 4.00e-07 4.00e-06 **** 15687.045 Lexicase , Tournament 3 5 p < 1e-04
mean_phenotype_pairwise_distance Random Tournament 240 240 55686.0 0.00e+00 0.00e+00 **** 17285.397 Random , Tournament 4 5 p < 1e-04

3.4 Phenotypic diversity

3.4.1 Relationship between different types of phenotypic diversity

First, we should assess the extent to which different metrics of phenotypic diversity are capturing different information.

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=phenotype_diversity,
        x=phenotype_num_taxa,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Phenotypic shannon diversity"
  ) +
  scale_x_continuous(
        name="Phenotypic richness",
        breaks = breaks_extended(4)
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

3.4.2 Over time

ggplot(
    data,
    aes(
      x=generation,
      y=phenotype_num_taxa,
      color=selection_name,
      fill=selection_name
    )
  ) +
  stat_summary(geom="line", fun=mean) +
  stat_summary(
    geom="ribbon",
    fun.data="mean_cl_boot",
    fun.args=list(conf.int=0.95),
    alpha=0.2,
    linetype=0
  ) +
  scale_y_continuous(
    name="Phenotypic richness"
  ) +
  scale_x_continuous(
    name="Generation"
  ) +
  scale_color_discrete("Selection") + 
  scale_fill_discrete("Selection") +
  facet_wrap(~problem_name, scales = "free")

3.4.3 Final

# Compute manual labels for geom_signif
stat.test <- final_data %>%
  wilcox_test(phenotype_num_taxa ~ selection_name) %>%
  adjust_pvalue(method = "bonferroni") %>%
  add_significance() %>%
  add_xy_position(x="selection_name",step.increase=1)
#stat.test$manual_position <- stat.test$y.position * .5
#stat.test$manual_position <- c(110, 150, 170, 170, 130, 110)
stat.test$label <- mapply(p_label,stat.test$p.adj)
ggplot(
    final_data,
    aes(
      x=selection_name,
      y=phenotype_num_taxa,
      fill=selection_name
    )
  ) +
  geom_boxplot() +
  scale_y_continuous(
    name="Phenotypic Richness"
  ) +
  scale_x_discrete(
    name="Selection"
  ) +
  scale_fill_discrete(
    name="Selection"
  ) +
  scale_color_discrete(
    name="Selection"
  ) +
  theme(legend.position = "none") +
  facet_wrap(~problem_name, scales = "free")

stat.test %>%
  kbl() %>%
  kable_styling(
    bootstrap_options = c(
      "striped",
      "hover",
      "condensed",
      "responsive"
    )
  ) %>%
  scroll_box(width="600px")
.y. group1 group2 n1 n2 statistic p p.adj p.adj.signif y.position groups xmin xmax label
phenotype_num_taxa Eco-EA Fitness sharing 240 240 3513.5 0.00000 0.0000 **** 1580.000 Eco-EA , Fitness sharing 1 2 p < 1e-04
phenotype_num_taxa Eco-EA Lexicase 240 240 17757.5 0.00000 0.0000 **** 2224.444 Eco-EA , Lexicase 1 3 p < 1e-04
phenotype_num_taxa Eco-EA Random 240 240 38186.0 0.00000 0.0000 **** 2868.889 Eco-EA, Random 1 4 p < 1e-04
phenotype_num_taxa Eco-EA Tournament 240 240 30723.0 0.20600 1.0000 ns 3513.333 Eco-EA , Tournament 1 5 p = 1
phenotype_num_taxa Fitness sharing Lexicase 240 240 39523.5 0.00000 0.0000 **** 4157.778 Fitness sharing, Lexicase 2 3 p < 1e-04
phenotype_num_taxa Fitness sharing Random 240 240 56742.5 0.00000 0.0000 **** 4802.222 Fitness sharing, Random 2 4 p < 1e-04
phenotype_num_taxa Fitness sharing Tournament 240 240 49804.5 0.00000 0.0000 **** 5446.667 Fitness sharing, Tournament 2 5 p < 1e-04
phenotype_num_taxa Lexicase Random 240 240 46856.0 0.00000 0.0000 **** 6091.111 Lexicase, Random 3 4 p < 1e-04
phenotype_num_taxa Lexicase Tournament 240 240 41709.5 0.00000 0.0000 **** 6735.556 Lexicase , Tournament 3 5 p < 1e-04
phenotype_num_taxa Random Tournament 240 240 23410.5 0.00039 0.0039 ** 7380.000 Random , Tournament 4 5 p = 0.0039

3.5 Relationship between phenotypic and phylogenetic diversity

ggplot(
    final_data,
    aes(
        y=phenotype_num_taxa,
        x=mean_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Phenotypic richness"
  ) +
  scale_x_continuous(
        name="Mean pairwise distance"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

3.6 Relationship between diversity and success

3.6.1 Earlier in run

ggplot(
    data %>% filter(generation==500),
    aes(
        y=max_performance,
        x=mean_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Average trait performance"
  ) +
  scale_x_continuous(
        name="Mean pairwise distance"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    data %>% filter(generation==500),
    aes(
        y=max_performance,
        x=phenotype_num_taxa,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Average trait performance"
  ) +
  scale_x_continuous(
        name="Phenotypic richness"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

phylogney_vs_performance <- ggplot(
    data %>% filter(generation==1000),
    aes(
        y=max_performance,
        x=mean_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Average trait performance"
  ) +
  scale_x_continuous(
        name="Mean pairwise distance"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")
  
phylogney_vs_performance

ggplot(
    data %>% filter(generation==1000),
    aes(
        y=max_performance,
        x=phenotype_num_taxa,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Average trait performance"
  ) +
  scale_x_continuous(
        name="Phenotypic richness"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

3.6.2 End of run

ggplot(
    final_data,
    aes(
        y=max_performance,
        x=mean_phenotype_pairwise_distance,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Average trait performance"
  ) +
  scale_x_continuous(
        name="Mean pairwise distance"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

ggplot(
    final_data,
    aes(
        y=max_performance,
        x=phenotype_num_taxa,
        color=selection_name,
        fill=selection_name
    )
  ) +
  geom_point() +
    scale_y_continuous(
        name="Average trait performance"
  ) +
  scale_x_continuous(
        name="Phenotypic richness"
  ) + 
  facet_wrap(
      ~selection_name*problem_name, ncol=4, scales="free"
  ) + 
  stat_smooth(
    method="lm"
  ) + 
  stat_cor(
    method="spearman", cor.coef.name = "rho", color="black"
  ) +
  theme(legend.position = "none")

3.7 Causality analysis

3.7.1 Setup

First let’s define a function we’ll use to calculate and output significance and effect size for these results:

transfer_entropy_stats <- function(res) {
  stat.test <- res %>%
    group_by(selection_name, problem_name, offset) %>%
    filter(max(value) > 0) %>% # Sorting networks have some values of 0, which won't work for Wilcox test
    wilcox_test(value ~ Type) %>%
    adjust_pvalue(method = "bonferroni") %>%
    add_significance() 
  stat.test$label <- mapply(p_label,stat.test$p.adj)
  
  # Calculate effect sizes for these differences
  effect_sizes <- res %>%
    group_by(selection_name, problem_name, offset) %>%
    filter(max(value) > 0) %>%
    wilcox_effsize(value ~ Type)
  
  stat.test$effsize <- effect_sizes$effsize
  stat.test$magnitude <- effect_sizes$magnitude
  
  stat.test %>%
    kbl() %>%
    kable_styling(
      bootstrap_options = c(
        "striped",
        "hover",
        "condensed",
        "responsive"
      )
    ) %>%
    scroll_box(width="100%")
}

3.7.2 Transfer entropy from diversity to fitness

3.7.2.1 Max pairwise distance vs. phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  fit_phylo_10 = condinformation(discretize(max_performance), discretize(lag(max_phenotype_pairwise_distance, 1)), discretize(lag(max_performance, 1))),
  fit_phylo_100 = condinformation(discretize(max_performance), discretize(lag(max_phenotype_pairwise_distance, 10)), discretize(lag(max_performance, 10))),
  fit_phylo_1000 = condinformation(discretize(max_performance), discretize(lag(max_phenotype_pairwise_distance, 100)), discretize(lag(max_performance, 100))),
    fit_pheno_10 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 1)), discretize(lag(max_performance, 1))),
      fit_pheno_100 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 10)), discretize(lag(max_performance, 10))),
      fit_pheno_1000 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 100)), discretize(lag(max_performance, 100)))
      )

res <- res %>% pivot_longer(cols=contains("o_10"))
res$offset <- str_extract(res$name, "[:digit:]*$")
res$Type <- case_when(str_detect(res$name, "phylo") ~ "Phylogenetic", TRUE ~ "Phenotypic")

ggplot(
  res %>% filter(str_detect(name, "fit_ph*")), 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_x_discrete("Lag") + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("") + 
  theme(legend.position = "bottom")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic Phylogenetic 60 60 1511.0 1.30e-01 1.0000000 ns p = 1 0.1384694 small
Eco-EA Count Odds 100 value Phenotypic Phylogenetic 60 60 701.0 0.00e+00 0.0000005 **** p < 1e-04 0.5265671 large
Eco-EA Count Odds 1000 value Phenotypic Phylogenetic 60 60 979.0 1.66e-05 0.0009794 *** p = 0.0009794 0.3933818 moderate
Eco-EA Logic-9 10 value Phenotypic Phylogenetic 60 60 1741.0 7.59e-01 1.0000000 ns p = 1 0.0282693 small
Eco-EA Logic-9 100 value Phenotypic Phylogenetic 60 60 1845.0 8.15e-01 1.0000000 ns p = 1 0.0215614 small
Eco-EA Logic-9 1000 value Phenotypic Phylogenetic 60 60 1801.0 9.98e-01 1.0000000 ns p = 1 0.0004811 small
Eco-EA NK Landscape 10 value Phenotypic Phylogenetic 60 60 1639.5 4.01e-01 1.0000000 ns p = 1 0.0769010 small
Eco-EA NK Landscape 100 value Phenotypic Phylogenetic 60 60 1740.5 7.57e-01 1.0000000 ns p = 1 0.0285085 small
Eco-EA NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1897.5 6.11e-01 1.0000000 ns p = 1 0.0467184 small
Eco-EA Sorting network 10 value Phenotypic Phylogenetic 60 60 2235.5 2.24e-02 1.0000000 ns p = 1 0.2086678 small
Eco-EA Sorting network 100 value Phenotypic Phylogenetic 60 60 1464.5 7.87e-02 1.0000000 ns p = 1 0.1607519 small
Eco-EA Sorting network 1000 value Phenotypic Phylogenetic 60 60 1771.0 5.80e-01 1.0000000 ns p = 1 0.0513765 small
Fitness sharing Count Odds 10 value Phenotypic Phylogenetic 60 60 1721.0 6.80e-01 1.0000000 ns p = 1 0.0378515 small
Fitness sharing Count Odds 100 value Phenotypic Phylogenetic 60 60 1272.0 5.63e-03 0.3321700 ns p = 0.33217 0.2529822 small
Fitness sharing Count Odds 1000 value Phenotypic Phylogenetic 60 60 1709.0 6.35e-01 1.0000000 ns p = 1 0.0436011 small
Fitness sharing Logic-9 10 value Phenotypic Phylogenetic 60 60 1620.0 3.46e-01 1.0000000 ns p = 1 0.0862454 small
Fitness sharing Logic-9 100 value Phenotypic Phylogenetic 60 60 1411.0 4.14e-02 1.0000000 ns p = 1 0.1863860 small
Fitness sharing Logic-9 1000 value Phenotypic Phylogenetic 60 60 1595.0 2.81e-01 1.0000000 ns p = 1 0.0986687 small
Fitness sharing NK Landscape 10 value Phenotypic Phylogenetic 60 60 1637.0 3.94e-01 1.0000000 ns p = 1 0.0780987 small
Fitness sharing NK Landscape 100 value Phenotypic Phylogenetic 60 60 807.0 2.00e-07 0.0000112 **** p < 1e-04 0.4757790 moderate
Fitness sharing NK Landscape 1000 value Phenotypic Phylogenetic 60 60 822.0 3.00e-07 0.0000171 **** p < 1e-04 0.4685921 moderate
Fitness sharing Sorting network 10 value Phenotypic Phylogenetic 60 60 796.0 1.00e-07 0.0000082 **** p < 1e-04 0.4810495 moderate
Fitness sharing Sorting network 100 value Phenotypic Phylogenetic 60 60 393.0 0.00e+00 0.0000000 **** p < 1e-04 0.6741401 large
Fitness sharing Sorting network 1000 value Phenotypic Phylogenetic 60 60 1807.0 9.73e-01 1.0000000 ns p = 1 0.0033539 small
Lexicase Count Odds 10 value Phenotypic Phylogenetic 60 60 1826.0 8.94e-01 1.0000000 ns p = 1 0.0124575 small
Lexicase Count Odds 100 value Phenotypic Phylogenetic 60 60 531.0 0.00e+00 0.0000000 **** p < 1e-04 0.6080198 large
Lexicase Count Odds 1000 value Phenotypic Phylogenetic 60 60 1092.0 2.04e-04 0.0120360
p = 0.012036 0.3392285 moderate
Lexicase Logic-9 10 value Phenotypic Phylogenetic 60 60 2031.5 2.25e-01 1.0000000 ns p = 1 0.1109195 small
Lexicase Logic-9 100 value Phenotypic Phylogenetic 60 60 1519.0 1.41e-01 1.0000000 ns p = 1 0.1346373 small
Lexicase Logic-9 1000 value Phenotypic Phylogenetic 60 60 1863.0 7.41e-01 1.0000000 ns p = 1 0.0303585 small
Lexicase NK Landscape 10 value Phenotypic Phylogenetic 60 60 1816.0 9.35e-01 1.0000000 ns p = 1 0.0077152 small
Lexicase NK Landscape 100 value Phenotypic Phylogenetic 60 60 1391.0 3.09e-02 1.0000000 ns p = 1 0.1972206 small
Lexicase NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1218.0 2.13e-03 0.1256700 ns p = 0.12567 0.2806415 small
Lexicase Sorting network 10 value Phenotypic Phylogenetic 60 60 1819.5 8.98e-01 1.0000000 ns p = 1 0.0120055 small
Lexicase Sorting network 100 value Phenotypic Phylogenetic 60 60 1815.0 9.22e-01 1.0000000 ns p = 1 0.0092350 small
Random Count Odds 10 value Phenotypic Phylogenetic 60 60 1970.0 3.74e-01 1.0000000 ns p = 1 0.0814526 small
Random Count Odds 100 value Phenotypic Phylogenetic 60 60 2096.0 1.21e-01 1.0000000 ns p = 1 0.1418234 small
Random Count Odds 1000 value Phenotypic Phylogenetic 60 60 1168.0 9.18e-04 0.0541620 ns p = 0.054162 0.3028120 moderate
Random Logic-9 10 value Phenotypic Phylogenetic 60 60 1920.0 4.79e-01 1.0000000 ns p = 1 0.0649373 small
Random Logic-9 100 value Phenotypic Phylogenetic 60 60 1857.5 7.35e-01 1.0000000 ns p = 1 0.0311145 small
Random Logic-9 1000 value Phenotypic Phylogenetic 60 60 1750.5 7.25e-01 1.0000000 ns p = 1 0.0324395 small
Random NK Landscape 10 value Phenotypic Phylogenetic 60 60 1613.0 3.28e-01 1.0000000 ns p = 1 0.0895979 small
Random NK Landscape 100 value Phenotypic Phylogenetic 60 60 1281.0 6.50e-03 0.3835000 ns p = 0.3835 0.2486700 small
Random NK Landscape 1000 value Phenotypic Phylogenetic 60 60 644.0 0.00e+00 0.0000001 **** p < 1e-04 0.5538777 large
Random Sorting network 10 value Phenotypic Phylogenetic 60 60 2056.0 1.80e-01 1.0000000 ns p = 1 0.1226580 small
Random Sorting network 100 value Phenotypic Phylogenetic 60 60 1271.0 5.54e-03 0.3268600 ns p = 0.32686 0.2534613 small
Random Sorting network 1000 value Phenotypic Phylogenetic 60 60 1369.0 2.38e-02 1.0000000 ns p = 1 0.2065063 small
Tournament Count Odds 10 value Phenotypic Phylogenetic 60 60 1577.0 2.43e-01 1.0000000 ns p = 1 0.1068467 small
Tournament Count Odds 100 value Phenotypic Phylogenetic 60 60 1376.0 2.62e-02 1.0000000 ns p = 1 0.2031524 small
Tournament Count Odds 1000 value Phenotypic Phylogenetic 60 60 1811.0 9.56e-01 1.0000000 ns p = 1 0.0052710 small
Tournament Logic-9 10 value Phenotypic Phylogenetic 60 60 2015.0 2.60e-01 1.0000000 ns p = 1 0.1030154 small
Tournament Logic-9 100 value Phenotypic Phylogenetic 60 60 1965.0 3.88e-01 1.0000000 ns p = 1 0.0790583 small
Tournament Logic-9 1000 value Phenotypic Phylogenetic 60 60 1983.0 3.33e-01 1.0000000 ns p = 1 0.0886950 small
Tournament NK Landscape 10 value Phenotypic Phylogenetic 60 60 1811.0 9.26e-01 1.0000000 ns p = 1 0.0089208 small
Tournament NK Landscape 100 value Phenotypic Phylogenetic 60 60 1802.0 9.89e-01 1.0000000 ns p = 1 0.0016220 small
Tournament NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1800.0 1.00e+00 1.0000000 ns p = 1 0.0000000 small
Tournament Sorting network 10 value Phenotypic Phylogenetic 60 60 2073.0 1.53e-01 1.0000000 ns p = 1 0.1308040 small
Tournament Sorting network 100 value Phenotypic Phylogenetic 60 60 1449.0 6.58e-02 1.0000000 ns p = 1 0.1681757 small
Tournament Sorting network 1000 value Phenotypic Phylogenetic 60 60 1996.5 2.60e-01 1.0000000 ns p = 1 0.1031163 small

3.7.2.2 Mean pairwise distance vs. phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  fit_phylo_10 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_pairwise_distance, 1)), discretize(lag(max_performance, 1))),
  fit_phylo_100 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_pairwise_distance, 10)), discretize(lag(max_performance, 10))),
  fit_phylo_1000 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_pairwise_distance, 100)), discretize(lag(max_performance, 100))),
    fit_pheno_10 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 1)), discretize(lag(max_performance, 1))),
      fit_pheno_100 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 10)), discretize(lag(max_performance, 10))),
      fit_pheno_1000 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 100)), discretize(lag(max_performance, 100)))
      )

res <- res %>% pivot_longer(cols=contains("o_10"))
res$offset <- str_extract(res$name, "[:digit:]*$")
res$Type <- case_when(str_detect(res$name, "phylo") ~ "Phylogenetic", TRUE ~ "Phenotypic")

ggplot(
  res %>% filter(str_detect(name, "fit_ph*")), 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_x_discrete("Lag") + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("") + 
  theme(legend.position = "bottom")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic Phylogenetic 60 60 1732.0 7.23e-01 1.0000000 ns p = 1 0.0325810 small
Eco-EA Count Odds 100 value Phenotypic Phylogenetic 60 60 943.0 6.90e-06 0.0004095 *** p = 0.00040946 0.4106170 moderate
Eco-EA Count Odds 1000 value Phenotypic Phylogenetic 60 60 1289.0 7.37e-03 0.4348300 ns p = 0.43483 0.2448608 small
Eco-EA Logic-9 10 value Phenotypic Phylogenetic 60 60 1743.0 7.67e-01 1.0000000 ns p = 1 0.0273111 small
Eco-EA Logic-9 100 value Phenotypic Phylogenetic 60 60 1704.0 6.16e-01 1.0000000 ns p = 1 0.0459976 small
Eco-EA Logic-9 1000 value Phenotypic Phylogenetic 60 60 1709.0 6.33e-01 1.0000000 ns p = 1 0.0437763 small
Eco-EA NK Landscape 10 value Phenotypic Phylogenetic 60 60 1526.5 1.52e-01 1.0000000 ns p = 1 0.1310431 small
Eco-EA NK Landscape 100 value Phenotypic Phylogenetic 60 60 1589.5 2.70e-01 1.0000000 ns p = 1 0.1008577 small
Eco-EA NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1900.0 6.01e-01 1.0000000 ns p = 1 0.0479180 small
Eco-EA Sorting network 10 value Phenotypic Phylogenetic 60 60 2104.0 1.11e-01 1.0000000 ns p = 1 0.1456605 small
Eco-EA Sorting network 100 value Phenotypic Phylogenetic 60 60 1742.5 7.65e-01 1.0000000 ns p = 1 0.0275502 small
Eco-EA Sorting network 1000 value Phenotypic Phylogenetic 60 60 1770.0 5.67e-01 1.0000000 ns p = 1 0.0531481 small
Fitness sharing Count Odds 10 value Phenotypic Phylogenetic 60 60 1699.0 5.98e-01 1.0000000 ns p = 1 0.0483924 small
Fitness sharing Count Odds 100 value Phenotypic Phylogenetic 60 60 1311.0 1.03e-02 0.6077000 ns p = 0.6077 0.2342960 small
Fitness sharing Count Odds 1000 value Phenotypic Phylogenetic 60 60 1926.0 5.10e-01 1.0000000 ns p = 1 0.0603708 small
Fitness sharing Logic-9 10 value Phenotypic Phylogenetic 60 60 1559.0 2.07e-01 1.0000000 ns p = 1 0.1154731 small
Fitness sharing Logic-9 100 value Phenotypic Phylogenetic 60 60 1402.0 3.69e-02 1.0000000 ns p = 1 0.1906982 small
Fitness sharing Logic-9 1000 value Phenotypic Phylogenetic 60 60 1531.0 1.57e-01 1.0000000 ns p = 1 0.1292849 small
Fitness sharing NK Landscape 10 value Phenotypic Phylogenetic 60 60 1550.0 1.90e-01 1.0000000 ns p = 1 0.1197832 small
Fitness sharing NK Landscape 100 value Phenotypic Phylogenetic 60 60 823.0 3.00e-07 0.0000175 **** p < 1e-04 0.4681129 moderate
Fitness sharing NK Landscape 1000 value Phenotypic Phylogenetic 60 60 642.0 0.00e+00 0.0000001 **** p < 1e-04 0.5548360 large
Fitness sharing Sorting network 10 value Phenotypic Phylogenetic 60 60 949.0 8.00e-06 0.0004749 *** p = 0.00047495 0.4077422 moderate
Fitness sharing Sorting network 100 value Phenotypic Phylogenetic 60 60 373.0 0.00e+00 0.0000000 **** p < 1e-04 0.6837228 large
Fitness sharing Sorting network 1000 value Phenotypic Phylogenetic 60 60 1885.0 6.57e-01 1.0000000 ns p = 1 0.0407263 small
Lexicase Count Odds 10 value Phenotypic Phylogenetic 60 60 1651.0 4.36e-01 1.0000000 ns p = 1 0.0713908 small
Lexicase Count Odds 100 value Phenotypic Phylogenetic 60 60 590.0 0.00e+00 0.0000000 **** p < 1e-04 0.5797509 large
Lexicase Count Odds 1000 value Phenotypic Phylogenetic 60 60 1166.0 8.84e-04 0.0521560 ns p = 0.052156 0.3037724 moderate
Lexicase Logic-9 10 value Phenotypic Phylogenetic 60 60 1879.5 6.78e-01 1.0000000 ns p = 1 0.0380911 small
Lexicase Logic-9 100 value Phenotypic Phylogenetic 60 60 1354.5 1.95e-02 1.0000000 ns p = 1 0.2134541 small
Lexicase Logic-9 1000 value Phenotypic Phylogenetic 60 60 1748.0 7.86e-01 1.0000000 ns p = 1 0.0250150 small
Lexicase NK Landscape 10 value Phenotypic Phylogenetic 60 60 1790.0 9.60e-01 1.0000000 ns p = 1 0.0048220 small
Lexicase NK Landscape 100 value Phenotypic Phylogenetic 60 60 1409.0 3.91e-02 1.0000000 ns p = 1 0.1885410 small
Lexicase NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1231.0 2.67e-03 0.1575300 ns p = 0.15753 0.2743729 small
Lexicase Sorting network 10 value Phenotypic Phylogenetic 60 60 1821.0 8.90e-01 1.0000000 ns p = 1 0.0129293 small
Lexicase Sorting network 100 value Phenotypic Phylogenetic 60 60 1831.0 8.37e-01 1.0000000 ns p = 1 0.0190856 small
Random Count Odds 10 value Phenotypic Phylogenetic 60 60 1781.0 9.23e-01 1.0000000 ns p = 1 0.0091035 small
Random Count Odds 100 value Phenotypic Phylogenetic 60 60 2026.0 2.37e-01 1.0000000 ns p = 1 0.1082841 small
Random Count Odds 1000 value Phenotypic Phylogenetic 60 60 1088.0 1.88e-04 0.0110920
p = 0.011092 0.3411427 moderate
Random Logic-9 10 value Phenotypic Phylogenetic 60 60 1772.5 8.73e-01 1.0000000 ns p = 1 0.0148811 small
Random Logic-9 100 value Phenotypic Phylogenetic 60 60 1799.0 9.98e-01 1.0000000 ns p = 1 0.0005411 small
Random Logic-9 1000 value Phenotypic Phylogenetic 60 60 1746.5 7.04e-01 1.0000000 ns p = 1 0.0350608 small
Random NK Landscape 10 value Phenotypic Phylogenetic 60 60 1490.0 1.04e-01 1.0000000 ns p = 1 0.1485312 small
Random NK Landscape 100 value Phenotypic Phylogenetic 60 60 1168.0 9.18e-04 0.0541620 ns p = 0.054162 0.3028120 moderate
Random NK Landscape 1000 value Phenotypic Phylogenetic 60 60 518.0 0.00e+00 0.0000000 **** p < 1e-04 0.6142485 large
Random Sorting network 10 value Phenotypic Phylogenetic 60 60 1918.0 5.37e-01 1.0000000 ns p = 1 0.0565377 small
Random Sorting network 100 value Phenotypic Phylogenetic 60 60 1188.0 1.33e-03 0.0784700 ns p = 0.07847 0.2932294 small
Random Sorting network 1000 value Phenotypic Phylogenetic 60 60 1339.0 1.56e-02 0.9204000 ns p = 0.9204 0.2208803 small
Tournament Count Odds 10 value Phenotypic Phylogenetic 60 60 1539.0 1.72e-01 1.0000000 ns p = 1 0.1250537 small
Tournament Count Odds 100 value Phenotypic Phylogenetic 60 60 1188.0 1.33e-03 0.0784700 ns p = 0.07847 0.2932294 small
Tournament Count Odds 1000 value Phenotypic Phylogenetic 60 60 1789.5 9.58e-01 1.0000000 ns p = 1 0.0050316 small
Tournament Logic-9 10 value Phenotypic Phylogenetic 60 60 1906.0 5.80e-01 1.0000000 ns p = 1 0.0507890 small
Tournament Logic-9 100 value Phenotypic Phylogenetic 60 60 1789.0 9.56e-01 1.0000000 ns p = 1 0.0052706 small
Tournament Logic-9 1000 value Phenotypic Phylogenetic 60 60 1943.0 4.50e-01 1.0000000 ns p = 1 0.0691744 small
Tournament NK Landscape 10 value Phenotypic Phylogenetic 60 60 1798.0 9.89e-01 1.0000000 ns p = 1 0.0016220 small
Tournament NK Landscape 100 value Phenotypic Phylogenetic 60 60 1783.0 8.83e-01 1.0000000 ns p = 1 0.0137867 small
Tournament NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1784.0 8.90e-01 1.0000000 ns p = 1 0.0129757 small
Tournament Sorting network 10 value Phenotypic Phylogenetic 60 60 1734.5 7.33e-01 1.0000000 ns p = 1 0.0313834 small
Tournament Sorting network 100 value Phenotypic Phylogenetic 60 60 1161.0 8.04e-04 0.0474360
p = 0.047436 0.3061660 moderate
Tournament Sorting network 1000 value Phenotypic Phylogenetic 60 60 2123.0 6.00e-02 1.0000000 ns p = 1 0.1719646 small

3.7.2.3 Mean pairwise distance vs. phenotypic Shannon diversity

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  fit_phylo_10 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_pairwise_distance, 1)), discretize(lag(max_performance, 1))),
  fit_phylo_100 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_pairwise_distance, 10)), discretize(lag(max_performance, 10))),
  fit_phylo_1000 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_pairwise_distance, 100)), discretize(lag(max_performance, 100))),
    fit_pheno_10 = condinformation(discretize(max_performance), discretize(lag(phenotype_diversity, 1)), discretize(lag(max_performance, 1))),
      fit_pheno_100 = condinformation(discretize(max_performance), discretize(lag(phenotype_diversity, 10)), discretize(lag(max_performance, 10))),
      fit_pheno_1000 = condinformation(discretize(max_performance), discretize(lag(phenotype_diversity, 100)), discretize(lag(max_performance, 100)))
      )

res <- res %>% pivot_longer(cols=contains("o_10"))
res$offset <- str_extract(res$name, "[:digit:]*$")
res$Type <- case_when(str_detect(res$name, "phylo") ~ "Phylogenetic", TRUE ~ "Phenotypic")

ggplot(
  res %>% filter(str_detect(name, "fit_ph*")), 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_x_discrete("Lag") + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("") + 
  theme(legend.position = "bottom")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic Phylogenetic 60 60 1823.0 9.06e-01 1.0000000 ns p = 1 0.0110201 small
Eco-EA Count Odds 100 value Phenotypic Phylogenetic 60 60 1164.0 8.51e-04 0.0502090 ns p = 0.050209 0.3047286 moderate
Eco-EA Count Odds 1000 value Phenotypic Phylogenetic 60 60 1192.5 1.44e-03 0.0849600 ns p = 0.08496 0.2911021 small
Eco-EA Logic-9 10 value Phenotypic Phylogenetic 60 60 1691.0 5.69e-01 1.0000000 ns p = 1 0.0522264 small
Eco-EA Logic-9 100 value Phenotypic Phylogenetic 60 60 1648.0 4.27e-01 1.0000000 ns p = 1 0.0728295 small
Eco-EA Logic-9 1000 value Phenotypic Phylogenetic 60 60 1669.0 4.91e-01 1.0000000 ns p = 1 0.0630876 small
Eco-EA NK Landscape 10 value Phenotypic Phylogenetic 60 60 1749.5 7.93e-01 1.0000000 ns p = 1 0.0241963 small
Eco-EA NK Landscape 100 value Phenotypic Phylogenetic 60 60 1640.5 4.04e-01 1.0000000 ns p = 1 0.0764218 small
Eco-EA NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1642.0 4.08e-01 1.0000000 ns p = 1 0.0757076 small
Eco-EA Sorting network 10 value Phenotypic Phylogenetic 60 60 1861.5 7.49e-01 1.0000000 ns p = 1 0.0294693 small
Eco-EA Sorting network 100 value Phenotypic Phylogenetic 60 60 1853.5 7.81e-01 1.0000000 ns p = 1 0.0256339 small
Eco-EA Sorting network 1000 value Phenotypic Phylogenetic 60 60 1770.0 5.67e-01 1.0000000 ns p = 1 0.0531481 small
Fitness sharing Count Odds 10 value Phenotypic Phylogenetic 60 60 1568.0 2.24e-01 1.0000000 ns p = 1 0.1111589 small
Fitness sharing Count Odds 100 value Phenotypic Phylogenetic 60 60 1351.0 1.86e-02 1.0000000 ns p = 1 0.2151307 small
Fitness sharing Count Odds 1000 value Phenotypic Phylogenetic 60 60 1950.0 4.33e-01 1.0000000 ns p = 1 0.0718699 small
Fitness sharing Logic-9 10 value Phenotypic Phylogenetic 60 60 1604.0 3.05e-01 1.0000000 ns p = 1 0.0939117 small
Fitness sharing Logic-9 100 value Phenotypic Phylogenetic 60 60 1437.0 5.71e-02 1.0000000 ns p = 1 0.1739283 small
Fitness sharing Logic-9 1000 value Phenotypic Phylogenetic 60 60 1602.0 2.99e-01 1.0000000 ns p = 1 0.0950882 small
Fitness sharing NK Landscape 10 value Phenotypic Phylogenetic 60 60 1528.0 1.54e-01 1.0000000 ns p = 1 0.1303242 small
Fitness sharing NK Landscape 100 value Phenotypic Phylogenetic 60 60 747.0 0.00e+00 0.0000020 **** p < 1e-04 0.5045270 large
Fitness sharing NK Landscape 1000 value Phenotypic Phylogenetic 60 60 694.0 0.00e+00 0.0000004 **** p < 1e-04 0.5299211 large
Fitness sharing Sorting network 10 value Phenotypic Phylogenetic 60 60 901.0 2.40e-06 0.0001422 *** p = 0.00014219 0.4307405 moderate
Fitness sharing Sorting network 100 value Phenotypic Phylogenetic 60 60 339.0 0.00e+00 0.0000000 **** p < 1e-04 0.7000133 large
Fitness sharing Sorting network 1000 value Phenotypic Phylogenetic 60 60 1773.0 8.89e-01 1.0000000 ns p = 1 0.0129366 small
Lexicase Count Odds 10 value Phenotypic Phylogenetic 60 60 1517.0 1.38e-01 1.0000000 ns p = 1 0.1355946 small
Lexicase Count Odds 100 value Phenotypic Phylogenetic 60 60 569.0 0.00e+00 0.0000000 **** p < 1e-04 0.5898127 large
Lexicase Count Odds 1000 value Phenotypic Phylogenetic 60 60 1134.0 4.78e-04 0.0282020
p = 0.028202 0.3191031 moderate
Lexicase Logic-9 10 value Phenotypic Phylogenetic 60 60 1754.5 8.13e-01 1.0000000 ns p = 1 0.0218006 small
Lexicase Logic-9 100 value Phenotypic Phylogenetic 60 60 1458.5 7.35e-02 1.0000000 ns p = 1 0.1636242 small
Lexicase Logic-9 1000 value Phenotypic Phylogenetic 60 60 1758.0 8.27e-01 1.0000000 ns p = 1 0.0202044 small
Lexicase NK Landscape 10 value Phenotypic Phylogenetic 60 60 1817.0 9.31e-01 1.0000000 ns p = 1 0.0081974 small
Lexicase NK Landscape 100 value Phenotypic Phylogenetic 60 60 1435.0 5.42e-02 1.0000000 ns p = 1 0.1760037 small
Lexicase NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1244.0 3.34e-03 0.1970600 ns p = 0.19706 0.2681043 small
Lexicase Sorting network 10 value Phenotypic Phylogenetic 60 60 1779.5 8.93e-01 1.0000000 ns p = 1 0.0126213 small
Lexicase Sorting network 100 value Phenotypic Phylogenetic 60 60 1837.0 8.06e-01 1.0000000 ns p = 1 0.0227797 small
Random Count Odds 10 value Phenotypic Phylogenetic 60 60 1754.0 8.11e-01 1.0000000 ns p = 1 0.0220401 small
Random Count Odds 100 value Phenotypic Phylogenetic 60 60 2145.0 7.06e-02 1.0000000 ns p = 1 0.1653009 small
Random Count Odds 1000 value Phenotypic Phylogenetic 60 60 971.0 1.37e-05 0.0008083 *** p = 0.0008083 0.3972012 moderate
Random Logic-9 10 value Phenotypic Phylogenetic 60 60 1896.5 5.69e-01 1.0000000 ns p = 1 0.0522211 small
Random Logic-9 100 value Phenotypic Phylogenetic 60 60 1839.0 8.19e-01 1.0000000 ns p = 1 0.0211053 small
Random Logic-9 1000 value Phenotypic Phylogenetic 60 60 1830.0 8.35e-01 1.0000000 ns p = 1 0.0193927 small
Random NK Landscape 10 value Phenotypic Phylogenetic 60 60 1437.0 5.71e-02 1.0000000 ns p = 1 0.1739253 small
Random NK Landscape 100 value Phenotypic Phylogenetic 60 60 1185.0 1.26e-03 0.0743400 ns p = 0.07434 0.2946668 small
Random NK Landscape 1000 value Phenotypic Phylogenetic 60 60 598.0 0.00e+00 0.0000000 **** p < 1e-04 0.5759178 large
Random Sorting network 10 value Phenotypic Phylogenetic 60 60 1731.0 7.19e-01 1.0000000 ns p = 1 0.0330602 small
Random Sorting network 100 value Phenotypic Phylogenetic 60 60 1441.0 5.99e-02 1.0000000 ns p = 1 0.1720087 small
Random Sorting network 1000 value Phenotypic Phylogenetic 60 60 1324.0 1.26e-02 0.7434000 ns p = 0.7434 0.2280673 small
Tournament Count Odds 10 value Phenotypic Phylogenetic 60 60 1574.5 2.38e-01 1.0000000 ns p = 1 0.1080447 small
Tournament Count Odds 100 value Phenotypic Phylogenetic 60 60 1441.0 5.99e-02 1.0000000 ns p = 1 0.1720087 small
Tournament Count Odds 1000 value Phenotypic Phylogenetic 60 60 1925.0 5.13e-01 1.0000000 ns p = 1 0.0599041 small
Tournament Logic-9 10 value Phenotypic Phylogenetic 60 60 1823.5 9.04e-01 1.0000000 ns p = 1 0.0112598 small
Tournament Logic-9 100 value Phenotypic Phylogenetic 60 60 1827.0 8.89e-01 1.0000000 ns p = 1 0.0129368 small
Tournament Logic-9 1000 value Phenotypic Phylogenetic 60 60 1898.0 6.05e-01 1.0000000 ns p = 1 0.0474506 small
Tournament NK Landscape 10 value Phenotypic Phylogenetic 60 60 1794.0 9.61e-01 1.0000000 ns p = 1 0.0048659 small
Tournament NK Landscape 100 value Phenotypic Phylogenetic 60 60 1802.0 9.89e-01 1.0000000 ns p = 1 0.0016220 small
Tournament NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1800.0 1.00e+00 1.0000000 ns p = 1 0.0000000 small
Tournament Sorting network 10 value Phenotypic Phylogenetic 60 60 1784.5 9.37e-01 1.0000000 ns p = 1 0.0074266 small
Tournament Sorting network 100 value Phenotypic Phylogenetic 60 60 1680.0 5.31e-01 1.0000000 ns p = 1 0.0574960 small
Tournament Sorting network 1000 value Phenotypic Phylogenetic 60 60 1885.0 6.18e-01 1.0000000 ns p = 1 0.0457398 small

3.7.2.4 Mean evolutionary distinctiveness vs. phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  fit_phylo_10 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_evolutionary_distinctiveness, 1)), discretize(lag(max_performance, 1))),
  fit_phylo_100 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_evolutionary_distinctiveness, 10)), discretize(lag(max_performance, 10))),
  fit_phylo_1000 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_evolutionary_distinctiveness, 100)), discretize(lag(max_performance, 100))),
    fit_pheno_10 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 1)), discretize(lag(max_performance, 1))),
      fit_pheno_100 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 10)), discretize(lag(max_performance, 10))),
      fit_pheno_1000 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 100)), discretize(lag(max_performance, 100)))
      )

res <- res %>% pivot_longer(cols=contains("o_10"))
res$offset <- str_extract(res$name, "[:digit:]*$")
res$Type <- case_when(str_detect(res$name, "phylo") ~ "Phylogenetic", TRUE ~ "Phenotypic")

ggplot(
  res %>% filter(str_detect(name, "fit_ph*")), 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_x_discrete("Lag") + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("") + 
  theme(legend.position = "bottom")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic Phylogenetic 60 60 1664.0 4.77e-01 1.0000000 ns p = 1 0.0651621 small
Eco-EA Count Odds 100 value Phenotypic Phylogenetic 60 60 1046.0 7.66e-05 0.0045194 ** p = 0.0045194 0.3612663 moderate
Eco-EA Count Odds 1000 value Phenotypic Phylogenetic 60 60 1209.5 1.96e-03 0.1156400 ns p = 0.11564 0.2829452 small
Eco-EA Logic-9 10 value Phenotypic Phylogenetic 60 60 1848.0 8.03e-01 1.0000000 ns p = 1 0.0229988 small
Eco-EA Logic-9 100 value Phenotypic Phylogenetic 60 60 1503.0 1.20e-01 1.0000000 ns p = 1 0.1423050 small
Eco-EA Logic-9 1000 value Phenotypic Phylogenetic 60 60 1481.0 9.33e-02 1.0000000 ns p = 1 0.1534575 small
Eco-EA NK Landscape 10 value Phenotypic Phylogenetic 60 60 1473.5 8.71e-02 1.0000000 ns p = 1 0.1564372 small
Eco-EA NK Landscape 100 value Phenotypic Phylogenetic 60 60 1550.5 1.91e-01 1.0000000 ns p = 1 0.1195439 small
Eco-EA NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1632.0 3.79e-01 1.0000000 ns p = 1 0.0804971 small
Eco-EA Sorting network 10 value Phenotypic Phylogenetic 60 60 1804.5 9.83e-01 1.0000000 ns p = 1 0.0021563 small
Eco-EA Sorting network 100 value Phenotypic Phylogenetic 60 60 1928.5 5.02e-01 1.0000000 ns p = 1 0.0615707 small
Eco-EA Sorting network 1000 value Phenotypic Phylogenetic 60 60 1770.0 5.67e-01 1.0000000 ns p = 1 0.0531481 small
Fitness sharing Count Odds 10 value Phenotypic Phylogenetic 60 60 1804.0 9.85e-01 1.0000000 ns p = 1 0.0019165 small
Fitness sharing Count Odds 100 value Phenotypic Phylogenetic 60 60 1624.0 3.57e-01 1.0000000 ns p = 1 0.0843274 small
Fitness sharing Count Odds 1000 value Phenotypic Phylogenetic 60 60 2030.0 2.28e-01 1.0000000 ns p = 1 0.1102006 small
Fitness sharing Logic-9 10 value Phenotypic Phylogenetic 60 60 1685.0 5.48e-01 1.0000000 ns p = 1 0.0551012 small
Fitness sharing Logic-9 100 value Phenotypic Phylogenetic 60 60 1527.0 1.53e-01 1.0000000 ns p = 1 0.1308056 small
Fitness sharing Logic-9 1000 value Phenotypic Phylogenetic 60 60 1513.0 1.31e-01 1.0000000 ns p = 1 0.1380636 small
Fitness sharing NK Landscape 10 value Phenotypic Phylogenetic 60 60 1531.0 1.59e-01 1.0000000 ns p = 1 0.1288868 small
Fitness sharing NK Landscape 100 value Phenotypic Phylogenetic 60 60 908.0 2.90e-06 0.0001699 *** p = 0.00016992 0.4273866 moderate
Fitness sharing NK Landscape 1000 value Phenotypic Phylogenetic 60 60 747.0 0.00e+00 0.0000020 **** p < 1e-04 0.5045270 large
Fitness sharing Sorting network 10 value Phenotypic Phylogenetic 60 60 908.0 2.90e-06 0.0001699 *** p = 0.00016992 0.4273866 moderate
Fitness sharing Sorting network 100 value Phenotypic Phylogenetic 60 60 1001.0 2.78e-05 0.0016402 ** p = 0.0016402 0.3828273 moderate
Fitness sharing Sorting network 1000 value Phenotypic Phylogenetic 60 60 2150.0 6.66e-02 1.0000000 ns p = 1 0.1676965 small
Lexicase Count Odds 10 value Phenotypic Phylogenetic 60 60 2178.0 4.76e-02 1.0000000 ns p = 1 0.1811123 small
Lexicase Count Odds 100 value Phenotypic Phylogenetic 60 60 832.0 4.00e-07 0.0000225 **** p < 1e-04 0.4638007 moderate
Lexicase Count Odds 1000 value Phenotypic Phylogenetic 60 60 1208.0 1.91e-03 0.1126900 ns p = 0.11269 0.2836487 small
Lexicase Logic-9 10 value Phenotypic Phylogenetic 60 60 1830.5 8.75e-01 1.0000000 ns p = 1 0.0146136 small
Lexicase Logic-9 100 value Phenotypic Phylogenetic 60 60 1315.5 1.11e-02 0.6549000 ns p = 0.6549 0.2321403 small
Lexicase Logic-9 1000 value Phenotypic Phylogenetic 60 60 1728.5 7.08e-01 1.0000000 ns p = 1 0.0344334 small
Lexicase NK Landscape 10 value Phenotypic Phylogenetic 60 60 1771.0 8.80e-01 1.0000000 ns p = 1 0.0139839 small
Lexicase NK Landscape 100 value Phenotypic Phylogenetic 60 60 1489.0 1.01e-01 1.0000000 ns p = 1 0.1499648 small
Lexicase NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1153.0 6.38e-04 0.0376420
p = 0.037642 0.3119846 moderate
Lexicase Sorting network 10 value Phenotypic Phylogenetic 60 60 1826.0 8.63e-01 1.0000000 ns p = 1 0.0160076 small
Lexicase Sorting network 100 value Phenotypic Phylogenetic 60 60 1812.0 9.38e-01 1.0000000 ns p = 1 0.0073881 small
Random Count Odds 10 value Phenotypic Phylogenetic 60 60 1742.0 7.63e-01 1.0000000 ns p = 1 0.0277897 small
Random Count Odds 100 value Phenotypic Phylogenetic 60 60 2052.0 1.87e-01 1.0000000 ns p = 1 0.1207415 small
Random Count Odds 1000 value Phenotypic Phylogenetic 60 60 1186.0 1.28e-03 0.0755200 ns p = 0.07552 0.2941876 small
Random Logic-9 10 value Phenotypic Phylogenetic 60 60 1711.0 6.00e-01 1.0000000 ns p = 1 0.0481649 small
Random Logic-9 100 value Phenotypic Phylogenetic 60 60 1821.0 9.03e-01 1.0000000 ns p = 1 0.0113645 small
Random Logic-9 1000 value Phenotypic Phylogenetic 60 60 1721.0 5.73e-01 1.0000000 ns p = 1 0.0517719 small
Random NK Landscape 10 value Phenotypic Phylogenetic 60 60 1539.0 1.72e-01 1.0000000 ns p = 1 0.1250537 small
Random NK Landscape 100 value Phenotypic Phylogenetic 60 60 1405.0 3.84e-02 1.0000000 ns p = 1 0.1892575 small
Random NK Landscape 1000 value Phenotypic Phylogenetic 60 60 457.0 0.00e+00 0.0000000 **** p < 1e-04 0.6434756 large
Random Sorting network 10 value Phenotypic Phylogenetic 60 60 2155.0 6.28e-02 1.0000000 ns p = 1 0.1700922 small
Random Sorting network 100 value Phenotypic Phylogenetic 60 60 1603.0 3.02e-01 1.0000000 ns p = 1 0.0943892 small
Random Sorting network 1000 value Phenotypic Phylogenetic 60 60 1947.0 4.42e-01 1.0000000 ns p = 1 0.0704325 small
Tournament Count Odds 10 value Phenotypic Phylogenetic 60 60 1484.0 9.77e-02 1.0000000 ns p = 1 0.1514060 small
Tournament Count Odds 100 value Phenotypic Phylogenetic 60 60 940.0 6.50e-06 0.0003806 *** p = 0.00038055 0.4120544 moderate
Tournament Count Odds 1000 value Phenotypic Phylogenetic 60 60 1298.5 8.55e-03 0.5044500 ns p = 0.50445 0.2402998 small
Tournament Logic-9 10 value Phenotypic Phylogenetic 60 60 2000.0 2.95e-01 1.0000000 ns p = 1 0.0958283 small
Tournament Logic-9 100 value Phenotypic Phylogenetic 60 60 1259.0 4.55e-03 0.2684500 ns p = 0.26845 0.2592154 small
Tournament Logic-9 1000 value Phenotypic Phylogenetic 60 60 1581.0 2.47e-01 1.0000000 ns p = 1 0.1059385 small
Tournament NK Landscape 10 value Phenotypic Phylogenetic 60 60 1791.0 9.40e-01 1.0000000 ns p = 1 0.0072988 small
Tournament NK Landscape 100 value Phenotypic Phylogenetic 60 60 1778.0 8.49e-01 1.0000000 ns p = 1 0.0178416 small
Tournament NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1776.0 8.35e-01 1.0000000 ns p = 1 0.0194636 small
Tournament Sorting network 10 value Phenotypic Phylogenetic 60 60 2019.5 2.50e-01 1.0000000 ns p = 1 0.1051704 small
Tournament Sorting network 100 value Phenotypic Phylogenetic 60 60 969.0 1.31e-05 0.0007729 *** p = 0.0007729 0.3981630 moderate
Tournament Sorting network 1000 value Phenotypic Phylogenetic 60 60 1745.5 7.60e-01 1.0000000 ns p = 1 0.0281237 small

3.7.2.5 Mean evolutionary distinctiveness vs. phenotypic Shannon diveristy

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  fit_phylo_10 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_evolutionary_distinctiveness, 1)), discretize(lag(max_performance, 1))),
  fit_phylo_100 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_evolutionary_distinctiveness, 10)), discretize(lag(max_performance, 10))),
  fit_phylo_1000 = condinformation(discretize(max_performance), discretize(lag(mean_phenotype_evolutionary_distinctiveness, 100)), discretize(lag(max_performance, 100))),
    fit_pheno_10 = condinformation(discretize(max_performance), discretize(lag(phenotype_diversity, 1)), discretize(lag(max_performance, 1))),
      fit_pheno_100 = condinformation(discretize(max_performance), discretize(lag(phenotype_diversity, 10)), discretize(lag(max_performance, 10))),
      fit_pheno_1000 = condinformation(discretize(max_performance), discretize(lag(phenotype_diversity, 100)), discretize(lag(max_performance, 100)))
      )

res <- res %>% pivot_longer(cols=contains("o_10"))
res$offset <- str_extract(res$name, "[:digit:]*$")
res$Type <- case_when(str_detect(res$name, "phylo") ~ "Phylogenetic", TRUE ~ "Phenotypic")

ggplot(
  res %>% filter(str_detect(name, "fit_ph*")), 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_x_discrete("Lag") + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("") + 
  theme(legend.position = "bottom")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic Phylogenetic 60 60 1721.0 6.80e-01 1.0000000 ns p = 1 0.0378515 small
Eco-EA Count Odds 100 value Phenotypic Phylogenetic 60 60 1288.0 7.26e-03 0.4283400 ns p = 0.42834 0.2453161 small
Eco-EA Count Odds 1000 value Phenotypic Phylogenetic 60 60 1076.5 1.48e-04 0.0087320 ** p = 0.008732 0.3466738 moderate
Eco-EA Logic-9 10 value Phenotypic Phylogenetic 60 60 1817.0 9.31e-01 1.0000000 ns p = 1 0.0081454 small
Eco-EA Logic-9 100 value Phenotypic Phylogenetic 60 60 1462.0 7.65e-02 1.0000000 ns p = 1 0.1619498 small
Eco-EA Logic-9 1000 value Phenotypic Phylogenetic 60 60 1459.0 7.24e-02 1.0000000 ns p = 1 0.1642205 small
Eco-EA NK Landscape 10 value Phenotypic Phylogenetic 60 60 1687.5 5.57e-01 1.0000000 ns p = 1 0.0539026 small
Eco-EA NK Landscape 100 value Phenotypic Phylogenetic 60 60 1645.5 4.19e-01 1.0000000 ns p = 1 0.0740262 small
Eco-EA NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1327.0 1.31e-02 0.7729000 ns p = 0.7729 0.2266338 small
Eco-EA Sorting network 10 value Phenotypic Phylogenetic 60 60 1764.0 8.52e-01 1.0000000 ns p = 1 0.0172527 small
Eco-EA Sorting network 100 value Phenotypic Phylogenetic 60 60 1999.5 2.96e-01 1.0000000 ns p = 1 0.0955910 small
Eco-EA Sorting network 1000 value Phenotypic Phylogenetic 60 60 1770.0 5.67e-01 1.0000000 ns p = 1 0.0531481 small
Fitness sharing Count Odds 10 value Phenotypic Phylogenetic 60 60 1709.0 6.35e-01 1.0000000 ns p = 1 0.0436011 small
Fitness sharing Count Odds 100 value Phenotypic Phylogenetic 60 60 1654.0 4.45e-01 1.0000000 ns p = 1 0.0699534 small
Fitness sharing Count Odds 1000 value Phenotypic Phylogenetic 60 60 2071.0 1.56e-01 1.0000000 ns p = 1 0.1298450 small
Fitness sharing Logic-9 10 value Phenotypic Phylogenetic 60 60 1779.0 9.14e-01 1.0000000 ns p = 1 0.0100620 small
Fitness sharing Logic-9 100 value Phenotypic Phylogenetic 60 60 1593.0 2.78e-01 1.0000000 ns p = 1 0.0991822 small
Fitness sharing Logic-9 1000 value Phenotypic Phylogenetic 60 60 1595.0 2.82e-01 1.0000000 ns p = 1 0.0985257 small
Fitness sharing NK Landscape 10 value Phenotypic Phylogenetic 60 60 1502.0 1.18e-01 1.0000000 ns p = 1 0.1427816 small
Fitness sharing NK Landscape 100 value Phenotypic Phylogenetic 60 60 883.0 1.50e-06 0.0000891 **** p < 1e-04 0.4393649 moderate
Fitness sharing NK Landscape 1000 value Phenotypic Phylogenetic 60 60 792.0 1.00e-07 0.0000073 **** p < 1e-04 0.4829660 moderate
Fitness sharing Sorting network 10 value Phenotypic Phylogenetic 60 60 862.0 9.00e-07 0.0000509 **** p < 1e-04 0.4494267 moderate
Fitness sharing Sorting network 100 value Phenotypic Phylogenetic 60 60 897.0 2.20e-06 0.0001280 *** p = 0.00012803 0.4326571 moderate
Fitness sharing Sorting network 1000 value Phenotypic Phylogenetic 60 60 2041.0 2.07e-01 1.0000000 ns p = 1 0.1154710 small
Lexicase Count Odds 10 value Phenotypic Phylogenetic 60 60 2058.0 1.77e-01 1.0000000 ns p = 1 0.1236163 small
Lexicase Count Odds 100 value Phenotypic Phylogenetic 60 60 806.0 2.00e-07 0.0000109 **** p < 1e-04 0.4762582 moderate
Lexicase Count Odds 1000 value Phenotypic Phylogenetic 60 60 1160.0 7.89e-04 0.0465510
p = 0.046551 0.3066456 moderate
Lexicase Logic-9 10 value Phenotypic Phylogenetic 60 60 1719.5 6.75e-01 1.0000000 ns p = 1 0.0385703 small
Lexicase Logic-9 100 value Phenotypic Phylogenetic 60 60 1426.5 5.03e-02 1.0000000 ns p = 1 0.1789565 small
Lexicase Logic-9 1000 value Phenotypic Phylogenetic 60 60 1765.0 8.56e-01 1.0000000 ns p = 1 0.0168555 small
Lexicase NK Landscape 10 value Phenotypic Phylogenetic 60 60 1812.0 9.52e-01 1.0000000 ns p = 1 0.0057864 small
Lexicase NK Landscape 100 value Phenotypic Phylogenetic 60 60 1498.0 1.11e-01 1.0000000 ns p = 1 0.1456250 small
Lexicase NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1157.0 6.89e-04 0.0406510
p = 0.040651 0.3100558 moderate
Lexicase Sorting network 10 value Phenotypic Phylogenetic 60 60 1779.0 8.90e-01 1.0000000 ns p = 1 0.0129291 small
Lexicase Sorting network 100 value Phenotypic Phylogenetic 60 60 1820.0 8.95e-01 1.0000000 ns p = 1 0.0123135 small
Random Count Odds 10 value Phenotypic Phylogenetic 60 60 1706.0 6.24e-01 1.0000000 ns p = 1 0.0450385 small
Random Count Odds 100 value Phenotypic Phylogenetic 60 60 2157.0 6.13e-02 1.0000000 ns p = 1 0.1710505 small
Random Count Odds 1000 value Phenotypic Phylogenetic 60 60 1060.0 1.04e-04 0.0061360 ** p = 0.006136 0.3545584 moderate
Random Logic-9 10 value Phenotypic Phylogenetic 60 60 1777.0 8.94e-01 1.0000000 ns p = 1 0.0124497 small
Random Logic-9 100 value Phenotypic Phylogenetic 60 60 1816.0 9.27e-01 1.0000000 ns p = 1 0.0086623 small
Random Logic-9 1000 value Phenotypic Phylogenetic 60 60 1793.0 9.63e-01 1.0000000 ns p = 1 0.0045250 small
Random NK Landscape 10 value Phenotypic Phylogenetic 60 60 1482.0 9.56e-02 1.0000000 ns p = 1 0.1523643 small
Random NK Landscape 100 value Phenotypic Phylogenetic 60 60 1380.0 2.77e-02 1.0000000 ns p = 1 0.2012359 small
Random NK Landscape 1000 value Phenotypic Phylogenetic 60 60 534.0 0.00e+00 0.0000000 **** p < 1e-04 0.6065824 large
Random Sorting network 10 value Phenotypic Phylogenetic 60 60 1993.0 3.12e-01 1.0000000 ns p = 1 0.0924727 small
Random Sorting network 100 value Phenotypic Phylogenetic 60 60 1857.0 7.67e-01 1.0000000 ns p = 1 0.0273106 small
Random Sorting network 1000 value Phenotypic Phylogenetic 60 60 1907.0 5.76e-01 1.0000000 ns p = 1 0.0512672 small
Tournament Count Odds 10 value Phenotypic Phylogenetic 60 60 1512.0 1.31e-01 1.0000000 ns p = 1 0.1379903 small
Tournament Count Odds 100 value Phenotypic Phylogenetic 60 60 1210.0 1.97e-03 0.1162300 ns p = 0.11623 0.2826885 small
Tournament Count Odds 1000 value Phenotypic Phylogenetic 60 60 1436.0 5.64e-02 1.0000000 ns p = 1 0.1744214 small
Tournament Logic-9 10 value Phenotypic Phylogenetic 60 60 1911.5 5.60e-01 1.0000000 ns p = 1 0.0534243 small
Tournament Logic-9 100 value Phenotypic Phylogenetic 60 60 1287.0 7.15e-03 0.4218500 ns p = 0.42185 0.2457995 small
Tournament Logic-9 1000 value Phenotypic Phylogenetic 60 60 1571.0 2.26e-01 1.0000000 ns p = 1 0.1108795 small
Tournament NK Landscape 10 value Phenotypic Phylogenetic 60 60 1792.0 9.47e-01 1.0000000 ns p = 1 0.0064879 small
Tournament NK Landscape 100 value Phenotypic Phylogenetic 60 60 1780.0 8.62e-01 1.0000000 ns p = 1 0.0162196 small
Tournament NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1780.0 8.62e-01 1.0000000 ns p = 1 0.0162196 small
Tournament Sorting network 10 value Phenotypic Phylogenetic 60 60 2028.5 2.31e-01 1.0000000 ns p = 1 0.1094826 small
Tournament Sorting network 100 value Phenotypic Phylogenetic 60 60 1383.0 2.88e-02 1.0000000 ns p = 1 0.1998002 small
Tournament Sorting network 1000 value Phenotypic Phylogenetic 60 60 1499.5 8.73e-02 1.0000000 ns p = 1 0.1563290 small

3.7.2.6 Variance evolutionary distinctiveness vs. phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  fit_phylo_10 = condinformation(discretize(max_performance), discretize(lag(variance_phenotype_evolutionary_distinctiveness, 1)), discretize(lag(max_performance, 1))),
  fit_phylo_100 = condinformation(discretize(max_performance), discretize(lag(variance_phenotype_evolutionary_distinctiveness, 10)), discretize(lag(max_performance, 10))),
  fit_phylo_1000 = condinformation(discretize(max_performance), discretize(lag(variance_phenotype_evolutionary_distinctiveness, 100)), discretize(lag(max_performance, 100))),
    fit_pheno_10 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 1)), discretize(lag(max_performance, 1))),
      fit_pheno_100 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 10)), discretize(lag(max_performance, 10))),
      fit_pheno_1000 = condinformation(discretize(max_performance), discretize(lag(phenotype_num_taxa, 100)), discretize(lag(max_performance, 100)))
      )

res <- res %>% pivot_longer(cols=contains("o_10"))
res$offset <- str_extract(res$name, "[:digit:]*$")
res$Type <- case_when(str_detect(res$name, "phylo") ~ "Phylogenetic", TRUE ~ "Phenotypic")

ggplot(
  res %>% filter(str_detect(name, "fit_ph*")), 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_x_discrete("Lag") + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("") + 
  theme(legend.position = "bottom")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic Phylogenetic 60 60 1727.0 7.04e-01 1.0000000 ns p = 1 0.0349767 small
Eco-EA Count Odds 100 value Phenotypic Phylogenetic 60 60 1192.0 1.43e-03 0.0843700 ns p = 0.08437 0.2913129 small
Eco-EA Count Odds 1000 value Phenotypic Phylogenetic 60 60 1163.0 8.35e-04 0.0492650
p = 0.049265 0.3052183 moderate
Eco-EA Logic-9 10 value Phenotypic Phylogenetic 60 60 1793.0 9.73e-01 1.0000000 ns p = 1 0.0033540 small
Eco-EA Logic-9 100 value Phenotypic Phylogenetic 60 60 1290.0 7.49e-03 0.4419100 ns p = 0.44191 0.2443621 small
Eco-EA Logic-9 1000 value Phenotypic Phylogenetic 60 60 1332.0 1.38e-02 0.8142000 ns p = 0.8142 0.2251351 small
Eco-EA NK Landscape 10 value Phenotypic Phylogenetic 60 60 1488.5 1.03e-01 1.0000000 ns p = 1 0.1492502 small
Eco-EA NK Landscape 100 value Phenotypic Phylogenetic 60 60 1516.5 1.37e-01 1.0000000 ns p = 1 0.1358344 small
Eco-EA NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1567.0 2.22e-01 1.0000000 ns p = 1 0.1116419 small
Eco-EA Sorting network 10 value Phenotypic Phylogenetic 60 60 2146.0 6.97e-02 1.0000000 ns p = 1 0.1657941 small
Eco-EA Sorting network 100 value Phenotypic Phylogenetic 60 60 2501.5 2.34e-04 0.0138060
p = 0.013806 0.3361130 moderate
Eco-EA Sorting network 1000 value Phenotypic Phylogenetic 60 60 1770.0 5.67e-01 1.0000000 ns p = 1 0.0531481 small
Fitness sharing Count Odds 10 value Phenotypic Phylogenetic 60 60 2027.0 2.35e-01 1.0000000 ns p = 1 0.1087632 small
Fitness sharing Count Odds 100 value Phenotypic Phylogenetic 60 60 1938.0 4.70e-01 1.0000000 ns p = 1 0.0661204 small
Fitness sharing Count Odds 1000 value Phenotypic Phylogenetic 60 60 2252.0 1.78e-02 1.0000000 ns p = 1 0.2165681 small
Fitness sharing Logic-9 10 value Phenotypic Phylogenetic 60 60 1650.0 4.33e-01 1.0000000 ns p = 1 0.0718712 small
Fitness sharing Logic-9 100 value Phenotypic Phylogenetic 60 60 1326.0 1.29e-02 0.7611000 ns p = 0.7611 0.2271130 small
Fitness sharing Logic-9 1000 value Phenotypic Phylogenetic 60 60 1466.0 7.90e-02 1.0000000 ns p = 1 0.1605958 small
Fitness sharing NK Landscape 10 value Phenotypic Phylogenetic 60 60 1352.0 1.88e-02 1.0000000 ns p = 1 0.2146516 small
Fitness sharing NK Landscape 100 value Phenotypic Phylogenetic 60 60 1273.0 5.72e-03 0.3374800 ns p = 0.33748 0.2525031 small
Fitness sharing NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1113.0 3.14e-04 0.0185260
p = 0.018526 0.3291644 moderate
Fitness sharing Sorting network 10 value Phenotypic Phylogenetic 60 60 1067.0 1.21e-04 0.0071390 ** p = 0.007139 0.3512045 moderate
Fitness sharing Sorting network 100 value Phenotypic Phylogenetic 60 60 2073.0 1.53e-01 1.0000000 ns p = 1 0.1308033 small
Fitness sharing Sorting network 1000 value Phenotypic Phylogenetic 60 60 2303.0 8.35e-03 0.4926500 ns p = 0.49265 0.2410039 small
Lexicase Count Odds 10 value Phenotypic Phylogenetic 60 60 1942.0 4.58e-01 1.0000000 ns p = 1 0.0680369 small
Lexicase Count Odds 100 value Phenotypic Phylogenetic 60 60 1432.0 5.37e-02 1.0000000 ns p = 1 0.1763209 small
Lexicase Count Odds 1000 value Phenotypic Phylogenetic 60 60 1494.0 1.09e-01 1.0000000 ns p = 1 0.1466157 small
Lexicase Logic-9 10 value Phenotypic Phylogenetic 60 60 1753.0 8.07e-01 1.0000000 ns p = 1 0.0225193 small
Lexicase Logic-9 100 value Phenotypic Phylogenetic 60 60 1303.5 9.23e-03 0.5445700 ns p = 0.54457 0.2378899 small
Lexicase Logic-9 1000 value Phenotypic Phylogenetic 60 60 1610.0 3.18e-01 1.0000000 ns p = 1 0.0914490 small
Lexicase NK Landscape 10 value Phenotypic Phylogenetic 60 60 1774.0 8.93e-01 1.0000000 ns p = 1 0.0125373 small
Lexicase NK Landscape 100 value Phenotypic Phylogenetic 60 60 1533.0 1.59e-01 1.0000000 ns p = 1 0.1287479 small
Lexicase NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1231.0 2.67e-03 0.1575300 ns p = 0.15753 0.2743729 small
Lexicase Sorting network 10 value Phenotypic Phylogenetic 60 60 1792.0 9.60e-01 1.0000000 ns p = 1 0.0049253 small
Lexicase Sorting network 100 value Phenotypic Phylogenetic 60 60 1776.0 8.74e-01 1.0000000 ns p = 1 0.0147759 small
Random Count Odds 10 value Phenotypic Phylogenetic 60 60 1752.0 8.03e-01 1.0000000 ns p = 1 0.0229984 small
Random Count Odds 100 value Phenotypic Phylogenetic 60 60 1764.0 8.52e-01 1.0000000 ns p = 1 0.0172488 small
Random Count Odds 1000 value Phenotypic Phylogenetic 60 60 1435.0 5.57e-02 1.0000000 ns p = 1 0.1748835 small
Random Logic-9 10 value Phenotypic Phylogenetic 60 60 1717.0 6.25e-01 1.0000000 ns p = 1 0.0449261 small
Random Logic-9 100 value Phenotypic Phylogenetic 60 60 1811.5 9.48e-01 1.0000000 ns p = 1 0.0062231 small
Random Logic-9 1000 value Phenotypic Phylogenetic 60 60 1714.5 5.42e-01 1.0000000 ns p = 1 0.0560318 small
Random NK Landscape 10 value Phenotypic Phylogenetic 60 60 1848.0 8.03e-01 1.0000000 ns p = 1 0.0229984 small
Random NK Landscape 100 value Phenotypic Phylogenetic 60 60 1754.0 8.11e-01 1.0000000 ns p = 1 0.0220401 small
Random NK Landscape 1000 value Phenotypic Phylogenetic 60 60 940.0 6.50e-06 0.0003806 *** p = 0.00038055 0.4120544 moderate
Random Sorting network 10 value Phenotypic Phylogenetic 60 60 1949.0 4.36e-01 1.0000000 ns p = 1 0.0713908 small
Random Sorting network 100 value Phenotypic Phylogenetic 60 60 1645.0 4.17e-01 1.0000000 ns p = 1 0.0742656 small
Random Sorting network 1000 value Phenotypic Phylogenetic 60 60 1736.0 7.39e-01 1.0000000 ns p = 1 0.0306645 small
Tournament Count Odds 10 value Phenotypic Phylogenetic 60 60 1534.0 1.63e-01 1.0000000 ns p = 1 0.1274494 small
Tournament Count Odds 100 value Phenotypic Phylogenetic 60 60 973.0 1.44e-05 0.0008496 *** p = 0.0008496 0.3962430 moderate
Tournament Count Odds 1000 value Phenotypic Phylogenetic 60 60 1484.5 9.82e-02 1.0000000 ns p = 1 0.1511756 small
Tournament Logic-9 10 value Phenotypic Phylogenetic 60 60 1872.0 7.07e-01 1.0000000 ns p = 1 0.0344982 small
Tournament Logic-9 100 value Phenotypic Phylogenetic 60 60 1270.0 5.45e-03 0.3215500 ns p = 0.32155 0.2539449 small
Tournament Logic-9 1000 value Phenotypic Phylogenetic 60 60 1610.0 3.15e-01 1.0000000 ns p = 1 0.0919101 small
Tournament NK Landscape 10 value Phenotypic Phylogenetic 60 60 1789.0 9.26e-01 1.0000000 ns p = 1 0.0089208 small
Tournament NK Landscape 100 value Phenotypic Phylogenetic 60 60 1778.0 8.49e-01 1.0000000 ns p = 1 0.0178416 small
Tournament NK Landscape 1000 value Phenotypic Phylogenetic 60 60 1778.0 8.49e-01 1.0000000 ns p = 1 0.0178416 small
Tournament Sorting network 10 value Phenotypic Phylogenetic 60 60 2183.0 4.47e-02 1.0000000 ns p = 1 0.1835086 small
Tournament Sorting network 100 value Phenotypic Phylogenetic 60 60 1367.0 2.32e-02 1.0000000 ns p = 1 0.2074646 small
Tournament Sorting network 1000 value Phenotypic Phylogenetic 60 60 1787.0 9.44e-01 1.0000000 ns p = 1 0.0067084 small

3.7.3 Transfer entropy between types of diversity

While we’re calculating transfer entropy, we might as well also calculate it between phenotypic diversity and phylogenetic diversity, as these could potentially also be in a feedback loop.

3.7.3.1 Max pairwise distance and phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  phen_phylo_10 =      condinformation(discretize(phenotype_num_taxa), 
                                       discretize(lag(max_phenotype_pairwise_distance, 1)), 
                                       discretize(lag(phenotype_num_taxa, 1))),
  phen_phylo_100 =     condinformation(discretize(phenotype_num_taxa),
                                       discretize(lag(max_phenotype_pairwise_distance, 10)),
                                       discretize(lag(phenotype_num_taxa, 10))),
  pheno_phylo_1000 =   condinformation(discretize(phenotype_num_taxa),
                                       discretize(lag(max_phenotype_pairwise_distance, 100)),
                                       discretize(lag(phenotype_num_taxa, 100))),
  
  phylo_pheno_10 =     condinformation(discretize(max_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_num_taxa, 1)),
                                       discretize(lag(max_phenotype_pairwise_distance, 1))),
  phylo_pheno_100 =    condinformation(discretize(max_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_num_taxa, 10)),
                                       discretize(lag(max_phenotype_pairwise_distance, 10))),
  phylo_pheno_1000 =   condinformation(discretize(max_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_num_taxa, 100)),
                                       discretize(lag(max_phenotype_pairwise_distance, 100))))

# Turn Transfer Entropy columns into rows
res <- res %>% pivot_longer(cols=contains("phylo"))
# Pull lag into a column
res$offset <- str_extract(res$name, "[:digit:]*$")
# Make column indicating direction of transfer entropy
res$Type <- case_when(str_detect(res$name, "phylo_pheno") ~ "\nPhenotypic\n\t->\nPhylogenetic\n", TRUE ~ "\nPhylogenetic\n\t->\nPhenotypic\n")

ggplot(
  res, 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name* problem_name, ncol=4) + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 4.0 0.00e+00 0.0000000 **** p < 1e-04 0.8605228 large
Eco-EA Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 284.0 0.00e+00 0.0000000 **** p < 1e-04 0.7263656 large
Eco-EA Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 633.0 0.00e+00 0.0000001 **** p < 1e-04 0.5591482 large
Eco-EA Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1990.0 3.20e-01 1.0000000 ns p = 1 0.0910353 small
Eco-EA Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2044.0 2.01e-01 1.0000000 ns p = 1 0.1169084 small
Eco-EA Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1467.0 8.10e-02 1.0000000 ns p = 1 0.1595513 small
Eco-EA NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 115.0 0.00e+00 0.0000000 **** p < 1e-04 0.8073391 large
Eco-EA NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 710.0 0.00e+00 0.0000006 **** p < 1e-04 0.5222549 large
Eco-EA NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1260.5 4.67e-03 0.2802000 ns p = 0.2802 0.2584927 small
Eco-EA Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 115.0 0.00e+00 0.0000000 **** p < 1e-04 0.8073391 large
Eco-EA Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 996.0 2.47e-05 0.0014820 ** p = 0.001482 0.3852229 moderate
Eco-EA Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1135.0 4.87e-04 0.0292200
p = 0.02922 0.3186345 moderate
Fitness sharing Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 16.0 0.00e+00 0.0000000 **** p < 1e-04 0.8547732 large
Fitness sharing Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1617.0 3.38e-01 1.0000000 ns p = 1 0.0876813 small
Fitness sharing Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1899.0 6.05e-01 1.0000000 ns p = 1 0.0474342 small
Fitness sharing Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 867.0 1.00e-06 0.0000592 **** p < 1e-04 0.4470311 moderate
Fitness sharing Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1066.0 1.18e-04 0.0070800 ** p = 0.00708 0.3516836 moderate
Fitness sharing Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1445.0 6.28e-02 1.0000000 ns p = 1 0.1700922 small
Fitness sharing NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Fitness sharing NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Fitness sharing NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 203.0 0.00e+00 0.0000000 **** p < 1e-04 0.7652019 large
Fitness sharing Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3.0 0.00e+00 0.0000000 **** p < 1e-04 0.8610020 large
Fitness sharing Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2733.0 1.00e-06 0.0000592 **** p < 1e-04 0.4470311 moderate
Fitness sharing Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2660.0 6.50e-06 0.0003870 *** p = 0.000387 0.4120544 moderate
Lexicase Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 22.0 0.00e+00 0.0000000 **** p < 1e-04 0.8518984 large
Lexicase Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 633.0 0.00e+00 0.0000001 **** p < 1e-04 0.5591676 large
Lexicase Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1402.0 3.69e-02 1.0000000 ns p = 1 0.1906949 small
Lexicase Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1809.0 9.64e-01 1.0000000 ns p = 1 0.0043122 small
Lexicase Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1545.0 1.82e-01 1.0000000 ns p = 1 0.1221798 small
Lexicase NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 18.0 0.00e+00 0.0000000 **** p < 1e-04 0.8538150 large
Lexicase Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1134.0 4.78e-04 0.0286800
p = 0.02868 0.3191026 moderate
Lexicase Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2890.0 0.00e+00 0.0000006 **** p < 1e-04 0.5222640 large
Lexicase Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 30.0 0.00e+00 0.0000000 **** p < 1e-04 0.9099165 large
Random Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1.0 0.00e+00 0.0000000 **** p < 1e-04 0.8619602 large
Random Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 228.0 0.00e+00 0.0000000 **** p < 1e-04 0.7531970 large
Random Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 372.0 0.00e+00 0.0000000 **** p < 1e-04 0.6842019 large
Random Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 928.0 4.80e-06 0.0002868 *** p = 0.0002868 0.4178040 moderate
Random Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1227.0 2.66e-03 0.1596000 ns p = 0.1596 0.2745451 small
Random NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 143.0 0.00e+00 0.0000000 **** p < 1e-04 0.7939371 large
Random Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 185.0 0.00e+00 0.0000000 **** p < 1e-04 0.7737998 large
Random Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 272.0 0.00e+00 0.0000000 **** p < 1e-04 0.7321152 large
Random Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 509.0 0.00e+00 0.0000000 **** p < 1e-04 0.6185607 large
Tournament Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1723.0 6.88e-01 1.0000000 ns p = 1 0.0368932 small
Tournament Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2468.0 4.59e-04 0.0275400
p = 0.02754 0.3200608 moderate
Tournament Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2198.0 3.69e-02 1.0000000 ns p = 1 0.1906949 small
Tournament Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2925.0 0.00e+00 0.0000002 **** p < 1e-04 0.5390246 large
Tournament Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2748.0 7.00e-07 0.0000395 **** p < 1e-04 0.4542181 moderate
Tournament Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1866.0 7.31e-01 1.0000000 ns p = 1 0.0316230 small
Tournament NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 784.0 1.00e-07 0.0000059 **** p < 1e-04 0.4867991 moderate
Tournament NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1198.0 1.59e-03 0.0954000 ns p = 0.0954 0.2884381 small
Tournament NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1630.5 3.75e-01 1.0000000 ns p = 1 0.0812132 small
Tournament Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 686.0 0.00e+00 0.0000003 **** p < 1e-04 0.5337541 large
Tournament Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1272.0 5.63e-03 0.3378000 ns p = 0.3378 0.2529822 small
Tournament Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1565.0 2.18e-01 1.0000000 ns p = 1 0.1126002 small

3.7.3.2 Mean pairwise distance and phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  phen_phylo_10 =      condinformation(discretize(phenotype_num_taxa), 
                                       discretize(lag(mean_phenotype_pairwise_distance, 1)), 
                                       discretize(lag(phenotype_num_taxa, 1))),
  phen_phylo_100 =     condinformation(discretize(phenotype_num_taxa),
                                       discretize(lag(mean_phenotype_pairwise_distance, 10)),
                                       discretize(lag(phenotype_num_taxa, 10))),
  pheno_phylo_1000 =   condinformation(discretize(phenotype_num_taxa),
                                       discretize(lag(mean_phenotype_pairwise_distance, 100)),
                                       discretize(lag(phenotype_num_taxa, 100))),
  
  phylo_pheno_10 =     condinformation(discretize(mean_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_num_taxa, 1)),
                                       discretize(lag(mean_phenotype_pairwise_distance, 1))),
  phylo_pheno_100 =    condinformation(discretize(mean_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_num_taxa, 10)),
                                       discretize(lag(mean_phenotype_pairwise_distance, 10))),
  phylo_pheno_1000 =   condinformation(discretize(mean_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_num_taxa, 100)),
                                       discretize(lag(mean_phenotype_pairwise_distance, 100)))
)

# Turn Transfer Entropy columns into rows
res <- res %>% pivot_longer(cols=contains("phylo"))
# Pull lag into a column
res$offset <- str_extract(res$name, "[:digit:]*$")
# Make column indicating direction of transfer entropy
res$Type <- case_when(str_detect(res$name, "phylo_pheno") ~ "\nPhenotypic\n\t->\nPhylogenetic\n", TRUE ~ "\nPhylogenetic\n\t->\nPhenotypic\n")

ggplot(
  res, 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 310.0 0.00e+00 0.0000000 **** p < 1e-04 0.7139081 large
Eco-EA Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 822.0 3.00e-07 0.0000173 **** p < 1e-04 0.4685921 moderate
Eco-EA Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 984.0 1.87e-05 0.0011220 ** p = 0.001122 0.3909752 moderate
Eco-EA Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1530.0 1.57e-01 1.0000000 ns p = 1 0.1293659 small
Eco-EA Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2183.0 4.47e-02 1.0000000 ns p = 1 0.1835079 small
Eco-EA Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1983.0 3.38e-01 1.0000000 ns p = 1 0.0876813 small
Eco-EA NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 117.0 0.00e+00 0.0000000 **** p < 1e-04 0.8063808 large
Eco-EA NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 775.0 1.00e-07 0.0000045 **** p < 1e-04 0.4911113 moderate
Eco-EA NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1562.5 2.14e-01 1.0000000 ns p = 1 0.1137943 small
Eco-EA Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 73.0 0.00e+00 0.0000000 **** p < 1e-04 0.8274627 large
Eco-EA Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 518.0 0.00e+00 0.0000000 **** p < 1e-04 0.6142485 large
Eco-EA Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1393.0 3.29e-02 1.0000000 ns p = 1 0.1950190 small
Fitness sharing Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3.0 0.00e+00 0.0000000 **** p < 1e-04 0.8610020 large
Fitness sharing Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1773.0 8.89e-01 1.0000000 ns p = 1 0.0129366 small
Fitness sharing Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1935.0 4.80e-01 1.0000000 ns p = 1 0.0646830 small
Fitness sharing Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 628.0 0.00e+00 0.0000000 **** p < 1e-04 0.5615439 large
Fitness sharing Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1010.0 3.42e-05 0.0020520 ** p = 0.002052 0.3785151 moderate
Fitness sharing Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1242.0 3.43e-03 0.2058000 ns p = 0.2058 0.2673562 small
Fitness sharing NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Fitness sharing NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 30.0 0.00e+00 0.0000000 **** p < 1e-04 0.8480654 large
Fitness sharing NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 480.0 0.00e+00 0.0000000 **** p < 1e-04 0.6324555 large
Fitness sharing Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 6.0 0.00e+00 0.0000000 **** p < 1e-04 0.8595646 large
Fitness sharing Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2922.0 0.00e+00 0.0000002 **** p < 1e-04 0.5375872 large
Fitness sharing Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2862.0 0.00e+00 0.0000015 **** p < 1e-04 0.5088392 large
Lexicase Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 150.0 0.00e+00 0.0000000 **** p < 1e-04 0.7905694 large
Lexicase Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 931.0 5.10e-06 0.0003090 *** p = 0.000309 0.4163673 moderate
Lexicase Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1862.0 7.47e-01 1.0000000 ns p = 1 0.0297062 small
Lexicase Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1835.0 8.56e-01 1.0000000 ns p = 1 0.0167697 small
Lexicase Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1857.0 7.67e-01 1.0000000 ns p = 1 0.0273106 small
Lexicase NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 4.0 0.00e+00 0.0000000 **** p < 1e-04 0.8605228 large
Lexicase Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1390.5 3.18e-02 1.0000000 ns p = 1 0.1962803 small
Lexicase Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1955.0 4.17e-01 1.0000000 ns p = 1 0.0742656 small
Lexicase Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1736.0 7.39e-01 1.0000000 ns p = 1 0.0306647 small
Random Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 18.0 0.00e+00 0.0000000 **** p < 1e-04 0.8538150 large
Random Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 478.0 0.00e+00 0.0000000 **** p < 1e-04 0.6334138 large
Random Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 625.0 0.00e+00 0.0000000 **** p < 1e-04 0.5629813 large
Random Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1029.0 5.25e-05 0.0031500 ** p = 0.00315 0.3694115 moderate
Random Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1371.0 2.45e-02 1.0000000 ns p = 1 0.2055480 small
Random NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 20.0 0.00e+00 0.0000000 **** p < 1e-04 0.8528567 large
Random NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 336.0 0.00e+00 0.0000000 **** p < 1e-04 0.7014507 large
Random Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 341.0 0.00e+00 0.0000000 **** p < 1e-04 0.6990550 large
Random Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 409.0 0.00e+00 0.0000000 **** p < 1e-04 0.6664740 large
Random Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 457.0 0.00e+00 0.0000000 **** p < 1e-04 0.6434756 large
Tournament Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 898.0 2.20e-06 0.0001338 *** p = 0.0001338 0.4321779 moderate
Tournament Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2480.0 3.62e-04 0.0217200
p = 0.02172 0.3258104 moderate
Tournament Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2402.0 1.59e-03 0.0954000 ns p = 0.0954 0.2884381 small
Tournament Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1427.0 5.06e-02 1.0000000 ns p = 1 0.1787166 small
Tournament Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2720.0 1.40e-06 0.0000834 **** p < 1e-04 0.4408023 moderate
Tournament Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1934.0 4.83e-01 1.0000000 ns p = 1 0.0642038 small
Tournament NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 272.0 0.00e+00 0.0000000 **** p < 1e-04 0.7321152 large
Tournament NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 913.0 3.30e-06 0.0001962 *** p = 0.0001962 0.4249910 moderate
Tournament NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1765.0 8.56e-01 1.0000000 ns p = 1 0.0167697 small
Tournament Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 314.0 0.00e+00 0.0000000 **** p < 1e-04 0.7119916 large
Tournament Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1160.0 7.89e-04 0.0473400
p = 0.04734 0.3066451 moderate
Tournament Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1766.0 8.60e-01 1.0000000 ns p = 1 0.0162906 small

3.7.3.3 Mean pairwise distance and shannon diversity

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  phen_phylo_10 =      condinformation(discretize(phenotype_diversity), 
                                       discretize(lag(mean_phenotype_pairwise_distance, 1)), 
                                       discretize(lag(phenotype_diversity, 1))),
  phen_phylo_100 =     condinformation(discretize(phenotype_diversity),
                                       discretize(lag(mean_phenotype_pairwise_distance, 10)),
                                       discretize(lag(phenotype_diversity, 10))),
  pheno_phylo_1000 =   condinformation(discretize(phenotype_diversity),
                                       discretize(lag(mean_phenotype_pairwise_distance, 100)),
                                       discretize(lag(phenotype_diversity, 100))),
  phylo_pheno_10 =     condinformation(discretize(mean_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_diversity, 1)),
                                       discretize(lag(mean_phenotype_pairwise_distance, 1))),
  phylo_pheno_100 =    condinformation(discretize(mean_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_diversity, 10)),
                                       discretize(lag(mean_phenotype_pairwise_distance, 10))),
  phylo_pheno_1000 =   condinformation(discretize(mean_phenotype_pairwise_distance),
                                       discretize(lag(phenotype_diversity, 100)),
                                       discretize(lag(mean_phenotype_pairwise_distance, 100)))
  
)

# Turn Transfer Entropy columns into rows
res <- res %>% pivot_longer(cols=contains("phylo"))
# Pull lag into a column
res$offset <- str_extract(res$name, "[:digit:]*$")
# Make column indicating direction of transfer entropy
res$Type <- case_when(str_detect(res$name, "phylo_pheno") ~ "\nPhenotypic\n\t->\nPhylogenetic\n", TRUE ~ "\nPhylogenetic\n\t->\nPhenotypic\n")

ggplot(
  res, 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 557.0 0.00e+00 0.0000000 **** p < 1e-04 0.5955623 large
Eco-EA Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 898.0 2.20e-06 0.0001338 *** p = 0.0001338 0.4321779 moderate
Eco-EA Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 875.0 1.20e-06 0.0000732 **** p < 1e-04 0.4432011 moderate
Eco-EA Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1419.0 4.58e-02 1.0000000 ns p = 1 0.1825497 small
Eco-EA Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1956.0 4.14e-01 1.0000000 ns p = 1 0.0747447 small
Eco-EA Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1758.0 8.28e-01 1.0000000 ns p = 1 0.0201236 small
Eco-EA NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1153.0 6.91e-04 0.0414600
p = 0.04146 0.3099990 moderate
Eco-EA NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1312.0 1.05e-02 0.6300000 ns p = 0.63 0.2338169 small
Eco-EA NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1459.0 7.39e-02 1.0000000 ns p = 1 0.1633843 small
Eco-EA Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 531.0 0.00e+00 0.0000000 **** p < 1e-04 0.6080198 large
Eco-EA Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2600.0 2.71e-05 0.0016260 ** p = 0.001626 0.3833064 moderate
Eco-EA Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1661.0 4.67e-01 1.0000000 ns p = 1 0.0666060 small
Fitness sharing Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1.0 0.00e+00 0.0000000 **** p < 1e-04 0.8619602 large
Fitness sharing Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1695.0 5.83e-01 1.0000000 ns p = 1 0.0503090 small
Fitness sharing Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2098.0 1.18e-01 1.0000000 ns p = 1 0.1427816 small
Fitness sharing Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 588.0 0.00e+00 0.0000000 **** p < 1e-04 0.5807092 large
Fitness sharing Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1101.0 2.46e-04 0.0147600
p = 0.01476 0.3349140 moderate
Fitness sharing Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1411.0 4.14e-02 1.0000000 ns p = 1 0.1863827 small
Fitness sharing NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Fitness sharing NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 40.0 0.00e+00 0.0000000 **** p < 1e-04 0.8432740 large
Fitness sharing NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 438.0 0.00e+00 0.0000000 **** p < 1e-04 0.6525791 large
Fitness sharing Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 5.0 0.00e+00 0.0000000 **** p < 1e-04 0.8600437 large
Fitness sharing Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2988.0 0.00e+00 0.0000000 **** p < 1e-04 0.5692100 large
Fitness sharing Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2871.0 0.00e+00 0.0000012 **** p < 1e-04 0.5131514 large
Lexicase Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 149.0 0.00e+00 0.0000000 **** p < 1e-04 0.7910485 large
Lexicase Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 871.0 1.10e-06 0.0000660 **** p < 1e-04 0.4451145 moderate
Lexicase Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1982.0 3.41e-01 1.0000000 ns p = 1 0.0872022 small
Lexicase Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2120.0 9.36e-02 1.0000000 ns p = 1 0.1533226 small
Lexicase Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1777.0 9.06e-01 1.0000000 ns p = 1 0.0110201 small
Lexicase NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Lexicase NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 18.0 0.00e+00 0.0000000 **** p < 1e-04 0.8538150 large
Lexicase Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2118.5 9.23e-02 1.0000000 ns p = 1 0.1539355 small
Lexicase Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2210.5 3.07e-02 1.0000000 ns p = 1 0.1974746 small
Lexicase Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1859.0 7.59e-01 1.0000000 ns p = 1 0.0282699 small
Random Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 51.0 0.00e+00 0.0000000 **** p < 1e-04 0.8380036 large
Random Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 455.0 0.00e+00 0.0000000 **** p < 1e-04 0.6444339 large
Random Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3394.0 0.00e+00 0.0000000 **** p < 1e-04 0.7637380 large
Random Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2548.0 8.73e-05 0.0052380 ** p = 0.005238 0.3583915 moderate
Random Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2370.0 2.80e-03 0.1680000 ns p = 0.168 0.2731058 small
Random NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Random NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 39.0 0.00e+00 0.0000000 **** p < 1e-04 0.8437532 large
Random NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 456.0 0.00e+00 0.0000000 **** p < 1e-04 0.6439547 large
Random Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 562.0 0.00e+00 0.0000000 **** p < 1e-04 0.5931666 large
Random Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 369.0 0.00e+00 0.0000000 **** p < 1e-04 0.6856393 large
Random Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 608.0 0.00e+00 0.0000000 **** p < 1e-04 0.5711265 large
Tournament Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2065.0 1.65e-01 1.0000000 ns p = 1 0.1269702 small
Tournament Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2459.0 5.48e-04 0.0328800
p = 0.03288 0.3157486 moderate
Tournament Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2074.5 1.50e-01 1.0000000 ns p = 1 0.1315222 small
Tournament Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2035.0 2.18e-01 1.0000000 ns p = 1 0.1125963 small
Tournament Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2437.0 8.35e-04 0.0501000 ns p = 0.0501 0.3052077 moderate
Tournament Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1782.0 9.27e-01 1.0000000 ns p = 1 0.0086244 small
Tournament NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1404.0 3.79e-02 1.0000000 ns p = 1 0.1897367 small
Tournament NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1759.0 8.32e-01 1.0000000 ns p = 1 0.0196445 small
Tournament NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1972.0 3.68e-01 1.0000000 ns p = 1 0.0824109 small
Tournament Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 581.0 0.00e+00 0.0000000 **** p < 1e-04 0.5840631 large
Tournament Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1362.0 2.17e-02 1.0000000 ns p = 1 0.2098602 small
Tournament Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1758.0 8.28e-01 1.0000000 ns p = 1 0.0201237 small

3.7.3.4 Mean evolutionary distinctiveness and phenotypic richness

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  phen_phylo_10 =      condinformation(
                          discretize(phenotype_num_taxa), 
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 1)), 
                          discretize(lag(phenotype_num_taxa, 1))),
  phen_phylo_100 =     condinformation(
                          discretize(phenotype_num_taxa),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 10)),
                          discretize(lag(phenotype_num_taxa, 10))),
  pheno_phylo_1000 =   condinformation(
                          discretize(phenotype_num_taxa),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 100)),
                          discretize(lag(phenotype_num_taxa, 100))),
  
  phylo_pheno_10 =     condinformation(
                          discretize(mean_phenotype_evolutionary_distinctiveness),
                          discretize(lag(phenotype_num_taxa, 1)),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 1))),
  phylo_pheno_100 =    condinformation(
                          discretize(mean_phenotype_evolutionary_distinctiveness),
                          discretize(lag(phenotype_num_taxa, 10)),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 10))),
  phylo_pheno_1000 =   condinformation(
                          discretize(mean_phenotype_evolutionary_distinctiveness),
                          discretize(lag(phenotype_num_taxa, 100)),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 100)))
)

# Turn Transfer Entropy columns into rows
res <- res %>% pivot_longer(cols=contains("phylo"))
# Pull lag into a column
res$offset <- str_extract(res$name, "[:digit:]*$")
# Make column indicating direction of transfer entropy
res$Type <- case_when(str_detect(res$name, "phylo_pheno") ~ "\nPhenotypic\n\t->\nPhylogenetic\n", TRUE ~ "\nPhylogenetic\n\t->\nPhenotypic\n")

ggplot(
  res, 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_y_continuous("Transfer Entropy") +  
  scale_color_discrete("")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 229.0 0.00e+00 0.0000000 **** p < 1e-04 0.7527179 large
Eco-EA Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1127.0 4.16e-04 0.0249600
p = 0.02496 0.3224565 moderate
Eco-EA Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1329.5 1.36e-02 0.8160000 ns p = 0.816 0.2254325 small
Eco-EA Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 53.0 0.00e+00 0.0000000 **** p < 1e-04 0.8370453 large
Eco-EA Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1089.0 1.92e-04 0.0115200
p = 0.01152 0.3406635 moderate
Eco-EA Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1906.0 5.80e-01 1.0000000 ns p = 1 0.0507881 small
Eco-EA NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 4.0 0.00e+00 0.0000000 **** p < 1e-04 0.8605228 large
Eco-EA NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 194.0 0.00e+00 0.0000000 **** p < 1e-04 0.7694876 large
Eco-EA NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 693.0 0.00e+00 0.0000004 **** p < 1e-04 0.5304002 large
Eco-EA Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Eco-EA Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Eco-EA Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 577.0 0.00e+00 0.0000000 **** p < 1e-04 0.5860000 large
Fitness sharing Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 447.0 0.00e+00 0.0000000 **** p < 1e-04 0.6482669 large
Fitness sharing Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1909.0 5.69e-01 1.0000000 ns p = 1 0.0522255 small
Fitness sharing Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2119.0 9.46e-02 1.0000000 ns p = 1 0.1528434 small
Fitness sharing Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1048.0 8.00e-05 0.0048000 ** p = 0.0048 0.3603080 moderate
Fitness sharing Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2263.0 1.52e-02 0.9120000 ns p = 0.912 0.2218386 small
Fitness sharing Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2156.0 6.21e-02 1.0000000 ns p = 1 0.1705713 small
Fitness sharing NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 80.0 0.00e+00 0.0000000 **** p < 1e-04 0.8241087 large
Fitness sharing NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 471.0 0.00e+00 0.0000000 **** p < 1e-04 0.6367677 large
Fitness sharing NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 946.0 7.50e-06 0.0004482 *** p = 0.0004482 0.4091796 moderate
Fitness sharing Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2089.0 1.30e-01 1.0000000 ns p = 1 0.1384694 small
Fitness sharing Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3316.0 0.00e+00 0.0000000 **** p < 1e-04 0.7263656 large
Fitness sharing Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3011.0 0.00e+00 0.0000000 **** p < 1e-04 0.5802300 large
Lexicase Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 9.0 0.00e+00 0.0000000 **** p < 1e-04 0.8581272 large
Lexicase Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 155.0 0.00e+00 0.0000000 **** p < 1e-04 0.7881738 large
Lexicase Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 981.0 1.74e-05 0.0010440 ** p = 0.001044 0.3924106 moderate
Lexicase Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 856.0 7.00e-07 0.0000440 **** p < 1e-04 0.4523015 moderate
Lexicase Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2006.0 2.81e-01 1.0000000 ns p = 1 0.0987014 small
Lexicase Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2615.0 1.91e-05 0.0011460 ** p = 0.001146 0.3904934 moderate
Lexicase NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3.0 0.00e+00 0.0000000 **** p < 1e-04 0.8610020 large
Lexicase NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 22.0 0.00e+00 0.0000000 **** p < 1e-04 0.8518984 large
Lexicase NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 167.0 0.00e+00 0.0000000 **** p < 1e-04 0.7824242 large
Lexicase Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624528 large
Lexicase Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 59.0 0.00e+00 0.0000000 **** p < 1e-04 0.8341705 large
Lexicase Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1576.0 2.41e-01 1.0000000 ns p = 1 0.1073262 small
Random Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 324.0 0.00e+00 0.0000000 **** p < 1e-04 0.7072003 large
Random Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 852.0 7.00e-07 0.0000395 **** p < 1e-04 0.4542181 moderate
Random Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 994.0 2.36e-05 0.0014160 ** p = 0.001416 0.3861812 moderate
Random Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 166.0 0.00e+00 0.0000000 **** p < 1e-04 0.7829033 large
Random Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 653.0 0.00e+00 0.0000001 **** p < 1e-04 0.5495655 large
Random Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 529.0 0.00e+00 0.0000000 **** p < 1e-04 0.6089780 large
Random NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 77.0 0.00e+00 0.0000000 **** p < 1e-04 0.8255461 large
Random NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 415.0 0.00e+00 0.0000000 **** p < 1e-04 0.6635992 large
Random NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 599.0 0.00e+00 0.0000000 **** p < 1e-04 0.5754387 large
Random Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1578.0 2.45e-01 1.0000000 ns p = 1 0.1063675 small
Random Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1711.0 6.42e-01 1.0000000 ns p = 1 0.0426428 small
Random Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2147.0 6.90e-02 1.0000000 ns p = 1 0.1662591 small
Tournament Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 277.0 0.00e+00 0.0000000 **** p < 1e-04 0.7297195 large
Tournament Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2039.0 2.11e-01 1.0000000 ns p = 1 0.1145128 small
Tournament Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2142.0 7.31e-02 1.0000000 ns p = 1 0.1638635 small
Tournament Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3.0 0.00e+00 0.0000000 **** p < 1e-04 0.8610020 large
Tournament Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 460.0 0.00e+00 0.0000000 **** p < 1e-04 0.6420382 large
Tournament Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1471.0 8.47e-02 1.0000000 ns p = 1 0.1576348 small
Tournament NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624424 large
Tournament NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Tournament NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 20.0 0.00e+00 0.0000000 **** p < 1e-04 0.8536871 large
Tournament Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 4.0 0.00e+00 0.0000000 **** p < 1e-04 0.8605228 large
Tournament Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 54.0 0.00e+00 0.0000000 **** p < 1e-04 0.8365662 large
Tournament Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 932.0 5.30e-06 0.0003168 *** p = 0.0003168 0.4158874 moderate

3.7.3.5 Mean evolutionary distinctiveness and shannon diversity

res <- data %>% group_by(SEED, selection_name, problem_name) %>%
summarise(
  phen_phylo_10 =      condinformation(
                          discretize(phenotype_diversity), 
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 1)), 
                          discretize(lag(phenotype_diversity, 1))),
  phen_phylo_100 =     condinformation(
                          discretize(phenotype_diversity),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 10)),
                          discretize(lag(phenotype_diversity, 10))),
  pheno_phylo_1000 =   condinformation(
                          discretize(phenotype_diversity),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 100)),
                          discretize(lag(phenotype_diversity, 100))),
  
  phylo_pheno_10 =     condinformation(
                          discretize(mean_phenotype_evolutionary_distinctiveness),
                          discretize(lag(phenotype_diversity, 1)),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 1))),
  phylo_pheno_100 =    condinformation(
                          discretize(mean_phenotype_evolutionary_distinctiveness),
                          discretize(lag(phenotype_diversity, 10)),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 10))),
  phylo_pheno_1000 =   condinformation(
                          discretize(mean_phenotype_evolutionary_distinctiveness),
                          discretize(lag(phenotype_diversity, 100)),
                          discretize(lag(mean_phenotype_evolutionary_distinctiveness, 100)))
)

# Turn Transfer Entropy columns into rows
res <- res %>% pivot_longer(cols=contains("phylo"))
# Pull lag into a column
res$offset <- str_extract(res$name, "[:digit:]*$")
# Make column indicating direction of transfer entropy
res$Type <- case_when(str_detect(res$name, "phylo_pheno") ~ "\nPhenotypic\n\t->\nPhylogenetic\n", TRUE ~ "\nPhylogenetic\n\t->\nPhenotypic\n")

ggplot(
  res, 
  aes(
    x=as.factor(offset), 
    y=value, 
    color=Type
    )
  ) + 
  geom_boxplot() + 
  facet_wrap(~selection_name*problem_name, ncol=4) + 
  scale_y_continuous("Transfer Entropy") + 
  scale_color_discrete("")

# Determine which conditions are significantly different from each other
transfer_entropy_stats(res)
selection_name problem_name offset .y. group1 group2 n1 n2 statistic p p.adj p.adj.signif label effsize magnitude
Eco-EA Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 569.0 0.00e+00 0.0000000 **** p < 1e-04 0.5898127 large
Eco-EA Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1222.0 2.44e-03 0.1464000 ns p = 0.1464 0.2769389 small
Eco-EA Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1062.5 1.10e-04 0.0066000 ** p = 0.0066 0.3533612 moderate
Eco-EA Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 101.0 0.00e+00 0.0000000 **** p < 1e-04 0.8140469 large
Eco-EA Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1068.0 1.23e-04 0.0073800 ** p = 0.00738 0.3507253 moderate
Eco-EA Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1639.0 4.00e-01 1.0000000 ns p = 1 0.0771404 small
Eco-EA NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 108.0 0.00e+00 0.0000000 **** p < 1e-04 0.8106930 large
Eco-EA NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 269.0 0.00e+00 0.0000000 **** p < 1e-04 0.7335526 large
Eco-EA NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 717.0 0.00e+00 0.0000008 **** p < 1e-04 0.5189010 large
Eco-EA Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2.0 0.00e+00 0.0000000 **** p < 1e-04 0.8614811 large
Eco-EA Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 186.0 0.00e+00 0.0000000 **** p < 1e-04 0.7733206 large
Eco-EA Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 340.0 0.00e+00 0.0000000 **** p < 1e-04 0.6996022 large
Fitness sharing Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 345.0 0.00e+00 0.0000000 **** p < 1e-04 0.6971385 large
Fitness sharing Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1896.0 6.16e-01 1.0000000 ns p = 1 0.0459968 small
Fitness sharing Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2291.0 1.00e-02 0.6000000 ns p = 0.6 0.2352543 small
Fitness sharing Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1175.0 1.05e-03 0.0630000 ns p = 0.063 0.2994581 small
Fitness sharing Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2410.0 1.38e-03 0.0828000 ns p = 0.0828 0.2922711 small
Fitness sharing Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2203.0 3.46e-02 1.0000000 ns p = 1 0.1930906 small
Fitness sharing NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 77.0 0.00e+00 0.0000000 **** p < 1e-04 0.8255461 large
Fitness sharing NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 578.0 0.00e+00 0.0000000 **** p < 1e-04 0.5855005 large
Fitness sharing NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 918.0 3.70e-06 0.0002232 *** p = 0.0002232 0.4225953 moderate
Fitness sharing Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1995.0 3.07e-01 1.0000000 ns p = 1 0.0934309 small
Fitness sharing Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3322.0 0.00e+00 0.0000000 **** p < 1e-04 0.7292404 large
Fitness sharing Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3155.0 0.00e+00 0.0000000 **** p < 1e-04 0.6492252 large
Lexicase Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 9.0 0.00e+00 0.0000000 **** p < 1e-04 0.8581272 large
Lexicase Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 161.0 0.00e+00 0.0000000 **** p < 1e-04 0.7852990 large
Lexicase Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 840.0 5.00e-07 0.0000285 **** p < 1e-04 0.4599677 moderate
Lexicase Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1038.0 6.42e-05 0.0038520 ** p = 0.003852 0.3650993 moderate
Lexicase Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2118.0 9.56e-02 1.0000000 ns p = 1 0.1523643 small
Lexicase Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2502.0 2.31e-04 0.0138600
p = 0.01386 0.3363514 moderate
Lexicase NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1.0 0.00e+00 0.0000000 **** p < 1e-04 0.8619602 large
Lexicase NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 12.0 0.00e+00 0.0000000 **** p < 1e-04 0.8566898 large
Lexicase NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 60.0 0.00e+00 0.0000000 **** p < 1e-04 0.8336914 large
Lexicase Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624633 large
Lexicase Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 83.0 0.00e+00 0.0000000 **** p < 1e-04 0.8226713 large
Lexicase Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1846.0 8.11e-01 1.0000000 ns p = 1 0.0220402 small
Random Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 586.0 0.00e+00 0.0000000 **** p < 1e-04 0.5816674 large
Random Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 697.0 0.00e+00 0.0000004 **** p < 1e-04 0.5284837 large
Random Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 980.0 1.70e-05 0.0010200 ** p = 0.00102 0.3928890 moderate
Random Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 3146.0 0.00e+00 0.0000000 **** p < 1e-04 0.6449130 large
Random Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1327.0 1.31e-02 0.7860000 ns p = 0.786 0.2266299 small
Random Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 691.0 0.00e+00 0.0000004 **** p < 1e-04 0.5313585 large
Random NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 44.0 0.00e+00 0.0000000 **** p < 1e-04 0.8413575 large
Random NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 354.0 0.00e+00 0.0000000 **** p < 1e-04 0.6928263 large
Random NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 749.0 0.00e+00 0.0000021 **** p < 1e-04 0.5035688 large
Random Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2339.0 4.71e-03 0.2826000 ns p = 0.2826 0.2582527 small
Random Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1713.0 6.50e-01 1.0000000 ns p = 1 0.0416846 small
Random Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 2121.0 9.25e-02 1.0000000 ns p = 1 0.1538017 small
Tournament Count Odds 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 626.0 0.00e+00 0.0000000 **** p < 1e-04 0.5625021 large
Tournament Count Odds 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1787.0 9.48e-01 1.0000000 ns p = 1 0.0062287 small
Tournament Count Odds 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1727.0 7.04e-01 1.0000000 ns p = 1 0.0349767 small
Tournament Logic-9 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 54.0 0.00e+00 0.0000000 **** p < 1e-04 0.8365662 large
Tournament Logic-9 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 496.0 0.00e+00 0.0000000 **** p < 1e-04 0.6247894 large
Tournament Logic-9 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 1225.0 2.57e-03 0.1542000 ns p = 0.1542 0.2755034 small
Tournament NK Landscape 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 0.0 0.00e+00 0.0000000 **** p < 1e-04 0.8624394 large
Tournament NK Landscape 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 32.0 0.00e+00 0.0000000 **** p < 1e-04 0.8471071 large
Tournament NK Landscape 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 148.0 0.00e+00 0.0000000 **** p < 1e-04 0.7922984 large
Tournament Sorting network 10 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 7.0 0.00e+00 0.0000000 **** p < 1e-04 0.8590854 large
Tournament Sorting network 100 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 55.0 0.00e+00 0.0000000 **** p < 1e-04 0.8360870 large
Tournament Sorting network 1000 value Phenotypic -> Phylogenetic Phylogenetic -> Phenotypic 60 60 217.0 0.00e+00 0.0000000 **** p < 1e-04 0.7584675 large