## R-Script of manuscript titled "Does novelty influence foraging decision of a scavenger?" by Bhattacharjee et al. 2023 # set directory setwd() # Packages required library(lme4) library(lmerTest) library(performance) library(DHARMa) library(lmtest) ## See Raw data_Bhattacharjee et al. 2023 to extract the data for analyses. #----------------------------------------------------------------------------------------------------------------------- ### Object Choice #----------------------------------------------------------------------------------------------------------------------- ## GB-BP Condition # Binomial test to check object choice (Including both age classes) # 41 dogs chose GB out of 63. binom.test(41, 63) # GLM to check influence of age class (and sex) on object choice gbbpinspect <- read.csv("gbbpinspect.csv") lrfit01 <- glm(inspect ~ age + sex, data = gbbpinspect, family = binomial(link = "logit")) summary(lrfit01) # Model diagnostics DHARMa::testResiduals(lrfit01) #----------------------------------------------------------------------------------------------------------------------- ## GB-TP Condition # Binomial test to check object choice (Including both age classes) # 45 dogs chose GB out of 60. binom.test(42, 60) # GLM to check influence of age class (and sex) on object choice gbtpinspect <- read.csv("gbtpinspect.csv") lrfit02 <- glm(inspect ~ age + sex, data = gbtpinspect, family = binomial(link = "logit")) summary(lrfit02) # Model diagnostics DHARMa::testResiduals(lrfit02) #----------------------------------------------------------------------------------------------------------------------- ## BP-TP Condition # Binomial test to check object choice (Including both age classes) # 34 dogs chose BP out of 59. binom.test(34, 59) # GLM to check influence of age class (and sex) on object choice bptpinspect <- read.csv("bptpinspect.csv") lrfit03 <- glm(inspect ~ age + sex, data = bptpinspect, family = binomial(link = "logit")) summary(lrfit03) # Model diagnostics DHARMa::testResiduals(lrfit03) #----------------------------------------------------------------------------------------------------------------------- ## GB-GBB Condition # Binomial test to check object choice (Including both age classes) # 43 dogs chose GB out of 79. binom.test(43, 79) # GLM to check influence of age class (and sex) on object choice gbgbbinspect <- read.csv("gbgbbinspect.csv") lrfit04 <- glm(inspect ~ age + sex, data = gbgbbinspect, family = binomial(link = "logit")) summary(lrfit04) # Model diagnostics DHARMa::testResiduals(lrfit04) #----------------------------------------------------------------------------------------------------------------------- ### Latency #----------------------------------------------------------------------------------------------------------------------- ## GB-BP Condition # LM to check influence of age class (and sex) on latency of object choice gbbplat <- read.csv("gbbplat.csv") #Log-transform of response variable gbbplat$latency <- log10(gbbplat$latency) #Linear model (LM) analysis lrfit05 <- lm(latency ~ age + sex + object, data = gbbplat) summary(lrfit05) # Model diagnostics DHARMa::testResiduals(lrfit05) #----------------------------------------------------------------------------------------------------------------------- ## GB-TP Condition # LM to check influence of age class (and sex) on latency of object choice gbtplat <- read.csv("gbtplat.csv") #Log-transform of response variable gbtplat$latency <- log10(gbtplat$latency) #Linear model (LM) analysis lrfit06 <- lm(latency ~ age + sex + object, data = gbtplat) summary(lrfit06) # Model diagnostics DHARMa::testResiduals(lrfit06) #----------------------------------------------------------------------------------------------------------------------- ## BP-TP Condition # LM to check influence of age class (and sex) on latency of object choice bptplat <- read.csv("bptplat.csv") #Log-transform of response variable bptplat$latency <- log10(bptplat$latency) #Linear model (LM) analysis lrfit07 <- lm(latency ~ age + sex + object, data = bptplat) summary(lrfit07) # Model diagnostics DHARMa::testResiduals(lrfit07) #----------------------------------------------------------------------------------------------------------------------- ## GB-GBB Condition # LM to check influence of age class (and sex) on latency of object choice gbgbblat <- read.csv("gbgbblat.csv") #Log-transform of response variable gbgbblat$latency <- log10(gbgbblat$latency) #Linear model (LM) analysis lrfit08 <- lm(latency ~ age + sex + object, data = gbgbblat) summary(lrfit08) # Model diagnostics DHARMa::testResiduals(lrfit08) # Residual deviation detected. Model Without log-transformation used. gbgbblat <- read.csv("gbgbblat.csv") lrfit09 <- lm(latency ~ age + sex + object, data = gbgbblat) summary(lrfit09) # Model diagnostics DHARMa::testResiduals(lrfit09) #-----------------------------------------------------------------------------------------------------------------------