aggregate(norm.latency ~ experiment, data = resp_time_df, FUN = mean)
experiment
norm.latency
female call
27.7992
female call | male courtship
25.8250
male courtship
25.0395
male trill
29.6180
male trill | female call
28.8122
Code
ggplot(resp_time_df,aes(x = experiment,y = stimuli.latency,color = experiment,fill = experiment)) +# add half-violin from {ggdist} packageggdist::stat_halfeye(# fill = fill_color,alpha =0.5,# custom bandwidthadjust = .5,# adjust heightwidth = .6,.width =0,# move geom to the crightjustification =-.2,point_colour =NA) +geom_boxplot(# fill = fill_color,width = .15,# remove outliersoutlier.shape =NA) +# add justified jitter from the {gghalves} packagegghalves::geom_half_point(# color = fill_color,# draw jitter on the leftside ="l",# control range of jitterrange_scale = .4,# add some transparencyalpha = .5,transformation = ggplot2::position_jitter(height =0)) +scale_color_viridis_d(option ="G", begin =0.3, end =0.8) +scale_fill_viridis_d(option ="G", begin =0.3, end =0.8, alpha =0.6) +theme_classic(base_size =20) +theme(legend.position ="none", axis.text.x =element_text(angle =45, hjust =1)) +labs(title ="Raw latency from previous stimuli by experiment", y ="Latency from previous stimuli", x ="Experiment type")
Code
ggplot(resp_time_df,aes(x = experiment,y = norm.latency,color = experiment,fill = experiment)) +# add half-violin from {ggdist} packageggdist::stat_halfeye(# fill = fill_color,alpha =0.5,# custom bandwidthadjust = .5,# adjust heightwidth = .6,.width =0,# move geom to the crightjustification =-.2,point_colour =NA) +geom_boxplot(# fill = fill_color,width = .15,# remove outliersoutlier.shape =NA) +# add justified jitter from the {gghalves} packagegghalves::geom_half_point(# color = fill_color,# draw jitter on the leftside ="l",# control range of jitterrange_scale = .4,# add some transparencyalpha = .5,transformation = ggplot2::position_jitter(height =0)) +scale_color_viridis_d(option ="G", begin =0.3, end =0.8) +scale_fill_viridis_d(option ="G", begin =0.3,end =0.8,alpha =0.6) +theme_classic(base_size =20) +# ylim(c(0, 75)) +theme(legend.position ="none", axis.text.x =element_text(angle =45, hjust =1)) +labs(title ="Standardized latency from previous stimuly by experiment", y ="Standardized latency", x ="Experiment type")
# Generate EMMs for the 'experiment' variableemms_experiment <-emmeans(mod, ~experiment)# Get pairwise contrasts between levels of 'experiment'contrast_experiment <-contrast(emms_experiment, method ="pairwise")# Display the contrastssumm_contrasts <-summary(contrast_experiment)names(summ_contrasts) <-c("Contrasts", "Estimate", "l-95% CI", "u-95% CI")# print estimatessumm_contrasts <-html_format_coef_table(summ_contrasts, fill =viridis(10)[7],highlight =TRUE)summ_contrasts
Contrasts
Estimate
l-95% CI
u-95% CI
1
female call - female call | male courtship
-1.083
-1.406
-0.768
2
female call - male courtship
-1.143
-1.474
-0.831
3
female call - male trill
-1.456
-1.786
-1.122
4
female call - male trill | female call
-1.251
-1.566
-0.922
5
female call | male courtship - male courtship
-0.057
-0.403
0.290
6
female call | male courtship - male trill
-0.371
-0.740
-0.030
7
female call | male courtship - male trill | female call
# Generate EMMs for the 'experiment' variableemms_experiment <-emmeans(mod, ~experiment)# Get pairwise contrasts between levels of 'experiment'contrast_experiment <-contrast(emms_experiment, method ="pairwise")# Display the contrastssumm_contrasts <-summary(contrast_experiment)names(summ_contrasts) <-c("Contrasts", "Estimate", "l-95% CI", "u-95% CI")# print estimatessumm_contrasts <-html_format_coef_table(summ_contrasts, fill =viridis(10)[7],highlight =TRUE)summ_contrasts
Contrasts
Estimate
l-95% CI
u-95% CI
1
female call - female call | male courtship
0.135
-0.200
0.453
2
female call - male courtship
0.080
-0.253
0.412
3
female call - male trill
-0.234
-0.573
0.099
4
female call - male trill | female call
-0.029
-0.359
0.299
5
female call | male courtship - male courtship
-0.057
-0.418
0.309
6
female call | male courtship - male trill
-0.370
-0.734
-0.001
7
female call | male courtship - male trill | female call
-0.164
-0.523
0.204
8
male courtship - male trill
-0.312
-0.693
0.057
9
male courtship - male trill | female call
-0.109
-0.489
0.248
10
male trill - male trill | female call
0.204
-0.178
0.569
3.0.3.2.1.3 Posterior predictive checks
Code
custom_ppc(fit = mod)
3.1 Vocal output
Code
# get response timesvocal_output_list <-lapply(unique(dat$sound.files), function(x) {# print(x) X <- dat[dat$sound.files == x, ] X <- X[order(X$start), ] counts <-sum(X$Name =="fem_resp") out_df <-data.frame(sound.files = x, counts = counts)return(out_df)})vocal_output_df <-do.call(rbind, vocal_output_list)
# Generate EMMs for the 'experiment' variableemms_experiment <-emmeans(mod, ~experiment)# Get pairwise contrasts between levels of 'experiment'contrast_experiment <-contrast(emms_experiment, method ="pairwise")# Display the contrastssumm_contrasts <-summary(contrast_experiment)names(summ_contrasts) <-c("Contrasts", "Estimate", "l-95% CI", "u-95% CI")# print estimatessumm_contrasts <-html_format_coef_table(summ_contrasts, fill =viridis(10)[7],highlight =TRUE)summ_contrasts
Contrasts
Estimate
l-95% CI
u-95% CI
1
female call - female call | male courtship
0.172
-0.220
0.548
2
female call - male courtship
0.281
-0.096
0.664
3
female call - male trill
0.278
-0.109
0.653
4
female call - male trill | female call
0.212
-0.165
0.599
5
female call | male courtship - male courtship
0.109
-0.284
0.486
6
female call | male courtship - male trill
0.107
-0.276
0.481
7
female call | male courtship - male trill | female call
# Generate EMMs for the 'experiment' variableemms_experiment <-emmeans(mod, ~experiment)# Get pairwise contrasts between levels of 'experiment'contrast_experiment <-contrast(emms_experiment, method ="pairwise")# Display the contrastssumm_contrasts <-summary(contrast_experiment)names(summ_contrasts) <-c("Contrasts", "Estimate", "l-95% CI", "u-95% CI")# print estimatessumm_contrasts <-html_format_coef_table(summ_contrasts, fill =viridis(10)[7],highlight =TRUE)summ_contrasts
Contrasts
Estimate
l-95% CI
u-95% CI
1
female call - female call | male courtship
-0.815
-1.140
-0.478
2
female call - male courtship
-0.703
-1.027
-0.369
3
female call - male trill
-0.707
-1.031
-0.365
4
female call - male trill | female call
-0.771
-1.111
-0.449
5
female call | male courtship - male courtship
0.110
-0.221
0.438
6
female call | male courtship - male trill
0.106
-0.224
0.429
7
female call | male courtship - male trill | female call