Retrieval

This rate is how many trees they had to look at to get each successive fruit.

e2 Retrieval: Prepare the data

Read the data in and pre-process it.

Show the code
e2 <- readRDS("002-00-e2-data.RDS")

# remove things from the raw data to make it 
# suitable for this particular analysis

# remove samples that did not look at a tree
e2 <- e2 %>% filter(fl>0)

# remove the second (and any subsequent) *consecutive* duplicates
e2 <- e2 %>% 
  group_by(pp, rr, tb) %>% 
  filter(is.na(tl != lag(tl)) | tl != lag(tl)) %>% 
  ungroup()

# remove trials where they failed to get 14 fruit
e2 <- e2 %>%
  group_by(pp, rr, tb) %>%
  mutate(max_fr = max(fr)) %>%
  ungroup() %>%
  filter(max_fr==14) %>% 
  select(-c(ex, max_fr, st, xx, yy, ln)) 

# how many trees to get each fruit?
# this is neat and it needs to be done after 
# reducing the data to row-per-valid-tree-visit
e2$ntrees_to_get_a_fruit = NA
j = 0
for (k in seq_along(e2$ix)) {
 j = j + 1
 if (e2[k, 'fl']==2) {
   e2[k, 'ntrees_to_get_a_fruit'] = j
   j = 0
 }
}

# remove any remaining NAs
e2 <- e2 %>% filter(!is.na(ntrees_to_get_a_fruit))

# average over trials (and ignore stage) to yield 
# participant means suitable for ggplot and ANOVA
rtv = e2 %>% 
  select(ff, pp, rr, tb, fr, ntrees_to_get_a_fruit) %>% 
  group_by(ff, pp, rr, fr) %>% 
  summarise(mu=mean(ntrees_to_get_a_fruit)) %>% 
  ungroup() %>% 
  mutate(ff= as_factor(ff), pp=as_factor(pp), rr=as_factor(rr), fr=as_factor(fr))

saveRDS(rtv, "e2_retrieval_plot_data.rds")

e2 Retrieval: ANOVA

Run the ANOVA

Show the code
options(contrasts=c("contr.sum","contr.poly"))
e2_retrievalrate_ANOVA <- 
  ezANOVA(data=rtv,
          dv=mu,
          wid=pp,
          within=c(rr, fr),
          between=ff,
          type=3, 
          return_aov = TRUE)
Warning: Data is unbalanced (unequal N per group). Make sure you specified a
well-considered value for the type argument to ezANOVA().
Show the code
if("Sphericity Corrections" %in% names(e2_retrievalrate_ANOVA)){
  corr=aovSphericityAdjustment(e2_retrievalrate_ANOVA)$ANOVA %>% tibble()
} else {
  corr=e2_retrievalrate_ANOVA$ANOVA %>% tibble()  
  }

Table the ANOVA taking into account sphericity violations.

Show the code
prettify_sphericity_3_way(
  aovSphericityAdjustment(e2_retrievalrate_ANOVA), 
  "e2 Retrieval ANOVA") 
e2 Retrieval ANOVA
Effect DFn DFd F p sig
ff 1 40 0.36 0.554
rr 1 40 71.71 0.000 ***
fr 5.3 211.7 17.22 0.000 ***
ff:rr 1 40 2.97 0.093
ff:fr 5.3 211.7 2.89 0.013 *
rr:fr 6.1 244.2 32.17 0.000 ***
ff:rr:fr 6.1 244.2 0.85 0.536

Report the ANOVA

The effect of fading was F(1, 40) = 0.36, p=0.554.

The effect of resources was F(1, 40) = 71.71, p<.001.

The effect of fruit was F(5.3, 211.7) = 17.22, p<.001.

The fruit x resources interaction was F(6.1, 244.2) = 32.17, p<.001.

The fruit x fading interaction was F(5.3, 211.7) = 2.89, p<.05.

The fruit x fading interaction was F(5.3, 211.7) = 2.89, p<.05.

e2 Retrieval: Plot

Ten points along the x axis, each participant contributes one point per cell, facet on fading

Show the code
ggplot(
  data=rtv, 
  aes(x=fr, y=mu, group=rr, fill=rr, shape=rr)
) +
  facet_wrap(~ff, nrow=2)+
  labs(title="(c): Retrieval rate", subtitle="People benefit from being in a patch once they realise they are in one")+
  ylab("Number\nof\ntrees\nvisited\nto get\neach fruit")+
  xlab("Number of fruit collected so far during trial")+
  my_fgms_theme+
  geom_hline(yintercept=2, lty=3,col="grey")+
  scale_fill_manual(name="Resources", values=c("white", "black")) +
  scale_shape_manual(name="Resources", values=c(24,19)) +
  stat_summary(fun.data = mean_cl_normal, geom = "errorbar", width=0.2, position=pd) +
  stat_summary(fun = mean, geom = "line", position=pd) + 
  stat_summary(fun = mean, geom = "point", size=3, position=pd)

e2 Retrieval: Resources Means

Table means for resources

Show the code
rrpremeans = rtv %>% group_by(rr, pp, fr) %>%
  summarise(mu=mean(mu)) %>% 
  summarise(mu=mean(mu)) 
rrmeans <- rrpremeans %>% 
  summarise(mean=mean(mu), sd=sd(mu))
prettify_means(rrmeans, "e2 Retrieval stage means")
e2 Retrieval stage means
rr mean sd
dispersed 2.06 0.11
patchy 1.64 0.35

e2 Retrieval: Fruit means

Table means for fruit

Show the code
frpremeans = rtv %>% group_by(fr, pp, rr) %>%
  summarise(mu=mean(mu)) %>% 
  summarise(mu=mean(mu))  
frmeans <- frpremeans %>% 
  summarise(mean=mean(mu), sd=sd(mu))
prettify_means(frmeans, "e2 Retrieval fruit means")
e2 Retrieval fruit means
fr mean sd
1 2.36 0.59
2 1.83 0.39
3 1.78 0.26
4 1.72 0.28
5 1.77 0.33
6 1.75 0.26
7 1.72 0.36
8 1.69 0.30
9 1.77 0.30
10 1.67 0.24
11 1.75 0.30
12 1.76 0.29
13 1.95 0.43
14 2.36 0.87