Preliminaries

Load libraries

library(knitr)       #for R Markdown
library(MASS)        #for negative binomial glm (glm.nb)
library(lme4)        #for mixed models
library(emmeans)     #for posthoc
library(car)         #for Anova
library(survival)    #for survival analysis
library(coxme)
library(rptR)        #for repeatability analysis
library(MuMIn)       #for model selection (dredge)
library(ggfortify)   #for plotting survival analysis
library(ggsignif)    #for labeling significance in ggplots
library(GGally)     #for correlation matrix
library(tidyverse)   #for data processing, put last to avoid function masking

Load data and clean up

data_raw <- read.csv("data_maze_062926.csv",                 
                 # to avoid reading errors
                 fileEncoding="UTF-8-BOM", na.strings = "")


data <- data_raw %>%
  
  #drop trailing NA reads
  filter(!if_all(everything(), is.na)) %>%
  
  #correct variable types
  mutate_at(c("ID","sex","assayer","trial","shelter_YN","shelter_quadrant"), as.factor) %>%
  mutate_at(c("found_date","morph_date","assay_date"), lubridate::mdy) %>%
  
  #derive variables
  mutate(
    
    #life history variables
    lat_meta = as.numeric(morph_date - found_date),
    age = as.numeric(assay_date - morph_date),
         
    #performance variables     
    lat_shelter_from_movement = as.numeric(lat_shelter - lat_move),
    lines_rate = lines_crossed/lat_trial,
    grids_rate = grids_explored/lat_trial,
    
    #for survival analysis and plotting
    shelter_10 = recode(shelter_YN, "Y" = 1, "N" = 0),
    move_10 = ifelse(lat_move==lat_trial, 0, 1)
    
    )

Make an aggregrate version of the dataset by frog ID

data_ind <- data %>%
  group_by(ID) %>%
  reframe(lat_move_avg = mean(lat_move),
            lat_shelter_avg = mean(lat_shelter),
            lat_shelter_mov_avg = mean(lat_shelter_from_movement),
            lat_shelter_improv = lat_shelter[trial == 1] - lat_shelter[trial == 5],
            lines_rate_avg = mean(lines_rate),
            grids_rate_avg = mean(grids_rate),
            prop_complete = sum(shelter_YN == "Y")/n(),
            found_date = mean(found_date),
            morph_date = mean(morph_date), 
            age = mean(age),
            lat_meta = mean(lat_meta)
            )

Prelim dataset checks

All completed 5?

data %>% select(ID) %>% table()
## ID
## V071 V084 V085 V108 V109 V110 V111 V112 V113 V117 V118 V124 V125 V178 V179 V183 
##    5    5    5    5    5    5    5    5    5    5    5    5    5    5    5    5 
## V186 V187 V251 V252 
##    5    5    5    5

Sample size

data %>% select(ID) %>% n_distinct()
## [1] 20

Personality (repeatability)

Are behaviors repeatable over time?

  • rpt{rptR}: Repeatability Estimation
  • P_permut: p-value from permutation test (more robust)
  • LRT_P: p-value from likelihood ratio test

All three personality axes are repeatable

Boldness

rpt_result <- rpt(lat_move ~ (1 | ID), 
                  grname = "ID", 
                  data = data, 
                  datatype = "Gaussian", 
                  nboot = 1000, 
                  npermut = 1000)
## Bootstrap Progress:
## Permutation Progress for ID :
summary(rpt_result)$rpt %>% kable(digits = 3)
R SE 2.5% 97.5% P_permut LRT_P
rpt 0.183 0.095 0 0.362 0.007 0.017

Activity

rpt_result <- rpt(lines_rate ~ (1 | ID), 
                  grname = "ID", 
                  data = data, 
                  datatype = "Gaussian", 
                  nboot = 1000, 
                  npermut = 1000)
## Bootstrap Progress:
## Permutation Progress for ID :
summary(rpt_result)$rpt %>% kable(digits = 3)
R SE 2.5% 97.5% P_permut LRT_P
rpt 0.336 0.111 0.098 0.534 0.002 0

Exploration

