Statistical analysis and code for: A high-throughput and sensitive method for food preference assays in walking insects

Thomas Wagner1*, Henrique Galante1, Tomer J. Czaczkes1

1 Animal Comparative Economics Laboratory, Department of Zoology and Evolutionary Biology, University of Regensburg, 93053 Regensburg, Germany

* Corresponding Author:


This document contains the statistical analysis output for the manuscript. https://doi.org/10.5281/zenodo.10953783 provides the entire raw data on which this analysis is based and the code used to process it. Note that much of the analysis is divided into sections using tabs. Click on the section you wish to inspect, and scroll down for the full analysis.


1 Setup

Load packages

require(betareg) # For beta regression
require(car) # To assess model fit
require(DHARMa) # To evaluate model fit
require(dplyr) # For data wrangling
require(emmeans) # For post-hoc analysis
require(ggplot2) # For plots
require(lme4) # Linear mixed-effects models
require(lmtest) # To assess model fit
require(MuMIn) # For adjusted R^2
require(stringr) # For handling strings
require(tidyr) # For data wrangling

Clean-up

rm(list = ls()) # Remove all variables/objects
graphics.off() # Close any open graphics
set.seed(11122) # Ensure all results are reproducible

Load data

linear_spoiling = read.csv2("../Data/DF_D1_Linear_Runway_Spoiling.csv")
dualfeeder = read.csv2("../Data/DF_D2_Sucrose_Quinine_Controls.csv")

2 Linear Runway Spoiling

Specify variable class

linear_spoiling$Collection_Date = as.factor(linear_spoiling$Collection_Date) # Data collection date
linear_spoiling$Experimenter = as.factor(linear_spoiling$Experimenter) # Experimenter who collected the data
linear_spoiling$Ant_ID = as.factor(linear_spoiling$Ant_ID) # Ant ID
linear_spoiling$Colony_ID = as.factor(linear_spoiling$Colony_ID) # Which colony did the ant belong to
linear_spoiling$Solution = as.factor(linear_spoiling$Solution) # What solution was the ant given
linear_spoiling$Quinine_Concentration = factor(linear_spoiling$Quinine_Concentration, levels = c("0", "0.31", "0.63", "0.94", "1.25"))  # How much quinine was the ant given (mM)
linear_spoiling$Spoiled_Status = as.factor(linear_spoiling$Spoiled_Status)  # Was the ant spoiled? 0 = No | 1 = Yes
linear_spoiling$Acceptance_First_10_sec = as.factor(linear_spoiling$Acceptance_First_10_sec) # Did the ant touch/drink the solution in the first 10 seconds? 0 = No | 1 = Yes
linear_spoiling$Acceptance_90_sec = as.factor(linear_spoiling$Acceptance_90_sec) # Did the ant have a visibly expanded gaster after 90 seconds? 0 = No | 1 = Yes

Linear Runway Spoiling Data

Biological model

Hide

Initial 10s

Sample size

0 1
1M Sucrose 39 39
1M Sucrose + 0.31mM Quinine 20 40
1M Sucrose + 0.63mM Quinine 29 40
1M Sucrose + 0.94mM Quinine 25 40
1M Sucrose + 1.25mM Quinine 30 40

Define biological model

bio_mod = glmer(Acceptance_First_10_sec ~ Solution * Spoiled_Status + (1 | Ant_ID/Colony_ID) + (1|Experimenter), data = linear_spoiling, family = "binomial")

Model validation

Goodness of fit

R2m: Variation explained by fixed effects (%)

R2c: Variation explained by fixed + random effects (%)

R2m R2c
theoretical 94.36261 94.36261
delta 90.79887 90.79887

Model summary - Fixed effects

Chisq Df Pr(>Chisq)
Solution 55.18474 4 0.0000000
Spoiled_Status 39.31174 1 0.0000000
Solution:Spoiled_Status 1.63065 4 0.8032731

Model summary - Random effects

grp var1 var2 vcov sdcor
Colony_ID:Ant_ID (Intercept) NA 0 0.0001378
Ant_ID (Intercept) NA 0 0.0000705
Experimenter (Intercept) NA 0 0.0000000

Estimated Marginal Means

