---
title             : "Supplementary Materials: Effects of human-animal interactions on affect and cognition"
shorttitle        : "Supplementary Materials"

author: 
  - name          : "Elise R. Thayer"
    affiliation   : "1"
    corresponding : no    # Define only one corresponding author
    address       : ""
    email         : "eliserthayer@gmail.com"
  - name          : "Jeffrey R. Stevens"
    affiliation   : "1"
    corresponding : yes    # Define only one corresponding author
    address       : "B83 East Stadium, University of Nebraska-Lincoln, Lincoln, NE 68588"
    email         : "jeffrey.r.stevens@gmail.com"
affiliation:
  - id            : "1"
    institution   : "University of Nebraska-Lincoln"

bibliography      : ["thayer_stevens_2020.bib", "r-references.bib"]
csl               : "thayer_stevens_2020.csl"

figsintext        : yes
figurelist        : no
tablelist         : no
footnotelist      : no
lineno            : no

header-includes: \usepackage[position=top]{subfig}

class             : "doc"
keep_tex          : "TRUE"
output            : papaja::apa6_pdf
---

```{r include = FALSE}
library(papaja)
library(kableExtra)
library(tidyverse)
source("thayer_stevens_2020_rcode.R")
```

\renewcommand{\thetable}{S\arabic{table}}
\setcounter{table}{0}
\renewcommand{\thefigure}{S\arabic{figure}}
\setcounter{figure}{0}

\renewcommand{\arraystretch}{1.35}

# Supplementary Methods

## Deese-Roedinger-McDermott long-term memory

In the presentation phase of the Deese-Roedinger-McDermott long-term memory task, we presented two sets of ten words associated with a not-presented *critical word* (e.g., child). For the recall phase, participants were told that they would view some of the words they were instructed to remember at the beginning of the experiment. They viewed 6 of the 20 previously presented words, the two critical words, and four unrelated words in random order (Table S2) and responded via key press whether they recalled seeing the words previously in the experiment. We calculated $d'$ as $z(P(recall|presented\ word))$ $-$ $z(P(recall|not\ presented\ word))$. A value of 0 indicates that a participant was not able to discriminate between previously presented and not presented words and larger values indicate greater propensities to discriminate between presented and not-presented words  [@Haatveit.etal.2010]. 

## Backwards digit span

Following a practice sequence of numbers, participants responded to a total of 14 unique sequences that increased in span (number of digits), starting with three digits and ending with nine digits. We pseudo-randomly generated each sequence such that no digit was repeated within a given sequence. 

## N-back

Each letter was presented for 0.5 seconds and followed by a 2.5 second inter-stimulus interval (fixation cross). Participants completed a brief practice before viewing a total of 96 letters, of which 16-19 were targets (i.e., matching the stimulus from two trials prior). We calculated $d'$ as $z(P(hit|target))$ $-$ $z(P(hit|not\ target))$ [@Haatveit.etal.2010].

## Cardiovascular activity
Participants wore an Empatica E4 wristband on their left wrist for the duration of the experiment to provide a continuous measure of cardiovascular activity, specifically heart rate variability [@Empatica.2018; @McCarthy.etal.2016]. The E4 wristband uses a photoplethysmogram (PPG) sensor located on the backside of the device face seated atop the wearer's wrist that samples heart beats at 64 Hertz. We do not provide analyses of cardiovascular data because the device did not sample at a sufficient frequency to detect fine changes in heart rate variability [@Shaffer.Ginsberg.2017].  

## HAI condition
The dog used for the HAI condition was a 65-pound, male Catahoula leopard mix that was Canine Good Citizen certified. When not interacting with participants, the dog was housed in JRS's office or adjacent experiment room that were both equipped with a large kennel and access to water. The dog participated in 1-5 sessions spread throughout the day with at least 40 minutes between sessions. 

Participants remained seated for the duration of the interaction. If participants asked questions of or made conversation with the researcher, the researcher briefly informed participants that they would be able to discuss more at the end of the experiment. The dog remained in the experiment room within visual contact after the animal interaction period to rest next to the researcher. 