rpt_result <- rpt(grids_rate ~ (1 | ID), 
                  grname = "ID", 
                  data = data, 
                  datatype = "Gaussian", 
                  nboot = 1000, 
                  npermut = 1000)
## Bootstrap Progress:
## Permutation Progress for ID :
summary(rpt_result)$rpt %>% kable(digits = 3)
R SE 2.5% 97.5% P_permut LRT_P
rpt 0.257 0.106 0.033 0.451 0.003 0.002

Analysis: changes across trials

boldness

mod <- coxme(Surv(lat_move, move_10) ~ as.numeric(trial) + (1 | ID), 
                     data = data  )

summary(mod)$coefficients
##                        coef exp(coef)   se(coef)    z          p
## as.numeric(trial) 0.1242415  1.132289 0.06870593 1.81 0.07055862

activity

mod <- lmer(sqrt(lines_rate) ~ as.numeric(trial) + (1|ID),
            data = data )

summary(mod)$coefficients
##                      Estimate  Std. Error  t value
## (Intercept)       0.169356240 0.019072654 8.879532
## as.numeric(trial) 0.005158824 0.004401773 1.171988
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: sqrt(lines_rate)
##                    Chisq Df Pr(>Chisq)
## as.numeric(trial) 1.3736  1     0.2412

exploration

mod <- lmer(sqrt(grids_rate) ~ as.numeric(trial) + (1|ID),
            data = data )

summary(mod)$coefficients
##                       Estimate  Std. Error    t value
## (Intercept)        0.124403605 0.018512015  6.7201547
## as.numeric(trial) -0.001464811 0.004637191 -0.3158832
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: sqrt(grids_rate)
##                    Chisq Df Pr(>Chisq)
## as.numeric(trial) 0.0998  1     0.7521

Box plots - by individual

Ordered by exploration median

fig_box_boldness <- 
  ggplot(data, 
       aes(x = fct_reorder(ID, log10(grids_rate)),
           y = lat_move)) +
  geom_boxplot(aes(fill = fct_reorder(ID, log10(grids_rate))),
               alpha = 0.8) +
  geom_jitter(width = 0.2, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(20, palette = "Mako"))) +
  
  labs(x = "Frog ID", y = "Latency to Move (s)") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+ 
  scale_y_log10()


fig_box_activity <- 
  ggplot(data, 
       aes(x = fct_reorder(ID, log10(grids_rate), .fun = median),
           y = lines_rate)) +
  geom_boxplot(aes(fill = fct_reorder(ID, log10(grids_rate), .fun = median)),
               alpha = 0.8) +
  geom_jitter(width = 0.2, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(20, palette = "Mako"))) +
  
  labs(x = "Frog ID", y = "# Lines crossed / Trial time (s)") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+ 
  scale_y_log10()


fig_box_exploration <- 
  ggplot(data, 
       aes(x = fct_reorder(ID, log10(grids_rate), .fun = median),
           y = grids_rate)) +
  geom_boxplot(aes(fill = fct_reorder(ID, log10(grids_rate), .fun = median)),
               alpha = 0.8) +
  geom_jitter(width = 0.2, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(20, palette = "Mako"))) +
  
  labs(x = "Frog ID", y = "# Grids explored / Trial time (s)") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+ 
  scale_y_log10()
egg::ggarrange(fig_box_boldness, fig_box_activity, fig_box_exploration,
               nrow = 3,
               labels = c("A","B","C"))

Box plot - by trial

fig_box_boldness_trial <- 
  ggplot(data, 
       aes(x = trial,
           y = lat_move,
           fill = trial)) +
  geom_boxplot(alpha = 0.8) +
  geom_jitter(width = 0.2, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(5, palette = "Mako"))) +
  
  labs(x = "Trial number", y = "Latency to Move (s)") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+ 
  scale_y_log10()


fig_box_activity_trial <- 
  ggplot(data, 
       aes(x = trial,
           y = lines_rate,
           fill = trial)) +
  geom_boxplot(alpha = 0.8) +
  geom_jitter(width = 0.2, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(5, palette = "Mako"))) +
  
  labs(x = "Trial number", y = "# Lines crossed / Trial time (s)") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+ 
  scale_y_log10()