Solution Spoiled_Status prob SE df asymp.LCL asymp.UCL Prop
1M Sucrose 0 100.0 0.0 Inf 0.0 100.0 10s
1M Sucrose + 0.31mM Quinine 0 100.0 0.0 Inf 0.0 100.0 10s
1M Sucrose + 0.63mM Quinine 0 96.6 3.4 Inf 61.7 99.8 10s
1M Sucrose + 0.94mM Quinine 0 92.0 5.4 Inf 59.2 98.9 10s
1M Sucrose + 1.25mM Quinine 0 90.0 5.5 Inf 62.0 98.0 10s
1M Sucrose 1 87.2 5.4 Inf 63.9 96.3 10s
1M Sucrose + 0.31mM Quinine 1 90.0 4.7 Inf 67.2 97.5 10s
1M Sucrose + 0.63mM Quinine 1 80.0 6.3 Inf 56.9 92.4 10s
1M Sucrose + 0.94mM Quinine 1 37.5 7.7 Inf 19.3 60.0 10s
1M Sucrose + 1.25mM Quinine 1 20.0 6.3 Inf 7.6 43.1 10s

Contrasts

contrast odds.ratio SE df null z.ratio p.value
1M Unspoiled / 1M Spoiled 1.256074e+08 8.442406e+09 Inf 1 0.2774577 1.0000000
0.31mM Q Unspoiled / 0.31mM Q Spoiled 9.489767e+07 1.728302e+10 Inf 1 0.1008568 1.0000000
0.63mM Q Unspoiled / 0.63mM Q Spoiled 6.999998e+00 7.642394e+00 Inf 1 1.7823427 0.3734669
0.94mM Q Unspoiled / 0.94mM Q Spoiled 1.916666e+01 1.546111e+01 Inf 1 3.6609568 0.0012564
1.25mM Q Unspoiled / 1.25mM Q Spoiled 3.600001e+01 2.614798e+01 Inf 1 4.9337159 0.0000040

Initial 90s

Sample size

0 1
1M Sucrose 39 39
1M Sucrose + 0.31mM Quinine 20 40
1M Sucrose + 0.63mM Quinine 29 40
1M Sucrose + 0.94mM Quinine 25 40
1M Sucrose + 1.25mM Quinine 30 40

Define biological model

bio_mod = glmer(Acceptance_90_sec ~ Solution * Spoiled_Status + (1 | Ant_ID/Colony_ID) + (1|Experimenter), data = linear_spoiling, family = "binomial")

Model validation

Goodness of fit

R2m: Variation explained by fixed effects (%)

R2c: Variation explained by fixed + random effects (%)

R2m R2c
theoretical 92.29295 92.29295
delta 0.00000 0.00000

Model summary - Fixed effects

Chisq Df Pr(>Chisq)
Solution 17.0628645 4 0.0018793
Spoiled_Status 6.0149006 1 0.0141856
Solution:Spoiled_Status 0.2924738 4 0.9902948

Model summary - Random effects

grp var1 var2 vcov sdcor
Colony_ID:Ant_ID (Intercept) NA 0 2.57e-05
Ant_ID (Intercept) NA 0 4.24e-05
Experimenter (Intercept) NA 0 0.00e+00

Estimated Marginal Means

Solution Spoiled_Status prob SE df asymp.LCL asymp.UCL Prop
1M Sucrose 0 97.4 2.5 Inf 68.9 99.8 90s
1M Sucrose + 0.31mM Quinine 0 100.0 0.0 Inf 0.0 100.0 90s
1M Sucrose + 0.63mM Quinine 0 96.6 3.4 Inf 61.7 99.8 90s
1M Sucrose + 0.94mM Quinine 0 100.0 0.0 Inf 0.0 100.0 90s
1M Sucrose + 1.25mM Quinine 0 90.0 5.5 Inf 62.0 98.0 90s
1M Sucrose 1 94.9 3.5 Inf 70.7 99.3 90s
1M Sucrose + 0.31mM Quinine 1 92.5 4.2 Inf 69.6 98.5 90s
1M Sucrose + 0.63mM Quinine 1 87.5 5.2 Inf 64.7 96.4 90s
1M Sucrose + 0.94mM Quinine 1 70.0 7.2 Inf 47.0 86.0 90s
1M Sucrose + 1.25mM Quinine 1 67.5 7.4 Inf 44.6 84.3 90s

Contrasts

