Distance

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

E2 Distance - Prepare the data

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) 

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

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

e2 <- e2 %>% rename(ll=ln)

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

e2 <- e2 %>% 
  mutate(ff=as_factor(ff),
         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 <- e2 %>% 
  group_by(ff, 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(ff, 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(ff, pp, rr, st, ll) %>% 
  summarise(mu.dist=mean(dist, na.rm=TRUE)) %>% 
  ungroup()

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

saveRDS(dst, "e2_distance_data.rds")

e2 Distance ANOVA

Run the ANOVA

2 x 2 x 2 x 2 fading, resources, stage, launch

Show the code
options(contrasts=c("contr.sum","contr.poly"))
e2_distance_ANOVA <- 
  ezANOVA(data=dst,
          dv=mu.dist,
          wid=pp,
          within=c(rr, st, ll),
          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_distance_ANOVA)){
  corr=aovSphericityAdjustment(e2_distance_ANOVA)$ANOVA %>% tibble()
} else {
  corr=e2_distance_ANOVA$ANOVA %>% tibble()  
  }

Table the ANOVA

Show the code
prettify_anova(e2_distance_ANOVA, "e2 Distance ANOVA")
e2 Distance ANOVA
Effect DFn DFd F p sig
ff 1 40 0.80 0.375
rr 1 40 35.46 0.000 ***
st 1 40 3.64 0.064
ll 1 40 28.98 0.000 ***
ff:rr 1 40 3.00 0.091
ff:st 1 40 3.24 0.079
ff:ll 1 40 2.53 0.120
rr:st 1 40 0.00 0.954
rr:ll 1 40 23.61 0.000 ***
st:ll 1 40 4.20 0.047 *
ff:rr:st 1 40 0.81 0.375
ff:rr:ll 1 40 0.32 0.575
ff:st:ll 1 40 0.11 0.746
rr:st:ll 1 40 1.53 0.223
ff:rr:st:ll 1 40 3.74 0.060

Report the ANOVA

The effect of fading was F(1, 40) = 0.80, p=0.375.

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

The effect of stage was F(1, 40) = 3.64, p=0.064.

The effect of stage was F(1, 40) = 28.98, p<.001.

2-way interactions

The resources x launch interaction was F(1, 40) = 23.61, p<.001.

The stage x launch interaction was F(1, 40) = 4.20, p<.05.

e2 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 10", "late trials\n11 to 20"))

E2 Distance means for resources

Show the code
dst %>% 
  group_by(rr, pp) %>%
  summarise(mu=mean(mu.dist)) %>% 
  summarise(mean=mean(mu), sd=sd(mu)) %>% 
  gt() %>% 
  fmt_number(decimals=0) %>% 
  tab_header("Pixels ")
Pixels
rr mean sd
dispersed 275 35
patchy 301 47

E2 Distance means for launch-site

Show the code
dst %>% 
  group_by(ll, pp) %>%
  summarise(mu=mean(mu.dist)) %>% 
  summarise(mean=mean(mu), sd=sd(mu)) %>% 
  gt() %>% 
  fmt_number(decimals=0) %>% 
  tab_header("Pixels ")
Pixels
ll mean sd
Launched from fruit 276 36
Launched from tree without fruit 299 45
Show the code
dst %>%
  filter(rr=="dispersed") %>% 
  group_by(ll, pp) %>% 
  summarise(mu=mean(mu.dist))%>% 
  summarise(mean=mean(mu), sd=sd(mu)) %>% 
  gt() %>% 
  fmt_number(decimals=0) %>% 
  tab_header("Pixels dispersed condition")
Pixels dispersed condition
ll mean sd
Launched from fruit 272 35
Launched from tree without fruit 277 36
Show the code
dst %>%
  filter(rr=="patchy") %>% 
  group_by(ll, pp) %>% 
  summarise(mu=mean(mu.dist))%>% 
  summarise(mean=mean(mu), sd=sd(mu)) %>% 
  gt() %>% 
  fmt_number(decimals=0) %>% 
  tab_header("Pixels patchy condition")
Pixels patchy condition
ll mean sd
Launched from fruit 280 41
Launched from tree without fruit 321 63