Distance

The Euclidian distance between successive tree-visits, in units of pixels.

E1 Distance - Prepare the data

Read the data 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)

# Euclid
e1 <- e1 %>% 
  group_by(pp, rr, tb) %>% 
  mutate(dist = round(sqrt((lead(xx)-xx)^2 + (lead(yy)-yy)^2), 2)) %>% 
  ungroup()

# time
e1 <- e1 %>% 
  group_by(pp, rr, tb) %>% 
  mutate(tm=tm-first(tm)) %>%
  ungroup()

# fewer columns
e1 <- e1 %>% 
  select(pp, rr, st, tb, tm, ll, tl, dist)

e1 <- e1 %>% 
  mutate(pp = as_factor(pp), 
         st=as_factor(st), 
         tb=as_factor(tb),
         ll=factor(ll, levels=c("fruit", "not"), labels=c(
           "Launched from fruit", "Launched from tree without fruit"
         )),
         rr=factor(rr, levels=c("dispersed", "patchy")), 
         )

dst <- e1 %>% 
  group_by(pp, rr, st, ll, tb) %>% 
  # average over tree-visits yielding
  # two values for each trial, 
  # one for launch from fruit, 
  # one for launch from empty
  summarise(dist=mean(dist, na.rm=TRUE)) %>% 
  arrange(pp, rr, st, ll, tb, .by_group = TRUE) %>% 
  ungroup()

# average over trials in each of the two stages,
# to yield one row for each launch type, per stage
# 8 rows per subject, 2 x 2 x 2
# 2 x 2 x 2 x 42=336 rows
dst <- dst %>% 
  group_by(pp, rr, st, ll) %>% 
  summarise(mu.dist=mean(dist, na.rm=TRUE)) %>% 
  ungroup()


dst <- dst %>% 
  select(rr, st, ll, pp, mu.dist) %>% 
  arrange(rr, st, ll, pp, mu.dist)

saveRDS(dst, "e1_distance_data.rds")

E1 Distance ANOVA

Run the ANOVA

2 x 2 x 2 resources, stage, launch

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

Table the ANOVA

Show the code
prettify_anova(e1_distance_ANOVA, "E1 Distance ANOVA")
E1 Distance ANOVA
Effect DFn DFd F p sig
rr 1 41 13.09 0.001 **
st 1 41 6.18 0.017 *
ll 1 41 31.62 0.000 ***
rr:st 1 41 8.89 0.005 **
rr:ll 1 41 16.06 0.000 ***
st:ll 1 41 4.37 0.043 *
rr:st:ll 1 41 11.62 0.001 **

Report the ANOVA

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

The effect of stage was F(1, 41) = 6.18, p<.05.

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

The effect of the interaction resources x stage x launch was F(1, 41) = 11.62, p<.01.

E1 Distance: Plot

x axis is stage; y axis is distance; group is resources; panel is launch site type

Show the code
ggplot(data=dst, aes(y=mu.dist, x=st, group=rr, fill=rr, shape=rr)) +
  facet_wrap(~ll) +
  labs(title="(d): Distance moved between trees", subtitle = "The eyes move further to the next tree if the current tree has no fruit")+
  ylab("Pixels")+
  xlab("Trials")+
  my_fgms_theme+
  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=3, position=pd)+
  scale_x_discrete(labels=c("early trials\n1 to 5", "late trials\n6 to 10"))

E1 Distance means

Stage means for patchy no-fruit increase over trials as subjects learn over the course of the experiment to move further when they are less likely to be in a patch, and to stay within fruitful areas (area restricted search)

Show the code
dst %>% filter(rr=="patchy", ll=="Launched from tree without fruit") %>% 
  group_by(st) %>% 
  summarise(mean=mean(mu.dist), sd=sd(mu.dist)) %>% 
  gt() %>% 
  fmt_number(decimals=0) %>% 
  tab_header("Pixels for patchy no-fruit")
Pixels for patchy no-fruit
st mean sd
early 337 68
late 389 124