Performing an ANOVA comparing the PSEs of all the subjects in different conditions
library("rstatix")
## Warning: replacing previous import 'vctrs::data_frame' by 'tibble::data_frame'
## when loading 'dplyr'
##
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
##
## filter
library("readxl")
Parametric_curve_results <- read_excel("~/Desktop/Parametric_curve_results.xlsx")
library(afex)
## Loading required package: lme4
## Loading required package: Matrix
## Registered S3 methods overwritten by 'lme4':
## method from
## cooks.distance.influence.merMod car
## influence.merMod car
## dfbeta.influence.merMod car
## dfbetas.influence.merMod car
## ************
## Welcome to afex. For support visit: http://afex.singmann.science/
## - Functions for ANOVAs: aov_car(), aov_ez(), and aov_4()
## - Methods for calculating p-values with mixed(): 'S', 'KR', 'LRT', and 'PB'
## - 'afex_aov' and 'mixed' objects can be passed to emmeans() for follow-up tests
## - Get and set global package options with: afex_options()
## - Set sum-to-zero contrasts globally: set_sum_contrasts()
## - For example analyses see: browseVignettes("afex")
## ************
##
## Attaching package: 'afex'
## The following object is masked from 'package:lme4':
##
## lmer
aov_model <- aov_ez(data = Parametric_curve_results, dv = "result", within = c("inducer"), id = "dog")
aov_model
## Anova Table (Type 3 tests)
##
## Response: result
## Effect df MSE F ges p.value
## 1 inducer 1.88, 13.16 0.49 44.14 *** .761 <.001
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
Calculating the Fisher’s z as a measure of the effect size
F_statistic <- 44.14
DF1 <- 2
DF2 <- 14
eta_squared <- F_statistic / (F_statistic + DF2)
fisher_z <- 0.5 * log((1 + eta_squared) / (1 - eta_squared))
print(fisher_z)
## [1] 0.9943284
Running the pairwise comparisons
library(rstatix)
library("readxl")
Parametric_curve_results <- read_excel("~/Desktop/Parametric_curve_results.xlsx")
pairwise_t_test(result~inducer,paired=TRUE, p.adjust.method = "none", data = Parametric_curve_results )
## # A tibble: 3 x 10
## .y. group1 group2 n1 n2 statistic df p p.adj p.adj.signif
## * <chr> <chr> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <chr>
## 1 result ind16 ind4 8 8 9.05 7 4.11e-5 4.11e-5 ****
## 2 result ind16 no 8 8 6.34 7 3.90e-4 3.90e-4 ***
## 3 result ind4 no 8 8 -3.54 7 1.00e-2 1.00e-2 **
Running a binomial logistic regression model assessing the effect of discrimination ratio, condition, and attention towards the inducer on dogs’ choices in the test presentations, where discriminations of either 4 vs 8 or 6 vs 8 were presented
library("readxl")
Data1 <- read_excel(("~/Desktop/Data1.xlsx"),
col_types = c("text", "text", "text",
"text", "numeric", "numeric", "text"))
library(lme4)
mod1 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Discrimination_ratio + condition
+ Attention_towards_the_inducer
+ condition * Attention_towards_the_inducer
+ condition * Discrimination_ratio,
family = binomial(logit),
data = Data1)
## boundary (singular) fit: see ?isSingular
summary(mod1)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula:
## Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Discrimination_ratio +
## condition + Attention_towards_the_inducer + condition * Attention_towards_the_inducer +
## condition * Discrimination_ratio
## Data: Data1
##
## AIC BIC logLik deviance df.resid
## 419.3 456.9 -200.7 401.3 470
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -7.1727 0.1433 0.3085 0.4921 0.9090
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 7.175e-02 0.267854
## Trial_nr (Intercept) 2.601e-09 0.000051
## Dog (Intercept) 6.687e-02 0.258584
## Number of obs: 479, groups: Session_nr, 25; Trial_nr, 11; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.6402 0.6908 2.374
## Discrimination_ratio6 -1.3669 0.5511 -2.480
## conditionsmaller -0.2862 0.7836 -0.365
## Attention_towards_the_inducer 2.4142 0.8943 2.700
## conditionsmaller:Attention_towards_the_inducer -2.2144 1.0222 -2.166
## Discrimination_ratio6:conditionsmaller 0.3439 0.6293 0.547
## Pr(>|z|)
## (Intercept) 0.01759 *
## Discrimination_ratio6 0.01312 *
## conditionsmaller 0.71493
## Attention_towards_the_inducer 0.00694 **
## conditionsmaller:Attention_towards_the_inducer 0.03029 *
## Discrimination_ratio6:conditionsmaller 0.58469
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Dscr_6 cndtns Att___ c:A___
## Dscrmntn_r6 -0.437
## condtnsmllr -0.854 0.385
## Attntn_tw__ -0.721 -0.170 0.638
## cndtns:A___ 0.627 0.149 -0.750 -0.870
## Dscrmntn_6: 0.381 -0.876 -0.445 0.144 -0.134
## convergence code: 0
## boundary (singular) fit: see ?isSingular
library(car)
## Loading required package: carData
Anova(mod1, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 5.6368 1 0.017588 *
## Discrimination_ratio 6.1526 1 0.013122 *
## condition 0.1334 1 0.714932
## Attention_towards_the_inducer 7.2875 1 0.006944 **
## condition:Attention_towards_the_inducer 4.6928 1 0.030289 *
## Discrimination_ratio:condition 0.2987 1 0.584686
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Removing the interactions that does not result significant
library(lme4)
mod1 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Discrimination_ratio + condition
+ Attention_towards_the_inducer
+ condition * Attention_towards_the_inducer,
family = binomial(logit),
data = Data1)
## boundary (singular) fit: see ?isSingular
summary(mod1)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula:
## Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Discrimination_ratio +
## condition + Attention_towards_the_inducer + condition * Attention_towards_the_inducer
## Data: Data1
##
## AIC BIC logLik deviance df.resid
## 417.6 451.0 -200.8 401.6 471
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -6.4470 0.1587 0.3055 0.4784 0.9296
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 7.730e-02 2.780e-01
## Trial_nr (Intercept) 6.313e-10 2.513e-05
## Dog (Intercept) 6.886e-02 2.624e-01
## Number of obs: 479, groups: Session_nr, 25; Trial_nr, 11; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.5030 0.6296 2.387
## Discrimination_ratio6 -1.1068 0.2648 -4.180
## conditionsmaller -0.0993 0.6959 -0.143
## Attention_towards_the_inducer 2.3465 0.8750 2.682
## conditionsmaller:Attention_towards_the_inducer -2.1421 1.0054 -2.131
## Pr(>|z|)
## (Intercept) 0.01699 *
## Discrimination_ratio6 2.91e-05 ***
## conditionsmaller 0.88652
## Attention_towards_the_inducer 0.00733 **
## conditionsmaller:Attention_towards_the_inducer 0.03312 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Dscr_6 cndtns Att___
## Dscrmntn_r6 -0.220
## condtnsmllr -0.821 -0.027
## Attntn_tw__ -0.849 -0.090 0.789
## cndtns:A___ 0.738 0.065 -0.912 -0.864
## convergence code: 0
## boundary (singular) fit: see ?isSingular
library(car)
Anova(mod1, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 5.6977 1 0.016987 *
## Discrimination_ratio 17.4761 1 2.909e-05 ***
## condition 0.0204 1 0.886524
## Attention_towards_the_inducer 7.1914 1 0.007325 **
## condition:Attention_towards_the_inducer 4.5397 1 0.033117 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Running a binomial logistic regression model assessing the effect of discrimination ratio, condition, and attention towards the inducer on dogs’ choices in the test presentations, where where both stimuli contained eight food pieces
library("readxl")
Data2 <- read_excel("~/Desktop/Data2.xlsx",
col_types = c("text", "text", "text",
"text", "numeric", "numeric"))
library(lme4)
mod2 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Condition
+ Attention_towards_the_inducer
+ Condition * Attention_towards_the_inducer,
family = binomial(logit),
data = Data2)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge with max|grad| = 0.0036395 (tol = 0.002, component 1)
summary(mod2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Condition +
## Attention_towards_the_inducer + Condition * Attention_towards_the_inducer
## Data: Data2
##
## AIC BIC logLik deviance df.resid
## 310.8 335.3 -148.4 296.8 239
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.9527 -1.0460 0.5338 0.6698 1.0997
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 2.691e-07 0.0005188
## Trial_nr (Intercept) 7.600e-02 0.2756768
## Dog (Intercept) 2.936e-07 0.0005418
## Number of obs: 246, groups: Session_nr, 25; Trial_nr, 9; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.3245 0.7344 1.803
## Conditionsmaller -0.3757 0.8702 -0.432
## Attention_towards_the_inducer -0.1292 0.9125 -0.142
## Conditionsmaller:Attention_towards_the_inducer -0.8094 1.1368 -0.712
## Pr(>|z|)
## (Intercept) 0.0713 .
## Conditionsmaller 0.6660
## Attention_towards_the_inducer 0.8874
## Conditionsmaller:Attention_towards_the_inducer 0.4764
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtns Att___
## Condtnsmllr -0.831
## Attntn_tw__ -0.943 0.795
## Cndtns:A___ 0.756 -0.934 -0.803
## convergence code: 0
## Model failed to converge with max|grad| = 0.0036395 (tol = 0.002, component 1)
library(car)
Anova(mod2, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 3.2526 1 0.07131 .
## Condition 0.1863 1 0.66599
## Attention_towards_the_inducer 0.0200 1 0.88745
## Condition:Attention_towards_the_inducer 0.5070 1 0.47644
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Removing the interaction that does not result significant
library(lme4)
mod2 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Condition
+ Attention_towards_the_inducer,
family = binomial(logit),
data = Data2)
## boundary (singular) fit: see ?isSingular
summary(mod2)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula: Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Condition +
## Attention_towards_the_inducer
## Data: Data2
##
## AIC BIC logLik deviance df.resid
## 309.3 330.3 -148.6 297.3 240
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.2737 -1.0722 0.5461 0.6948 1.0441
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 5.546e-08 0.0002355
## Trial_nr (Intercept) 7.408e-02 0.2721781
## Dog (Intercept) 1.144e-10 0.0000107
## Number of obs: 246, groups: Session_nr, 25; Trial_nr, 9; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 1.7319 0.4905 3.531 0.000414 ***
## Conditionsmaller -0.9596 0.3135 -3.061 0.002204 **
## Attention_towards_the_inducer -0.6604 0.5480 -1.205 0.228147
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Cndtns
## Condtnsmllr -0.556
## Attntn_tw__ -0.867 0.248
## convergence code: 0
## boundary (singular) fit: see ?isSingular
library(car)
Anova(mod2, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 12.4661 1 0.0004144 ***
## Condition 9.3714 1 0.0022040 **
## Attention_towards_the_inducer 1.4524 1 0.2281470
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Running a binomial logistic regression model assessing the effect of discrimination ratio, condition, and attention towards the inducer on dogs’ choices in the test presentations, where discriminations of either 8 vs 11 or 8 vs 16 were presented
library("readxl")
Data3 <- read_excel(("~/Desktop/Data3.xlsx"),
col_types = c("text", "text", "text",
"text", "text", "numeric", "numeric"))
library(lme4)
mod3 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Discrimination_ratio + Condition
+ Attention_towards_the_inducer
+ Condition * Attention_towards_the_inducer
+ Condition * Discrimination_ratio,
family = binomial(logit),
data = Data3)
summary(mod3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula:
## Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Discrimination_ratio +
## Condition + Attention_towards_the_inducer + Condition * Attention_towards_the_inducer +
## Condition * Discrimination_ratio
## Data: Data3
##
## AIC BIC logLik deviance df.resid
## 351.4 389.0 -166.7 333.4 471
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -9.1827 0.0727 0.2640 0.3846 1.3047
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 0.1772 0.4210
## Trial_nr (Intercept) 0.2318 0.4814
## Dog (Intercept) 0.2286 0.4782
## Number of obs: 480, groups: Session_nr, 25; Trial_nr, 13; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.4052 0.6660 2.110
## Discrimination_ratio16 1.9532 0.4066 4.804
## Conditionsmaller 0.2654 0.9102 0.292
## Attention_towards_the_inducer -1.0879 0.7558 -1.439
## Conditionsmaller:Attention_towards_the_inducer 1.5611 1.2220 1.277
## Discrimination_ratio16:Conditionsmaller 1.2927 1.1094 1.165
## Pr(>|z|)
## (Intercept) 0.0349 *
## Discrimination_ratio16 1.55e-06 ***
## Conditionsmaller 0.7706
## Attention_towards_the_inducer 0.1500
## Conditionsmaller:Attention_towards_the_inducer 0.2014
## Discrimination_ratio16:Conditionsmaller 0.2439
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Dsc_16 Cndtns Att___ C:A___
## Dscrmntn_16 -0.046
## Condtnsmllr -0.633 0.029
## Attntn_tw__ -0.864 -0.148 0.620
## Cndtns:A___ 0.528 0.101 -0.903 -0.600
## Dscrmn_16:C 0.037 -0.331 -0.124 0.042 -0.015
library(car)
Anova(mod3, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 4.4511 1 0.03488 *
## Discrimination_ratio 23.0804 1 1.554e-06 ***
## Condition 0.0850 1 0.77061
## Attention_towards_the_inducer 2.0717 1 0.15005
## Condition:Attention_towards_the_inducer 1.6319 1 0.20144
## Discrimination_ratio:Condition 1.3577 1 0.24394
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Removing the interactions that do not result significant
library(lme4)
mod3 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Discrimination_ratio + Condition
+ Attention_towards_the_inducer
+ Condition * Attention_towards_the_inducer,
family = binomial(logit),
data = Data3)
summary(mod3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula:
## Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Discrimination_ratio +
## Condition + Attention_towards_the_inducer + Condition * Attention_towards_the_inducer
## Data: Data3
##
## AIC BIC logLik deviance df.resid
## 351.0 384.4 -167.5 335.0 472
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -5.8842 0.1138 0.2483 0.3605 1.3499
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 0.1907 0.4366
## Trial_nr (Intercept) 0.2083 0.4564
## Dog (Intercept) 0.2346 0.4844
## Number of obs: 480, groups: Session_nr, 25; Trial_nr, 13; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value
## (Intercept) 1.3724 0.6743 2.035
## Discrimination_ratio16 2.1841 0.3787 5.767
## Conditionsmaller 0.4435 0.9015 0.492
## Attention_towards_the_inducer -1.1430 0.7689 -1.487
## Conditionsmaller:Attention_towards_the_inducer 1.6023 1.2221 1.311
## Pr(>|z|)
## (Intercept) 0.0418 *
## Discrimination_ratio16 8.08e-09 ***
## Conditionsmaller 0.6227
## Attention_towards_the_inducer 0.1371
## Conditionsmaller:Attention_towards_the_inducer 0.1898
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Dsc_16 Cndtns Att___
## Dscrmntn_16 -0.011
## Condtnsmllr -0.640 -0.059
## Attntn_tw__ -0.874 -0.138 0.647
## Cndtns:A___ 0.541 0.100 -0.915 -0.611
library(car)
Anova(mod3, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 4.1424 1 0.04182 *
## Discrimination_ratio 33.2549 1 8.083e-09 ***
## Condition 0.2421 1 0.62271
## Attention_towards_the_inducer 2.2099 1 0.13713
## Condition:Attention_towards_the_inducer 1.7191 1 0.18981
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
mod3 <- glmer(formula = Choice ~ (1|`Dog`) + (1|`Session_nr`) + (1|`Trial_nr`)
+ Discrimination_ratio + Condition
+ Attention_towards_the_inducer,
family = binomial(logit),
data = Data3)
summary(mod3)
## Generalized linear mixed model fit by maximum likelihood (Laplace
## Approximation) [glmerMod]
## Family: binomial ( logit )
## Formula:
## Choice ~ (1 | Dog) + (1 | Session_nr) + (1 | Trial_nr) + Discrimination_ratio +
## Condition + Attention_towards_the_inducer
## Data: Data3
##
## AIC BIC logLik deviance df.resid
## 350.8 380.0 -168.4 336.8 473
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -4.9481 0.1208 0.2518 0.3577 1.2306
##
## Random effects:
## Groups Name Variance Std.Dev.
## Session_nr (Intercept) 0.1815 0.4260
## Trial_nr (Intercept) 0.1779 0.4218
## Dog (Intercept) 0.2585 0.5084
## Number of obs: 480, groups: Session_nr, 25; Trial_nr, 13; Dog, 8
##
## Fixed effects:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) 0.9145 0.5591 1.636 0.102
## Discrimination_ratio16 2.1474 0.3722 5.769 7.98e-09 ***
## Conditionsmaller 1.5468 0.3505 4.414 1.02e-05 ***
## Attention_towards_the_inducer -0.5501 0.6052 -0.909 0.363
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) Dsc_16 Cndtns
## Dscrmntn_16 -0.074
## Condtnsmllr -0.358 0.090
## Attntn_tw__ -0.813 -0.102 0.190
Anova(mod3, type=3)
## Analysis of Deviance Table (Type III Wald chisquare tests)
##
## Response: Choice
## Chisq Df Pr(>Chisq)
## (Intercept) 2.6756 1 0.1019
## Discrimination_ratio 33.2793 1 7.983e-09 ***
## Condition 19.4810 1 1.016e-05 ***
## Attention_towards_the_inducer 0.8264 1 0.3633
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1