Trees

This number is how many trees they looked at overall to get the ten fruit - high numbers represent worse performance.

E1 Ntrees: 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)

# average over tree-visits to get counts for each trial
ntr.counts <- e1 %>% 
  select(pp, rr, st, tb, tl) %>% 
  group_by(pp, rr, st, tb) %>% 
  summarise(ntrees=n()) %>% 
  ungroup() %>% 
  mutate(pp=as_factor(pp), rr=as_factor(rr),  st=as_factor(st))

# average over trials to get mean count for each stage
ntr <- ntr.counts %>% 
  group_by(pp, rr, st) %>% 
  summarise(mean_ntrees_per_stage=mean(ntrees))

saveRDS(ntr, "e1_ntrees_plot_data.rds")

E1 Ntrees: ANOVA

Run the ANOVA

Show the code
options(contrasts=c("contr.sum","contr.poly"))
e1_ntrees_ANOVA <- 
  ezANOVA(data=ntr,
          dv=mean_ntrees_per_stage,
          wid=pp,
          within=c(rr, st),
          type=3,
          return_aov = TRUE)
if("Sphericity Corrections" %in% names(e1_ntrees_ANOVA)){
  corr=aovSphericityAdjustment(e1_ntrees_ANOVA)$ANOVA %>% tibble()
} else {
  corr=e1_ntrees_ANOVA$ANOVA %>% tibble()  
  }

Table the ANOVA.

Show the code
prettify_anova(e1_ntrees_ANOVA, "E1 Ntrees ANOVA")
E1 Ntrees ANOVA
Effect DFn DFd F p sig
rr 1 41 52.17 0.000 ***
st 1 41 17.43 0.000 ***
rr:st 1 41 5.04 0.030 *

Report the ANOVA

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

The effect of stage was F(1, 41) = 17.43, p<.001.

The effect of the interaction resources x stage was F(1, 41) = 5.04, p<.05.

E1 Ntrees: Plot

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

Show the code
ggplot(data=ntr, aes(x=st, y=mean_ntrees_per_stage, group=rr, pch=rr, fill=rr)
) +
  my_fgms_theme+
  ggtitle("(a): Total trees visited")+
  ylab("Visits")+
  xlab("Trials")+
  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.1, position=pd) +
  stat_summary(fun = mean, geom = "line", position=pd) + 
  stat_summary(fun = mean, geom = "point", size=4, position=pd)+
  scale_x_discrete(labels=c("early\ntrials 1 to 5", "late\ntrials 6 to 10"))

E1 Number of trees: Resources Means

Table means for resources

Show the code
rrpremeans = ntr %>% group_by(rr, pp, st) %>%
  summarise(mu=mean(mean_ntrees_per_stage)) %>% 
  summarise(mu=mean(mu)) 
rrmeans <- rrpremeans %>% 
  summarise(mean=mean(mu), sd=sd(mu))
prettify_means(rrmeans, "E1 Number of trees resources means")
E1 Number of trees resources means
rr mean sd
dispersed 20.40 1.26
patchy 16.69 3.06

E1 Number of trees: Stage means

Table means for stage

Show the code
frpremeans = ntr %>% group_by(st, pp, rr) %>%
  summarise(mu=mean(mean_ntrees_per_stage)) %>% 
  summarise(mu=mean(mu))  
frmeans <- frpremeans %>% 
  summarise(mean=mean(mu), sd=sd(mu))
prettify_means(frmeans, "E1 Number of trees stage means")
E1 Number of trees stage means
st mean sd
early 19.09 1.84
late 18.00 1.85