contrast odds.ratio SE df null z.ratio p.value
1M Unspoiled / 1M Spoiled 2.054054e+00 2.559691e+00 Inf 1 0.5776243 1.0000000
0.31mM Q Unspoiled / 0.31mM Q Spoiled 6.827367e+07 1.526103e+10 Inf 1 0.0807017 1.0000000
0.63mM Q Unspoiled / 0.63mM Q Spoiled 4.000000e+00 4.497527e+00 Inf 1 1.2329391 1.0000000
0.94mM Q Unspoiled / 0.94mM Q Spoiled 3.609000e+08 7.708684e+10 Inf 1 0.0922494 1.0000000
1.25mM Q Unspoiled / 1.25mM Q Spoiled 4.333333e+00 3.015699e+00 Inf 1 2.1070165 0.1755807

Proportion of acceptance at initial 10sec and 90sec

3 Dual-Feeder

Proportion of time spent at initial choice

dualfeeder$time_initial_choice_s = ifelse(dualfeeder$Initial_Decision == "L", dualfeeder$Drinking_Time_Left_s, dualfeeder$Drinking_Time_Right_s)

dualfeeder$prop_time_initial_choice = dualfeeder$time_initial_choice_s / (dualfeeder$Drinking_Time_Left_s + dualfeeder$Drinking_Time_Right_s)

If an ant spent 100% of the time at one feeder it is likely it didn’t perceive both and therefore we cannot be sure the ant made a choice. Therefore, these points are excluded.

dualfeeder$prop_time_initial_choice = ifelse(dualfeeder$prop_time_initial_choice == 1, NA, dualfeeder$prop_time_initial_choice)

Initial choice solution

dualfeeder$solution_initial_choice = ifelse(dualfeeder$Initial_Decision == "L", dualfeeder$Solution_Left, dualfeeder$Solution_Right)
dualfeeder$solution_initial_choice = ifelse((dualfeeder$Solution_Left == "1M Sucrose") & (dualfeeder$Solution_Right == "1M Sucrose"), "1M_L", dualfeeder$solution_initial_choice)
dualfeeder$solution_initial_choice = ifelse((dualfeeder$Solution_Left == "1M Sucrose") & (dualfeeder$Solution_Right == "1M Sucrose") & (dualfeeder$Initial_Decision == "R"), "1M_R", dualfeeder$solution_initial_choice)

Is initial choice random?

Number of times each solution was placed on the left

Var1 Freq
0.5M Sucrose 63
0.75M Sucrose 32
1M Sucrose 443
1M Sucrose+ 0.156mM Quinine 38
1M Sucrose+ 0.313mM Quinine 39
1M Sucrose+ 0.625mM Quinine 38

Number of times each solution was placed on the right

Var1 Freq
0.5M Sucrose 77
0.75M Sucrose 33
1M Sucrose 427
1M Sucrose+ 0.156mM Quinine 39
1M Sucrose+ 0.313mM Quinine 38
1M Sucrose+ 0.625mM Quinine 39

Ants seem to have a side bias towards the right especially in the 0.75M VS 1M and 1M VS Quinine experiments. However, all experiments were balanced regarding how many times each solution was placed on which side of the feeder.

Var1 Freq
L 283
R 370
0.5M_1M 0.75M_1M 1M_1M 1M_Quinine
L 66 21 110 86
R 74 44 107 145
## 
##  Chi-squared test for given probabilities
## 
## data:  table(dualfeeder$Initial_Decision)
## X-squared = 11.591, df = 1, p-value = 0.0006627

Specify variable class

dualfeeder$Collection_Date = as.factor(dualfeeder$Collection_Date) # Data collection date
dualfeeder$Experimenter = as.factor(dualfeeder$Experimenter) # Experimenter who collected the data
dualfeeder$Ant_ID = as.factor(dualfeeder$Ant_ID) # Ant ID
dualfeeder$Colony_ID = as.factor(dualfeeder$Colony_ID) # Which colony did the ant belong to
dualfeeder$Experiment = as.factor(dualfeeder$Experiment) # What experiment is the data referent to
dualfeeder$Set = as.factor(dualfeeder$Set) # Some experiments were conducted in multiple sets
dualfeeder$solution_initial_choice = factor(dualfeeder$solution_initial_choice, levels = c("0.5M Sucrose", "0.75M Sucrose", "1M_L", "1M_R", "1M Sucrose", "1M Sucrose+ 0.156mM Quinine", "1M Sucrose+ 0.313mM Quinine", "1M Sucrose+ 0.625mM Quinine"))  # Which solution was first touched
dualfeeder$prop_time_initial_choice = as.numeric(dualfeeder$prop_time_initial_choice) # Proportion of time spent drinking the first solution touched