After the experiment ended, researchers debriefed participants who experienced the HAI condition. The researcher explained that participants were not made aware of the dog in recruitment or consent materials to avoid biasing the sample and the results. Researchers requested that participants not discuss the presence of the dog in the experiment with other individuals to help maintain an unbiased sample. Then, researchers invited participants to ask any questions about the nature of the study. 

## Analysis

We used `r cite_r("r-references.bib", pkgs = c("BayesFactor", "ggbeeswarm", "ggcorrplot", "here", "Hmisc", "lsmeans", "papaja", "patchwork", "psych", "rcompanion", "tidyverse"), withhold = FALSE)` for all our analyses. We prepared the manuscript using *rmarkdown*  [Version `r packageVersion("rmarkdown")`; @R-rmarkdown].

To assess potential condition differences pre-condition, we conducted independent samples t-tests or Wilcoxon rank sum tests in the case of test violations. For condition effects, we used analysis of covariance to examine the effects of condition on post-scores controlling for pre-scores. We report predicted marginal means and 95% confidence intervals and calculated effect sizes with generalized eta squared (${\eta}^2_G$).  We used both visual and test-based methods to check analysis of covariance test assumptions: linearity between covariate and outcome variable, homogeneity of regression slopes, normally distributed residuals on outcome variable, and homogeneity of variance [@Johnson.2016]. Since we recorded responses only at post-condition for the long-term memory task, we compared between-groups differences with a Wilcoxon rank sum test, as it violated assumptions of an independent samples t-test.  For these, we calculated effect sizes with $r$, the z-score of the test statistic divided by the total number of observations. 

In Experiment 1, the analyses of covariance for negative affect and Necker cube significantly violated model assumptions, so we log-transformed negative affect pre- and post-scores and removed outliers (standard deviation $\times$ 3; 2 observations) from Necker post-scores to conform to model assumptions. We excluded one observation from DRM (participant expressed comprehension issues after task), three from Necker cube (participants expressed comprehension issues after task), and three from digit span (participants did not request response sheet) when running respective analyses, inserting missing data for these subjects.  Similarly, in Experiment 2, we log-transformed negative affect pre- and post-scores and removed a single outlier (standard deviation $\times$ 3) to conform to analysis of covariance model assumptions. We excluded one observation from DRM (participant expressed comprehension issues after task), three from Necker cube (participants expressed comprehension issues after task), six from digit span (participants did not request response sheet or did not complete more than half of task), and three from n-back (two participants did not record any responses and one participant expressed comprehension issues after task).

We supplemented the frequentist analyses with Bayes factors and drew inferences based on Bayes factors, that is, the strength of evidence for the alternative over the null hypothesis. For example, $BF$ = 15 suggests that there is 15 times more evidence for the alternative than the null hypothesis. Bayes factors between 3-10 provide moderate evidence for the alternative hypothesis, those between 10-30 provide strong evidence, those between 30-100 provide very strong evidence, and those above 100 provide extreme evidence; reciprocal values (1/3, 1/10, 1/30, 1/100) provide comparable evidence for the null hypothesis [@Wagenmakers.etal.2018]. We used the *BayesFactor* package to calculate most Bayes factors, except for the Wilcoxon rank sum tests which we calculated from code provided by @vanDoorn.etal.2020.


\clearpage


<!--(Table S1)-->
```{r dems, results = 'asis', echo = F}
knitr::kable(descriptives, col.names = c("Measure", "$N$ (\\%)", "$N$ (\\%)"), booktabs = TRUE, caption = "Demographics", escape = FALSE) %>%
  kable_styling(position = "center")  %>% 
  kable_styling(font_size = 9) %>% 
  add_header_above(c("", "Experiment 1" = 1, "Experiment 2" = 1)) %>% 
  pack_rows("Gender", 1, 3) %>%
  pack_rows("Ethnicity", 4, 9) %>% 
  pack_rows("Family Income", 10, 15)
```

<!--(Table S2)-->
```{r}
presentation_words <- c("kid", "adult", "adolescent", "toy", "parent", "baby", "dependent", "immature", "brat", "juvenile", "beaker", "element", "lab", "physics", "formula", "molecule", "flask", "test tube", "scientist", "electron")
recall_words <- c("kid*", "toy*", "immature*", "beaker*", "physics*", "test tube*", "child", "chemistry", "blouse", "table", "victory", "cardboard", "", "", "", "", "", "", "", "")
drm_df <- tibble(`Presentation words` = presentation_words, `Recall words` = recall_words)
knitr::kable(drm_df, caption = "Words used in Deese-Roedinger-McDermott long-term memory test.", booktabs = TRUE) %>% 
  kable_styling() %>%
  add_footnote("Denotes recall words that were present in presentation phase.", notation="symbol")
```

\clearpage


<!--(Figure S1)-->
(ref:tasks-fig-cap) Cognitive tasks: (a) Necker Cube Pattern Control Test, (b) backwards digit span test, and (c) n-back task.

```{r tasks-fig, fig.cap = "(ref:tasks-fig-cap)", out.width = "45%", fig.show = "hold", fig.subcap = c("", "", ""), fig.sep = c("\\hspace{5mm}", "\\newline")}
knitr::include_graphics(path = c("figures/illustration_necker_cube.png", "figures/illustration_backwards_digit_span.png", "figures/illustration_n-back.png"))
```


<!--(Figure S2)-->
(ref:affect1-cap) Post-condition predicted affect scores (controlling for pre-condition scores) for control and HAI (human-animal interaction) groups in Experiment 1. Scores show (a) positive PANAS ratings and (b) negative PANAS ratings. Negative affect scores are log-transformed. Open triangles represent individual control participant scores, open circles represent individual HAI participant scores, filled triangles and circles represent condition group means, error bars represent 95% confidence intervals.

```{r affect1, fig.cap = "(ref:affect1-cap)", out.width = "100%"}
knitr::include_graphics(path = "figures/affect_1.png")
```

<!--(Figure S3)-->
(ref:cognitive1-cap) Post-condition predicted cognitive scores (controlling for pre-condition scores) for HAI (human-animal interaction) and control groups in Experiment 1. Scores show (a) the difference in number of attentional shifts between the two Necker cube trials, (b) the index for the backwards digit span task, and (c) $d'$ for the n-back task. Open triangles represent individual control participant scores, open circles represent individual HAI participant scores, filled triangles and circles represent condition group means, error bars represent 95% confidence intervals.

```{r cognitive1, fig.cap = "(ref:cognitive1-cap)", out.width = "100%"}
knitr::include_graphics(path = "figures/cognitive_1.png")
```

<!--(Figure S4)-->
(ref:hai-corr-plots-cap) Animal experience correlation matrices for Experiments 1 (a) and 2 (b). Values in cells are correlation coefficients for correlations with p < 0.05. 

```{r hai-corr-plots, echo = F, out.width = "80%", fig.sep = "\\newline",  fig.subcap = c("Experiment 1", "Experiment 2"), fig.cap = "(ref:hai-corr-plots-cap)", fig.show = 'hold', fig.align = 'center', warning=FALSE,  message = FALSE}
knitr::include_graphics(path = "figures/correlation_plots.png")
```

<!--(Figure S5)-->
(ref:affect2-cap) Post-condition predicted affect scores (controlling for pre-condition scores) for control and HAI (human-animal interaction) groups in Experiment 2. Scores show (a) positive PANAS ratings, (b) negative PANAS ratings, (c) anxiety ratings, and (d) stress ratings. Negative affect scores are log-transformed. Open triangles represent individual control participant scores, open circles represent individual HAI participant scores, filled triangles and circles represent condition group means, error bars represent 95% confidence intervals.

```{r affect2, fig.cap = "(ref:affect2-cap)", out.width = "100%"}
knitr::include_graphics(path = "figures/affect_2.png")
```

<!--(Figure S6)-->
(ref:cognitive2-cap) Post-condition predicted cognitive scores (controlling for pre-condition scores) for HAI (human-animal interaction) and control groups in Experiment 2. Scores show (a) the difference in number of attentional shifts between the two Necker cube trials, (b) the index for the backwards digit span task, and (c) $d'$ for the n-back task. Open triangles represent individual control participant scores, open circles represent individual HAI participant scores, filled triangles and circles represent condition group means, error bars represent 95% confidence intervals.

```{r cognitive2, fig.cap = "(ref:cognitive2-cap)", out.width = "100%"}
knitr::include_graphics(path = "figures/cognitive_2.png")
```

\clearpage

# References