fig_box_exploration_trial <- 
  ggplot(data, 
       aes(x = trial,
           y = grids_rate,
           fill = trial)) +
  geom_boxplot(alpha = 0.8) +
  geom_jitter(width = 0.2, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(5, palette = "Mako"))) +
  
  labs(x = "Trial number", y = "# Grids explored / Trial time (s)") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+ 
  scale_y_log10()
egg::ggarrange(fig_box_boldness_trial, fig_box_activity_trial, fig_box_exploration_trial,
               nrow = 3,
               labels = c("A","B","C"))

Behavioral Syndrome

Are different personality axes correlated?

Stats

boldness-activity

mod_boldness_activity <- lmer(lines_rate ~ lat_move + (1|ID),
                              data = data)

summary(mod_boldness_activity)$coefficients
##                  Estimate   Std. Error   t value
## (Intercept)  4.788897e-02 8.398764e-03  5.701907
## lat_move    -9.192473e-05 5.321059e-05 -1.727565
Anova(mod_boldness_activity)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: lines_rate
##           Chisq Df Pr(>Chisq)  
## lat_move 2.9845  1    0.08407 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

boldness-exploration

mod_boldness_exploration <- lmer(grids_rate ~ lat_move + (1|ID),
                              data = data)

summary(mod_boldness_exploration)$coefficients
##                  Estimate   Std. Error    t value
## (Intercept)  2.363989e-02 0.0077948390  3.0327622
## lat_move    -3.934652e-05 0.0000539086 -0.7298747
Anova(mod_boldness_exploration)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: grids_rate
##           Chisq Df Pr(>Chisq)
## lat_move 0.5327  1     0.4655

activity-exploration

mod_activity_exploration <- lmer(grids_rate ~ lines_rate + (1|ID),
                              data = data)

summary(mod_activity_exploration)$coefficients
##                Estimate  Std. Error   t value
## (Intercept) -0.01579186 0.003095678 -5.101262
## lines_rate   0.89123158 0.042355885 21.041505
Anova(mod_activity_exploration)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: grids_rate
##             Chisq Df Pr(>Chisq)    
## lines_rate 442.75  1  < 2.2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Correlation plots - by trial

fig_boldness_activity <- 
  ggplot(data, aes(x = lat_move, y = lines_rate)) +
  geom_point(color = "black", size = 2) +
  geom_smooth(method = lm, ,alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to move (s)") +
  ylab("# Lines crossed / Trial time (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)

fig_boldness_exploration <- 
  ggplot(data, aes(x = lat_move, y = grids_rate)) +
  geom_point(color = "black", size = 2) +
  geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to move (s)") +
  ylab("# Grids explored / Trial time (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)

fig_activity_exploration <- 
  ggplot(data, aes(x = lines_rate, y = grids_rate)) +
  geom_point(color = "black", size = 2) +
  geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("# Lines crossed / Trial time (s)") +
  ylab("# Grids explored / Trial time (s)") +
  
  theme_bw(base_size = 15) +
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)
egg::ggarrange(fig_boldness_activity, fig_boldness_exploration, fig_activity_exploration,
               nrow = 1,
               labels = c("A","B","C"))

Correlation Plots - by individual

fig_boldness_activity_ind <- 
  ggplot(data_ind, aes(x = lat_move_avg, y = lines_rate_avg)) +
  
  # for overlaying trial level data - doesn't look good on the plot though
  # geom_point(data = data, aes(x = lat_move, y = lines_rate),
  #            color = "grey80", size = 1) +
  
  geom_point(color = "black", size = 5) +
  geom_smooth(method = lm, alpha = 0.2, linetype = "dashed", size = 2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to move (sec)") +
  ylab("# Lines crossed/sec") +
  
  theme_bw(base_size = 20)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_rect(linewidth = 2, fill = NA),
        axis.title.x = element_text(colour = "#D86ECC", face = "bold"),
        axis.title.y = element_text(colour = "#00B050", face = "bold"),
        aspect.ratio=1)


fig_boldness_exploration_ind <- 
  ggplot(data_ind, aes(x = lat_move_avg, y = grids_rate_avg)) +
  geom_point(color = "black", size = 5) +
  geom_smooth(method = lm, alpha = 0.2, linetype = "dashed", size = 2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to move (sec)") +
  ylab("# Grids explored/sec") +
  
  theme_bw(base_size = 20)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_rect(linewidth = 2, fill = NA),
        axis.title.x = element_text(colour = "#D86ECC", face = "bold"),
        axis.title.y = element_text(colour = "#D16830", face = "bold"),
        aspect.ratio=1)


fig_activity_exploration_ind <- 
  ggplot(data_ind, aes(x = lines_rate_avg, y = grids_rate_avg)) +
  geom_point(color = "black", size = 5) +
  geom_smooth(method = lm, alpha = 0.2, size = 2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("# Lines crossed/sec") +
  ylab("# Grids explored/sec") +
  
  theme_bw(base_size = 20)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_rect(linewidth = 2, fill = NA),
        axis.title.x = element_text(colour = "#D16830", face = "bold"),
        axis.title.y = element_text(colour = "#D86ECC", face = "bold"),
        aspect.ratio=1)
egg::ggarrange(fig_boldness_activity_ind, fig_boldness_exploration_ind, fig_activity_exploration_ind,
               nrow = 3)

For graph output

# panel_syndrome <-
#   egg::ggarrange(fig_boldness_activity_ind, fig_boldness_exploration_ind, fig_activity_exploration_ind,
#                nrow = 3)
# 
# ggsave("Behavioral Syndrome.svg", panel_syndrome, height = 14, width = 5, dpi = 500)

Spatial Learning

Do frogs solve maze quicker and with less error over time?

Analysis

Latency to shleter

Treat trial as factor

coef: Log hazard ratio for that trial vs reference (trial 1)

mod_survival<- coxme(Surv(lat_shelter, shelter_10) ~ trial + (1 | ID), 
                     data = data %>% filter(trial != "6") %>% droplevels())

summary(mod_survival)$coefficients
##              coef exp(coef)  se(coef)     z            p
## trial2 -1.7443476 0.1747590 0.5691430 -3.06 0.0021776663
## trial3 -0.6264779 0.5344710 0.4466630 -1.40 0.1607439029
## trial4 -2.1055527 0.1217784 0.6185456 -3.40 0.0006639751
## trial5 -0.7837793 0.4566768 0.4779481 -1.64 0.1010293882

Overall effect of trial

mod_survival_0 <- coxme(Surv(lat_shelter, shelter_10) ~ (1 | ID), 
                     data = data %>% filter(trial != "6") %>% droplevels())

anova(mod_survival, mod_survival_0)
## Analysis of Deviance Table
##  Cox model: response is  Surv(lat_shelter, shelter_10)
##  Model 1: ~trial + (1 | ID)
##  Model 2: ~(1 | ID)
##    loglik  Chisq Df P(>|Chi|)   
## 1 -160.19                       
## 2 -168.88 17.367  4   0.00164 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Treat trial as numeric
mod_survival<- coxme(Surv(lat_shelter, shelter_10) ~ as.numeric(trial) + (1 | ID), 
                     data = data %>% filter(trial != "6") %>% droplevels())

summary(mod_survival)$coefficients
##                         coef exp(coef)  se(coef)     z         p
## as.numeric(trial) -0.1985544 0.8199152 0.1251919 -1.59 0.1127394

Number of wrong turns

mod <- glmer(wrong_turns ~ as.numeric(trial) + (1 | ID), 
             family = poisson,
             data = data %>% filter(trial != 6, path_seq != 1),
             control = glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
summary(mod)
## Generalized linear mixed model fit by maximum likelihood (Laplace
##   Approximation) [glmerMod]
##  Family: poisson  ( log )
## Formula: wrong_turns ~ as.numeric(trial) + (1 | ID)
##    Data: data %>% filter(trial != 6, path_seq != 1)
## Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
## 
##      AIC      BIC   logLik deviance df.resid 
##    486.9    494.6   -240.4    480.9       92 
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0583 -0.9619 -0.1791  0.9214  2.9458 
## 
## Random effects:
##  Groups Name        Variance Std.Dev.
##  ID     (Intercept) 0.251    0.501   
## Number of obs: 95, groups:  ID, 20
## 
## Fixed effects:
##                   Estimate Std. Error z value Pr(>|z|)    
## (Intercept)        1.23537    0.16272   7.592 3.15e-14 ***
## as.numeric(trial)  0.04777    0.03383   1.412    0.158    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## as.nmrc(tr) -0.635

Spagetti plot - latency

  ggplot(data , 
         aes(x = trial, y = lat_shelter, group = ID, color = ID)) +
  geom_line(alpha = 0.9, size = 1) +
  labs(x = "Trial number", y = "Latency to Shelter (s)") +
  
  scale_color_manual(values = rev(hcl.colors(20, palette = "Mako")),
                     name = "ID") +
  
  theme_classic(base_size = 15) +
  theme(legend.position = "none") + 
  scale_y_log10()

Boxplot - wrong turns

  ggplot(data %>% filter(trial != 6, lines_crossed > 0), 
       aes(x = trial,
           y = wrong_turns,
           fill = trial)) +
  geom_boxplot(alpha = 0.8) +
  geom_jitter(width = 0.1, height = 0, alpha = 0.5) +
  
  scale_fill_manual(values = rev(hcl.colors(5, palette = "Mako"))) +
  
  labs(x = "Trial number", y = "Number of wrong turns") +
  guides(fill = "none")+ 
  theme_classic(base_size = 15)+
  theme(legend.position = "none") 

Accumulations plot

data_plot <- 
  survfit(Surv(lat_shelter, shelter_10) ~ trial,
          data = data %>% filter(trial != "6")) %>%  #filter out the accidental 6th trials
  fortify(surv.connect = TRUE) #make into a dataframe

fig_shelter_lat <- 
  
  ggplot(data_plot, aes(time, 1-surv, color = strata)) +
  
  #survival plot
  geom_step(linewidth = 1) +
  
  # axes and legends
  labs(x = "Time since start of trial (s)", y = "Proportion Frogs in Shelter") +
  
  scale_color_manual(values = rev(hcl.colors(7, palette = "BuPu")[1:5]),
                     name = "Trial number") +
  
  scale_y_continuous(expand = c(0,0), limit = c(0,0.61),
                     labels = scales::percent) +
  
  # adjust element themes
  theme_classic(base_size = 15)

fig_shelter_lat

## Spatial Learning vs Life history

Is spatial navigation ability correlated with life history?

stats

mod<- lm(prop_complete ~ lat_meta, data = data_ind)

summary(mod)$coefficients
##                Estimate Std. Error    t value  Pr(>|t|)
## (Intercept) -1.12670157 1.41276640 -0.7975144 0.4394770
## lat_meta     0.02460733 0.02378201  1.0347034 0.3196726
mod<- lm(prop_complete ~ age, data =  data_ind)

summary(mod)$coefficients
##                Estimate  Std. Error  t value    Pr(>|t|)
## (Intercept) 0.257405644 0.085883725 2.997141 0.007733336
## age         0.000173064 0.000074644 2.318525 0.032389004

figure

fig_meta_comp <-
  ggplot(data_ind ,
         aes(x = lat_meta, y = prop_complete)) +
  geom_point(color = "black", size = 2) +
  #geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to Metamorphose (days)") +
  ylab("Percentage of Success (%)") +
  scale_y_continuous(labels = scales::percent) +  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)


fig_age_comp <-
  ggplot(data_ind,
         aes(x = age, y = prop_complete)) +
  geom_point(color = "black", size = 2) +

  geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Age (days)") +
  ylab("Percentage of Success (%)") +
  scale_y_continuous(labels = scales::percent) +
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1) 
egg::ggarrange(fig_meta_comp, fig_age_comp,
               nrow = 1,
               labels = c("A","B"))

# panel_LH <-
#   egg::ggarrange(fig_meta_comp, fig_age_comp, nrow = 1)
# 
# ggsave("LifeHistory.jpg", panel_LH, width = 9, height = 4, dpi = 300)

Spatial Navigation vs Personality

Is spatial navigation ability correlated with personality?

stats

mod<- lm(prop_complete ~ lat_move_avg, data =  data_ind)
summary(mod)$coefficients
##                  Estimate  Std. Error    t value    Pr(>|t|)
## (Intercept)  0.3909784166 0.126371120 3.09389057 0.006262438
## lat_move_avg 0.0001182538 0.001393686 0.08484968 0.933317518
mod<- lm(prop_complete ~ lines_rate_avg, data = data_ind)
summary(mod)$coefficients
##                 Estimate Std. Error  t value    Pr(>|t|)
## (Intercept)    0.1843953 0.08857896 2.081705 0.051915160
## lines_rate_avg 5.2745997 1.69667049 3.108794 0.006061556
mod<- lm(prop_complete ~ grids_rate_avg, data =  data_ind)
summary(mod)$coefficients
##                 Estimate Std. Error  t value     Pr(>|t|)
## (Intercept)    0.3045918 0.07421413 4.104229 0.0006659262
## grids_rate_avg 4.6229060 2.08126935 2.221195 0.0394055730

figure

fig_comp_boldness <-
  ggplot(data_ind ,
         aes(x = lat_move_avg, y = prop_complete)) +
  geom_point(color = "black", size = 5) +
  geom_smooth(method = lm, alpha = 0.2, 
              linetype = "dashed", size = 1.5,
              color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to move (sec)") +
  ylab("Percentage of Success (%)") +
  scale_y_continuous(labels = scales::percent) +  
  theme_bw(base_size = 20)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_rect(linewidth = 2, fill = NA),
        axis.title.x = element_text(colour = "#D86ECC", face = "bold"),
        axis.title.y = element_text(face = "bold"),
        aspect.ratio=1)

fig_comp_activity <-
  ggplot(data_ind ,
         aes(x = lines_rate_avg, y = prop_complete)) +
  geom_point(color = "black", size = 5) +
  geom_smooth(method = lm, alpha = 0.2, 
              linetype = "dashed", size = 1.5,
              color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Lines crossed/sec") +
  ylab("Percentage of Success (%)") +
  scale_y_continuous(labels = scales::percent) +  
  theme_bw(base_size = 20)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_rect(linewidth = 2, fill = NA),
        axis.title.x = element_text(colour = "#00B050", face = "bold"),
        axis.title.y = element_text(face = "bold"),
        aspect.ratio=1)


fig_comp_exploration <-
  ggplot(data_ind ,
         aes(x = grids_rate_avg, y = prop_complete)) +
  geom_point(color = "black", size = 5) +
  geom_smooth(method = lm, alpha = 0.2, 
              linetype = "dashed", size = 1.5,
              color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Grids explored/sec") +
  ylab("Percentage of Success (%)") +
  scale_y_continuous(labels = scales::percent) +  
  theme_bw(base_size = 20)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        panel.border = element_rect(linewidth = 2, fill = NA),
        axis.title.x = element_text(colour = "#D16830", face = "bold"),
        axis.title.y = element_text(face = "bold"),
        aspect.ratio=1)
egg::ggarrange(fig_comp_boldness,fig_comp_activity, fig_comp_exploration,
               nrow = 1)

# spacer <-ggplot() + theme_void()
# 
# panel_all <-
#   egg::ggarrange(fig_boldness_activity_ind, spacer , fig_comp_boldness,
#                  fig_boldness_exploration_ind, spacer  , fig_comp_activity, 
#                  fig_activity_exploration_ind,spacer , fig_comp_exploration,
#                  ncol = 3, widths = c(5,1,5))
# 
# ggsave("Fig_all.svg", panel_all, width = 12, height = 14, dpi = 500)

Personality vs Life History

Is personality correlated with life history traits?

Analyses

Boldness-Meta time

mod<- lmer(lat_move ~ lat_meta + (1|ID), data = data)
summary(mod)$coefficients
##               Estimate Std. Error    t value
## (Intercept) 281.612565 263.125160  1.0702609
## lat_meta     -3.558639   4.429357 -0.8034211
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: lat_move
##           Chisq Df Pr(>Chisq)
## lat_meta 0.6455  1     0.4217
mod <- lm (lat_move_avg ~ lat_meta, data = data_ind )
summary(mod)
## 
## Call:
## lm(formula = lat_move_avg ~ lat_meta, data = data_ind)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -62.570 -16.491  -6.970   6.082 149.430 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)
## (Intercept)  281.613    263.125   1.070    0.304
## lat_meta      -3.559      4.429  -0.803    0.436
## 
## Residual standard error: 49.98 on 13 degrees of freedom
##   (5 observations deleted due to missingness)
## Multiple R-squared:  0.0473, Adjusted R-squared:  -0.02598 
## F-statistic: 0.6455 on 1 and 13 DF,  p-value: 0.4362

Activity-Meta time

mod<- lmer(lines_rate ~ lat_meta + (1|ID),
                              data = data )

summary(mod)$coefficients
##                 Estimate  Std. Error    t value
## (Intercept)  0.116226315 0.196559564  0.5913033
## lat_meta    -0.001323033 0.003308815 -0.3998512
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: lines_rate
##           Chisq Df Pr(>Chisq)
## lat_meta 0.1599  1     0.6893
mod <- lm (lines_rate_avg ~ lat_meta, data = data_ind )
summary(mod)
## 
## Call:
## lm(formula = lines_rate_avg ~ lat_meta, data = data_ind)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.034591 -0.015751 -0.010996 -0.002277  0.115265 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.116226   0.196560   0.591    0.564
## lat_meta    -0.001323   0.003309  -0.400    0.696
## 
## Residual standard error: 0.03734 on 13 degrees of freedom
##   (5 observations deleted due to missingness)
## Multiple R-squared:  0.01215,    Adjusted R-squared:  -0.06384 
## F-statistic: 0.1599 on 1 and 13 DF,  p-value: 0.6958

Exploration-Meta time

mod<- lmer(grids_rate ~ lat_meta + (1|ID),
                              data = data )

summary(mod)$coefficients
##                Estimate  Std. Error    t value
## (Intercept)  0.11386561 0.180567596  0.6305983
## lat_meta    -0.00158468 0.003039612 -0.5213431
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: grids_rate
##           Chisq Df Pr(>Chisq)
## lat_meta 0.2718  1     0.6021
mod <- lm (grids_rate_avg ~ lat_meta, data = data_ind)
summary(mod)
## 
## Call:
## lm(formula = grids_rate_avg ~ lat_meta, data = data_ind)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.020428 -0.014189 -0.010704 -0.003244  0.114308 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)
## (Intercept)  0.113866   0.180568   0.631    0.539
## lat_meta    -0.001585   0.003040  -0.521    0.611
## 
## Residual standard error: 0.0343 on 13 degrees of freedom
##   (5 observations deleted due to missingness)
## Multiple R-squared:  0.02048,    Adjusted R-squared:  -0.05487 
## F-statistic: 0.2718 on 1 and 13 DF,  p-value: 0.6109

Boldness-Age

mod<- lmer(lat_move ~ age + (1|ID),
                              data = data )

summary(mod)$coefficients
##                Estimate  Std. Error   t value
## (Intercept) 65.33032531 16.13299881 4.0494843
## age          0.01330154  0.01402033 0.9487324
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: lat_move
##      Chisq Df Pr(>Chisq)
## age 0.9001  1     0.3428
mod <- lm (lat_move_avg ~ age, data = data_ind )
summary(mod)
## 
## Call:
## lm(formula = lat_move_avg ~ age, data = data_ind)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -56.533 -27.595  -5.201  14.914 158.614 
## 
## Coefficients:
##             Estimate Std. Error t value Pr(>|t|)    
## (Intercept) 65.11093   16.13460   4.035 0.000776 ***
## age          0.01357    0.01402   0.968 0.346097    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 50.36 on 18 degrees of freedom
## Multiple R-squared:  0.04944,    Adjusted R-squared:  -0.003373 
## F-statistic: 0.9361 on 1 and 18 DF,  p-value: 0.3461

Activity-Age

mod<- lmer(lines_rate ~ age + (1|ID),
                              data = data )

summary(mod)$coefficients
##                 Estimate   Std. Error   t value
## (Intercept) 3.343301e-02 1.070583e-02 3.1228771
## age         9.033456e-06 9.303288e-06 0.9709961
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: lines_rate
##      Chisq Df Pr(>Chisq)
## age 0.9428  1     0.3316
mod <- lm (lines_rate_avg ~ age, data = data_ind )
summary(mod)
## 
## Call:
## lm(formula = lines_rate_avg ~ age, data = data_ind)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.032141 -0.015469 -0.009619  0.007670  0.119060 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)   
## (Intercept) 3.367e-02  1.071e-02   3.144  0.00561 **
## age         8.748e-06  9.306e-06   0.940  0.35963   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03342 on 18 degrees of freedom
## Multiple R-squared:  0.0468, Adjusted R-squared:  -0.006159 
## F-statistic: 0.8837 on 1 and 18 DF,  p-value: 0.3596

Exploration-Age

mod<- lmer(grids_rate ~ age + (1|ID),
                              data = data )

summary(mod)$coefficients
##                 Estimate   Std. Error   t value
## (Intercept) 1.745193e-02 9.764255e-03 1.7873281
## age         3.867053e-06 8.485327e-06 0.4557341
Anova(mod)
## Analysis of Deviance Table (Type II Wald chisquare tests)
## 
## Response: grids_rate
##      Chisq Df Pr(>Chisq)
## age 0.2077  1     0.6486
mod <- lm (grids_rate_avg ~ age, data = data_ind )
summary(mod)
## 
## Call:
## lm(formula = grids_rate_avg ~ age, data = data_ind)
## 
## Residuals:
##       Min        1Q    Median        3Q       Max 
## -0.015656 -0.011486 -0.008540 -0.006583  0.118879 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)  
## (Intercept) 1.752e-02  9.766e-03   1.794   0.0897 .
## age         3.787e-06  8.488e-06   0.446   0.6608  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.03048 on 18 degrees of freedom
## Multiple R-squared:  0.01094,    Adjusted R-squared:  -0.04401 
## F-statistic: 0.1991 on 1 and 18 DF,  p-value: 0.6608

Figure

For non-significant correlations, fitted line removed

Latency to Metamorphosis

fig_meta_boldness <-
  ggplot(data_ind, aes(x = lat_meta, y = lat_move_avg)) +
  geom_point(color = "black", size = 2) +
 # geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to Metamorphose (days)") +
  ylab("Latency to Move (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1) +
  scale_y_log10()
  
fig_meta_activity <-
  ggplot(data_ind, aes(x = lat_meta, y = lines_rate_avg)) +
  geom_point(color = "black", size = 2) +
  # geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to Metamorphose (days)") +
  ylab("# Lines crossed / Trial time (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)  + 
  scale_y_log10()
  
fig_meta_exploration <-
  ggplot(data_ind, aes(x = lat_meta, y = grids_rate_avg)) +
  geom_point(color = "black", size = 2) +
  # geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Latency to Metamorphose (days)") +
  ylab("# Grids explored / Trial time (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)  + 
  scale_y_log10()  

Age at trial (With the outlier age removed)

fig_age_boldness <-
  ggplot(data_ind ,
         aes(x = age, y = lat_move_avg)) +
  geom_point(color = "black", size = 2) +
  # geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Age (days)") +
  ylab("Latency to Move (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1) +
  scale_y_log10()
  
fig_age_activity <-
  ggplot(data_ind ,
         aes(x = age, y = lines_rate_avg)) +
  geom_point(color = "black", size = 2) +
 # geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Age (days)") +
  ylab("# Lines crossed / Trial time (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)  + 
  scale_y_log10()
  
fig_age_exploration <-
  ggplot(data_ind,
         aes(x = age, y = grids_rate_avg)) +
  geom_point(color = "black", size = 2) +
  # geom_smooth(method = lm, alpha = 0.2, color = "SteelBlue", fill = "SteelBlue")+
  
  xlab("Age (days)") +
  ylab("# Grids explored / Trial time (s)") +
  
  theme_bw(base_size = 15)+
  theme(panel.grid.major = element_blank(),
        panel.grid.minor = element_blank(),
        aspect.ratio=1)  + 
  scale_y_log10()  
egg::ggarrange(fig_meta_boldness, fig_meta_activity, fig_meta_exploration,  
               fig_age_boldness, fig_age_activity, fig_age_exploration,
               nrow = 2,
               labels = c("A","B","C", "D", "E", "F"))