Dual Feeder Data

3.1 Quinine Sensitivity

Sample Size

0 0.156 0.313 0.625
0.156 33 29 0 0
0.313 26 0 34 0
0.625 19 0 0 38

Hide

0.156mM of quinine

Biological Model

bio_mod = betareg(prop_time_initial_choice ~ solution_initial_choice, data = subset(quinine, quinine$pair == "0.156"))

Model Summary

lrtest(bio_mod)
## Likelihood ratio test
## 
## Model 1: prop_time_initial_choice ~ solution_initial_choice
## Model 2: prop_time_initial_choice ~ 1
##   #Df LogLik Df  Chisq Pr(>Chisq)
## 1   3 17.330                     
## 2   2 16.884 -1 0.8912     0.3451
summary(bio_mod)
## 
## Call:
## betareg(formula = prop_time_initial_choice ~ solution_initial_choice, 
##     data = subset(quinine, quinine$pair == "0.156"))
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -2.5554 -0.6991  0.0805  0.6587  1.5785 
## 
## Coefficients (mean model with logit link):
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                    0.9689     0.1816   5.334 9.58e-08 ***
## solution_initial_choice0.156  -0.2395     0.2527  -0.948    0.343    
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   3.0704     0.5062   6.065 1.32e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 17.33 on 3 Df
## Pseudo R-squared: 0.01726
## Number of iterations: 15 (BFGS) + 2 (Fisher scoring)
joint_tests(bio_mod)
##  model term              df1 df2 F.ratio Chisq p.value
##  solution_initial_choice   1 Inf   0.895 0.895  0.3440
Anova(bio_mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: prop_time_initial_choice
##                         Df  Chisq Pr(>Chisq)
## solution_initial_choice  1 0.8983     0.3432

Estimated Marginal Means

solution_initial_choice emmean SE df asymp.LCL asymp.UCL
0 0.7248925 0.0362199 Inf 0.6437092 0.8060758
0.156 0.6746629 0.0411192 Inf 0.5824982 0.7668276

Contrasts

contrast estimate SE df z.ratio p.value
solution_initial_choice0 - solution_initial_choice0.156 0.0502296 0.053083 Inf 0.9462464 0.3440229

0.313mM of quinine

Biological Model

bio_mod = betareg(prop_time_initial_choice ~ solution_initial_choice, data = subset(quinine, quinine$pair == "0.313"))

Model Summary

lrtest(bio_mod)
## Likelihood ratio test
## 
## Model 1: prop_time_initial_choice ~ solution_initial_choice
## Model 2: prop_time_initial_choice ~ 1
##   #Df LogLik Df  Chisq Pr(>Chisq)    
## 1   3 29.535                         
## 2   2 22.951 -1 13.167  0.0002849 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bio_mod)
## 
## Call:
## betareg(formula = prop_time_initial_choice ~ solution_initial_choice, 
##     data = subset(quinine, quinine$pair == "0.313"))
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -2.6345 -0.6313  0.1156  0.5185  2.1822 
## 
## Coefficients (mean model with logit link):
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                    1.5899     0.2025   7.850 4.17e-15 ***
## solution_initial_choice0.313  -0.9159     0.2454  -3.732  0.00019 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   4.2975     0.7521   5.714  1.1e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 29.53 on 3 Df
## Pseudo R-squared: 0.2439
## Number of iterations: 13 (BFGS) + 1 (Fisher scoring)
joint_tests(bio_mod)
##  model term              df1 df2 F.ratio  Chisq p.value
##  solution_initial_choice   1 Inf  15.252 15.252  0.0001
Anova(bio_mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: prop_time_initial_choice
##                         Df  Chisq Pr(>Chisq)    
## solution_initial_choice  1 13.925  0.0001903 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Estimated Marginal Means

solution_initial_choice emmean SE df asymp.LCL asymp.UCL
0 0.8306056 0.0284987 Inf 0.7667286 0.8944826
0.313 0.6624081 0.0343740 Inf 0.5853622 0.7394540

Contrasts

contrast estimate SE df z.ratio p.value
solution_initial_choice0 - solution_initial_choice0.313 0.1681974 0.0430687 Inf 3.905325 9.41e-05

0.625mM of quinine

Biological Model

bio_mod = betareg(prop_time_initial_choice ~ solution_initial_choice, data = subset(quinine, quinine$pair == "0.625"))

Model Summary

lrtest(bio_mod)
## Likelihood ratio test
## 
## Model 1: prop_time_initial_choice ~ solution_initial_choice
## Model 2: prop_time_initial_choice ~ 1
##   #Df LogLik Df  Chisq Pr(>Chisq)   
## 1   3 18.376                        
## 2   2 13.071 -1 10.611   0.001124 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bio_mod)
## 
## Call:
## betareg(formula = prop_time_initial_choice ~ solution_initial_choice, 
##     data = subset(quinine, quinine$pair == "0.625"))
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -2.1806 -0.4001  0.1484  0.5056  2.4698 
## 
## Coefficients (mean model with logit link):
##                              Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                    1.4113     0.2622   5.383 7.33e-08 ***
## solution_initial_choice0.625  -1.0034     0.3058  -3.282  0.00103 ** 
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   2.3756     0.4034    5.89 3.87e-09 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 18.38 on 3 Df
## Pseudo R-squared: 0.2216
## Number of iterations: 14 (BFGS) + 1 (Fisher scoring)
joint_tests(bio_mod)
##  model term              df1 df2 F.ratio  Chisq p.value
##  solution_initial_choice   1 Inf  12.789 12.789  0.0003
Anova(bio_mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: prop_time_initial_choice
##                         Df  Chisq Pr(>Chisq)   
## solution_initial_choice  1 10.769   0.001032 **
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Estimated Marginal Means

solution_initial_choice emmean SE df asymp.LCL asymp.UCL
0 0.8039783 0.0413203 Inf 0.7113630 0.8965937
0.625 0.6006017 0.0415239 Inf 0.5075299 0.6936734

Contrasts

contrast estimate SE df z.ratio p.value
solution_initial_choice0 - solution_initial_choice0.625 0.2033767 0.0568701 Inf 3.576163 0.0003487

Graph

3.2 Sucrose Sensitivity

Sample Size

0.5 0.75 1 1_L 1_R
1M VS 0.5M 71 0 69 0 0
1M VS 0.75M 0 28 37 0 0
1M VS 1M 0 0 0 110 107

Hide

0.5M of sucrose

Biological Model

bio_mod = betareg(prop_time_initial_choice ~ solution_initial_choice * Set, data = subset(sucrose, sucrose$pair == "1M VS 0.5M"))

Model Summary

lrtest(bio_mod)
## Likelihood ratio test
## 
## Model 1: prop_time_initial_choice ~ solution_initial_choice * Set
## Model 2: prop_time_initial_choice ~ 1
##   #Df LogLik Df  Chisq Pr(>Chisq)    
## 1   5 70.389                         
## 2   2 53.366 -3 34.047  1.937e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bio_mod)
## 
## Call:
## betareg(formula = prop_time_initial_choice ~ solution_initial_choice * 
##     Set, data = subset(sucrose, sucrose$pair == "1M VS 0.5M"))
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -3.1385 -0.5033  0.1385  0.5866  2.2588 
## 
## Coefficients (mean model with logit link):
##                               Estimate Std. Error z value Pr(>|z|)   
## (Intercept)                     0.5586     0.2012   2.777  0.00549 **
## solution_initial_choice1        0.5250     0.2936   1.788  0.07376 . 
## SetB                            0.1848     0.2575   0.718  0.47294   
## solution_initial_choice1:SetB   0.7477     0.3841   1.947  0.05158 . 
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   3.0702     0.3919   7.835 4.69e-15 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 70.39 on 5 Df
## Pseudo R-squared: 0.3916
## Number of iterations: 19 (BFGS) + 2 (Fisher scoring)
joint_tests(bio_mod)
##  model term                  df1 df2 F.ratio  Chisq p.value
##  solution_initial_choice       1 Inf  18.373 18.373  <.0001
##  Set                           1 Inf   5.794  5.794  0.0161
##  solution_initial_choice:Set   1 Inf   1.625  1.625  0.2023
Anova(bio_mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: prop_time_initial_choice
##                             Df   Chisq Pr(>Chisq)    
## solution_initial_choice      1 24.5018  7.424e-07 ***
## Set                          1  7.3288   0.006786 ** 
## solution_initial_choice:Set  1  3.7892   0.051585 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Estimated Marginal Means

solution_initial_choice Set emmean SE df asymp.LCL asymp.UCL
0.5 A 0.6361318 0.0465645 Inf 0.5198274 0.7524363
1 A 0.7471753 0.0413425 Inf 0.6439138 0.8504368
0.5 B 0.6777413 0.0360806 Inf 0.5876225 0.7678600
1 B 0.8824781 0.0212136 Inf 0.8294929 0.9354634

Contrasts

## NOTE: Results may be misleading due to involvement in interactions
contrast estimate SE df z.ratio p.value
solution_initial_choice0.5 - solution_initial_choice1 -0.1578902 0.0368355 Inf -4.286363 1.82e-05

0.75M of sucrose

Biological Model

bio_mod = betareg(prop_time_initial_choice ~ solution_initial_choice, data = subset(sucrose, sucrose$pair == "1M VS 0.75M"))

Model Summary

lrtest(bio_mod)
## Likelihood ratio test
## 
## Model 1: prop_time_initial_choice ~ solution_initial_choice
## Model 2: prop_time_initial_choice ~ 1
##   #Df LogLik Df  Chisq Pr(>Chisq)    
## 1   3 25.657                         
## 2   2 20.031 -1 11.252  0.0007956 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(bio_mod)
## 
## Call:
## betareg(formula = prop_time_initial_choice ~ solution_initial_choice, 
##     data = subset(sucrose, sucrose$pair == "1M VS 0.75M"))
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -2.3031 -0.5965  0.1168  0.6589  1.4716 
## 
## Coefficients (mean model with logit link):
##                          Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                0.5770     0.2034   2.837  0.00455 ** 
## solution_initial_choice1   1.0396     0.2963   3.509  0.00045 ***
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)   3.2680     0.6489   5.036 4.75e-07 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 25.66 on 3 Df
## Pseudo R-squared: 0.2536
## Number of iterations: 13 (BFGS) + 2 (Fisher scoring)
joint_tests(bio_mod)
##  model term              df1 df2 F.ratio  Chisq p.value
##  solution_initial_choice   1 Inf  12.598 12.598  0.0004
Anova(bio_mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: prop_time_initial_choice
##                         Df  Chisq Pr(>Chisq)    
## solution_initial_choice  1 12.312    0.00045 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Estimated Marginal Means

solution_initial_choice emmean SE df asymp.LCL asymp.UCL
0.75 0.6403743 0.0468367 Inf 0.5353943 0.7453542
1 0.8343259 0.0320770 Inf 0.7624284 0.9062234

Contrasts

contrast estimate SE df z.ratio p.value
solution_initial_choice0.75 - solution_initial_choice1 -0.1939517 0.0546441 Inf -3.549358 0.0003862

1M of sucrose

Biological Model

bio_mod = betareg(prop_time_initial_choice ~ solution_initial_choice * Set, data = subset(sucrose, sucrose$pair == "1M VS 1M"))

Model Summary

lrtest(bio_mod)
## Likelihood ratio test
## 
## Model 1: prop_time_initial_choice ~ solution_initial_choice * Set
## Model 2: prop_time_initial_choice ~ 1
##   #Df LogLik Df  Chisq Pr(>Chisq)
## 1   7 87.894                     
## 2   2 86.712 -5 2.3649     0.7967
summary(bio_mod)
## 
## Call:
## betareg(formula = prop_time_initial_choice ~ solution_initial_choice * 
##     Set, data = subset(sucrose, sucrose$pair == "1M VS 1M"))
## 
## Standardized weighted residuals 2:
##     Min      1Q  Median      3Q     Max 
## -2.8080 -0.5817 -0.0247  0.6047  2.3207 
## 
## Coefficients (mean model with logit link):
##                                 Estimate Std. Error z value Pr(>|z|)    
## (Intercept)                      1.05155    0.17267   6.090 1.13e-09 ***
## solution_initial_choice1_R       0.12469    0.25345   0.492    0.623    
## SetB                             0.30976    0.24121   1.284    0.199    
## SetC                             0.03364    0.23755   0.142    0.887    
## solution_initial_choice1_R:SetB -0.23179    0.34730  -0.667    0.505    
## solution_initial_choice1_R:SetC  0.04557    0.34121   0.134    0.894    
## 
## Phi coefficients (precision model with identity link):
##       Estimate Std. Error z value Pr(>|z|)    
## (phi)    4.649      0.484   9.604   <2e-16 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1 
## 
## Type of estimator: ML (maximum likelihood)
## Log-likelihood: 87.89 on 7 Df
## Pseudo R-squared: 0.01629
## Number of iterations: 16 (BFGS) + 2 (Fisher scoring)
joint_tests(bio_mod)
##  model term                  df1 df2 F.ratio Chisq p.value
##  solution_initial_choice       1 Inf   0.236 0.236  0.6274
##  Set                           2 Inf   0.695 1.390  0.4992
##  solution_initial_choice:Set   2 Inf   0.412 0.824  0.6623
Anova(bio_mod)
## Analysis of Deviance Table (Type II tests)
## 
## Response: prop_time_initial_choice
##                             Df  Chisq Pr(>Chisq)
## solution_initial_choice      1 0.2075     0.6487
## Set                          2 1.3369     0.5125
## solution_initial_choice:Set  2 0.7926     0.6728

Estimated Marginal Means

## NOTE: Results may be misleading due to involvement in interactions
solution_initial_choice emmean SE df asymp.LCL asymp.UCL
1_L 0.7615070 0.0184529 Inf 0.7201465 0.8028674
1_R 0.7735133 0.0181694 Inf 0.7327884 0.8142383

Contrasts

contrast estimate SE df z.ratio p.value
1_L - 1_R -0.0120064 0.0247355 Inf -0.4853912 0.6273989

Graph

4 Session Information

R version 4.2.2 (2022-10-31) Platform: aarch64-apple-darwin20 (64-bit) Running under: macOS Ventura 13.2.1

Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.dylib

locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages: [1] stats graphics grDevices utils datasets methods base

other attached packages: [1] tidyr_1.3.0 stringr_1.5.0 MuMIn_1.47.5 lmtest_0.9-40 zoo_1.8-12
[6] lme4_1.1-33 Matrix_1.5-4.1 ggplot2_3.4.2 emmeans_1.8.6 dplyr_1.1.2
[11] DHARMa_0.4.6 car_3.1-2 carData_3.0-5 betareg_3.1-4 knitr_1.43

loaded via a namespace (and not attached): [1] Rcpp_1.0.10 mvtnorm_1.2-1 lattice_0.21-8 digest_0.6.31
[5] utf8_1.2.3 R6_2.5.1 gap.datasets_0.0.5 stats4_4.2.2
[9] evaluate_0.21 coda_0.19-4 highr_0.10 pillar_1.9.0
[13] rlang_1.1.1 multcomp_1.4-23 rstudioapi_0.14 minqa_1.2.5
[17] nloptr_2.0.3 jquerylib_0.1.4 gap_1.5-1 rmarkdown_2.22
[21] splines_4.2.2 munsell_0.5.0 compiler_4.2.2 xfun_0.39
[25] pkgconfig_2.0.3 htmltools_0.5.5 nnet_7.3-19 tidyselect_1.2.0
[29] tibble_3.2.1 bookdown_0.34 codetools_0.2-19 fansi_1.0.4
[33] withr_2.5.0 MASS_7.3-60 grid_4.2.2 nlme_3.1-162
[37] jsonlite_1.8.5 xtable_1.8-4 gtable_0.3.3 lifecycle_1.0.3
[41] magrittr_2.0.3 scales_1.2.1 rmdformats_1.0.4 stringi_1.7.12
[45] estimability_1.4.1 cli_3.6.1 cachem_1.0.8 flexmix_2.3-19
[49] bslib_0.4.2 generics_0.1.3 vctrs_0.6.2 boot_1.3-28.1
[53] sandwich_3.0-2 Formula_1.2-5 TH.data_1.1-2 tools_4.2.2
[57] glue_1.6.2 purrr_1.0.1 abind_1.4-5 fastmap_1.1.1
[61] survival_3.5-5 yaml_2.3.7 colorspace_2.1-0 sass_0.4.6
[65] modeltools_0.2-23