Retrieval

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

E1 Retrieval: Prepare the data

Read the data in and pre-process it.

Show the code
e1 <- readRDS("001-00-e1-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
e1 <- e1 %>% filter(fl>0)

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

# remove trials where they failed to get 10 fruit
e1 <- e1 %>% 
  group_by(pp, rr, tb) %>% 
  mutate(max_fr = max(fr)) %>% 
  ungroup() %>% 
  filter(max_fr==10)

# 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
e1$ntrees_to_get_a_fruit = NA
j = 0
for (k in seq_along(e1$ix)) {
 j = j + 1
 if (e1[k, 'fl']==2) {
   e1[k, 'ntrees_to_get_a_fruit'] = j
   j = 0
 }
}

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

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

saveRDS(rtv, "e1_retrieval_plot_data.rds")

E1 Retrieval: ANOVA

Run the ANOVA

Show the code
options(contrasts=c("contr.sum","contr.poly"))
e1_retrievalrate_ANOVA <- 
  ezANOVA(data=rtv,
          dv=mu,
          wid=pp,
          within=c(rr, fr),
          type=3, 
          return_aov = TRUE)

if("Sphericity Corrections" %in% names(e1_retrievalrate_ANOVA)){
  corr=aovSphericityAdjustment(e1_retrievalrate_ANOVA)$ANOVA %>% tibble()
} else {
  corr=e1_retrievalrate_ANOVA$ANOVA %>% tibble()  
  }

Table the ANOVA taking into account sphericity violations.

Show the code
prettify_sphericity(
  aovSphericityAdjustment(e1_retrievalrate_ANOVA), 
  "E1 Retrieval ANOVA") 
E1 Retrieval ANOVA
Effect DFn DFd F p sig
rr 1 41 54.14 0.000 ***
fr 3.91 160.43 22.99 0.000 ***
rr:fr 4.83 197.91 46.85 0.000 ***

Report the ANOVA

The effect of resources was F(1, 41) = 54.14, p<.001.

The effect of fruit was F(3.9, 160.4) = 22.99, p<.001.

The fruit x resources interaction was F(4.8, 197.9) = 46.85, p<.001.

E1 Retrieval: Plot

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

Show the code
ggplot(
  data=rtv, 
  aes(x=fr, y=mu, group=rr, fill=rr, shape=rr)
) +
  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="Resource\ndistribution", values=c("white", "black")) +
  scale_shape_manual(name="Resource\ndistribution", 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)

E1 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, "E1 Retrieval stage means")
E1 Retrieval stage means
rr mean sd
dispersed 2.04 0.13
patchy 1.67 0.30

E1 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, "E1 Retrieval fruit means")
E1 Retrieval fruit means
fr mean sd
1 2.79 0.90
2 2.00 0.63
3 1.67 0.28
4 1.77 0.44
5 1.73 0.36
6 1.75 0.38
7 1.68 0.35
8 1.58 0.20
9 1.74 0.44
10 1.79 0.38