Skip to content

Instantly share code, notes, and snippets.

@padpadpadpad
Created January 5, 2017 21:37
Show Gist options
  • Save padpadpadpad/b800ce373c1b917b9b91680dafa7cbe7 to your computer and use it in GitHub Desktop.
Save padpadpadpad/b800ce373c1b917b9b91680dafa7cbe7 to your computer and use it in GitHub Desktop.
Looking at how community temperature dependence emerges from simulated species thermal performance curves
# Test hypothesis that activation energy of community is determined from activation energies of its determinants
n = 3
community <- data.frame(expand.grid(temp = seq(275, 305,0.5), curve = c(1:3)))
params <- data.frame(ln.c = c(1.5, 1, 0.5),
Ea = c(0.7, 0.5, 0.3),
Eh = rep(rnorm(n, 3, sd = 0.5)),
Th = c(rnorm(n, 300, sd = 2)),
curve = c(1,2,3))
community <- merge(community, params, by = 'curve') %>%
mutate(., rate = schoolfield.high(ln.c, Ea, Eh, Th, temp, Tc = 15)) %>%
select(., c(curve, temp, rate))
whole_community <- community %>%
group_by(temp) %>%
summarise(rate = sum(rate))
fit_whole_community <- nls(rate ~ schoolfield.high(ln.c, Ea, Eh, Th, temp = temp, Tc = 15),
data = whole_community,
start = list(ln.c = 1, Ea = 1, Eh = 4, Th = 295))
ggplot(community) +
geom_line(aes(temp - 273.15, rate, group = curve), alpha = 0.5) +
geom_line(aes(temp - 273.15, rate), whole_community)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment