sim <-data.frame(guild =rep(c("Cerrado", "Abierto"), each =100),duration =c(rnorm(100, mean =0.03, sd =0.01), rnorm(100, mean =0.05, sd =0.01)))ggplot(sim, aes(x = guild, y = duration)) +geom_boxplot(fill =mako(10, alpha =0.3)[4]) +labs(x ="Ambiente", y ="Duración") +# remove y axis tick labelstheme_classic(base_size =30) +theme(axis.text.y=element_blank(),axis.ticks.y=element_blank() )
Code
sim2 <-data.frame(guild =rep(c("Cerrado", "Abierto"), each =100),rate =c(rnorm(100, mean =0.05, sd =0.01), rnorm(100, mean =0.032, sd =0.01)))ggplot(sim2, aes(x = guild, y = rate)) +geom_boxplot(fill =mako(10, alpha =0.3)[4]) +labs(x ="Ambiente", y ="Tasa de llamados") +# remove y axis tick labelstheme_classic(base_size =30) +theme(axis.text.y=element_blank(),axis.ticks.y=element_blank() )
Code
sim3 <-data.frame(guild =rep(c("Cerrado", "Abierto"), each =100),freq =c(rnorm(100, mean =0.05, sd =0.01), rnorm(100, mean =0.032, sd =0.01)))ggplot(sim3, aes(x = guild, y = freq)) +geom_boxplot(fill =mako(10, alpha =0.3)[4]) +labs(x ="Ambiente", y ="Frecuencia (kHz)") +# remove y axis tick labelstheme_classic(base_size =30) +theme(axis.text.y=element_blank(),axis.ticks.y=element_blank() )
6.2 Macroevolution
6.2.1 By guild
Code
est_bats <-readRDS("./data/processed/acoustic_analysis_data_2026.RDS")iter <-5000chains <-2priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))dur_mod <-brm(formula = duration ~ guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf) + (1| treatment),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/duration_macro_model.RDS" )priors <-c(# Population-level (fixed) effectsset_prior("normal(0, 1)", class ="b"),# Intercept - centered around plausible frequency value# Adjust mean based on your data (e.g., kHz for bat calls)set_prior("normal(0, 10)", class ="Intercept"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Residual standard deviationset_prior("exponential(1)", class ="sigma"))freq_mod <-brm(formula = freq ~ guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf) + (1| treatment),family =gaussian(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/freq_macro_model.RDS" )priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))rate_mod <-brm(formula = rate ~ guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf) + (1| treatment),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/rate_macro_model.RDS" )priors <-c(# Population-level effects# PCA scores usually range ~ -3 to 3set_prior("normal(0, 1)", class ="b"),# Intercept - centered at 0 (mean of PCA scores)set_prior("normal(0, 1)", class ="Intercept"),# Random effect standard deviations# Expect smaller variation than total variance (SD=1)set_prior("exponential(2)", class ="sd", group ="indiv"),set_prior("exponential(2)", class ="sd", group ="sp"),# Residual standard deviation# Should be less than 1 (total SD of PCA scores)set_prior("exponential(2)", class ="sigma"))pc1_mod <-brm(formula = pc1 ~ guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf) + (1| treatment),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/pc1_macro_model.RDS" )
est_bats <-readRDS("./data/processed/acoustic_analysis_data_2026.RDS")iter <-5000chains <-2priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))dur_sp_mod <-brm(formula = duration ~ sp + (1| indiv) + (1| sp) + (1| treatment),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/duration_sp_macro_model.RDS" )priors <-c(# Population-level (fixed) effectsset_prior("normal(0, 1)", class ="b"),# Intercept - centered around plausible frequency value# Adjust mean based on your data (e.g., kHz for bat calls)set_prior("normal(0, 10)", class ="Intercept"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Residual standard deviationset_prior("exponential(1)", class ="sigma"))freq_mod <-brm(formula = freq ~ sp + (1| indiv) + (1| sp) + (1| treatment),family =gaussian(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/freq_sp_macro_model.RDS" )priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))rate_mod <-brm(formula = rate ~ sp + (1| indiv) + (1| sp) + (1| treatment),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/rate_sp_macro_model.RDS" )priors <-c(# Population-level effects# PCA scores usually range ~ -3 to 3set_prior("normal(0, 1)", class ="b"),# Intercept - centered at 0 (mean of PCA scores)set_prior("normal(0, 1)", class ="Intercept"),# Random effect standard deviations# Expect smaller variation than total variance (SD=1)set_prior("exponential(2)", class ="sd", group ="indiv"),set_prior("exponential(2)", class ="sd", group ="sp"),# Residual standard deviation# Should be less than 1 (total SD of PCA scores)set_prior("exponential(2)", class ="sigma"))pc1_mod <-brm(formula = pc1 ~ sp + (1| indiv) + (1| sp) + (1| treatment),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/pc1_sp_macro_model.RDS" )
priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))dur_plast_mod <-brm(formula = duration ~ treatment + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/duration_plasticity_model.RDS")priors <-c(# Population-level (fixed) effectsset_prior("normal(0, 1)", class ="b"),# Intercept - centered around plausible frequency value# Adjust mean based on your data (e.g., kHz for bat calls)set_prior("normal(0, 10)", class ="Intercept"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Residual standard deviationset_prior("exponential(1)", class ="sigma"))freq_plast_mod <-brm(formula = freq ~ treatment + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),family =gaussian(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/freq_plasticity_model.RDS" )priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))rate_plast_mod <-brm(formula = rate ~ treatment + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/rate_plasticity_model.RDS" )priors <-c(# Population-level effects# PCA scores usually range ~ -3 to 3set_prior("normal(0, 1)", class ="b"),# Intercept - centered at 0 (mean of PCA scores)set_prior("normal(0, 1)", class ="Intercept"),# Random effect standard deviations# Expect smaller variation than total variance (SD=1)set_prior("exponential(2)", class ="sd", group ="indiv"),set_prior("exponential(2)", class ="sd", group ="sp"),# Residual standard deviation# Should be less than 1 (total SD of PCA scores)set_prior("exponential(2)", class ="sigma"))pc1_plast_mod <-brm(formula = pc1 ~ treatment + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/pc1_plasticity_model.RDS" )
mod <-readRDS("./data/processed/pc1_plasticity_model.RDS")# contrastscontrasts <-contrasts(fit = mod,predictor ="treatment",n.posterior =2000,level.sep =" VS ",html.table =FALSE,plot =TRUE,highlight =TRUE,fill = fill_color)
6.3.2 Habitat by guild
Code
iter <-10000chains <-4priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))dur_plast_mod <-brm(formula = duration ~ treatment * guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/duration_plasticity_interaction_model.RDS")priors <-c(# Population-level (fixed) effectsset_prior("normal(0, 1)", class ="b"),# Intercept - centered around plausible frequency value# Adjust mean based on your data (e.g., kHz for bat calls)set_prior("normal(0, 10)", class ="Intercept"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Residual standard deviationset_prior("exponential(1)", class ="sigma"))freq_plast_mod <-brm(formula = freq ~ treatment * guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),family =gaussian(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/freq_plasticity_interaction_model.RDS" )priors <-c(# Population-level effects (including intercept)# For log-link Gamma, intercept is on log scaleset_prior("normal(1, 2)", class ="Intercept"), # log-scale: exp(1) ≈ 2.7 mean durationset_prior("normal(0, 1)", class ="b"),# Random effect standard deviationsset_prior("exponential(1)", class ="sd", group ="indiv"),set_prior("exponential(1)", class ="sd", group ="sp"),# Gamma shape parameter (nu or shape)# Constrained to be positiveset_prior("exponential(1)", class ="shape"))rate_plast_mod <-brm(formula = rate ~ treatment * guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),family =Gamma(),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/rate_plasticity_interaction_model.RDS" )priors <-c(# Population-level effects# PCA scores usually range ~ -3 to 3set_prior("normal(0, 1)", class ="b"),# Intercept - centered at 0 (mean of PCA scores)set_prior("normal(0, 1)", class ="Intercept"),# Random effect standard deviations# Expect smaller variation than total variance (SD=1)set_prior("exponential(2)", class ="sd", group ="indiv"),set_prior("exponential(2)", class ="sd", group ="sp"),# Residual standard deviation# Should be less than 1 (total SD of PCA scores)set_prior("exponential(2)", class ="sigma"))pc1_plast_mod <-brm(formula = pc1 ~ treatment * guild + (1| indiv) + (1| sp) +ar(p =2, time = orig.start, gr = orig.sf),data = est_bats,prior = priors,chains = chains,iter = iter,file ="./data/processed/pc1_plasticity_interaction_model.RDS" )