Created
October 7, 2019 18:06
-
-
Save monogenea/deb164ddd02894d34da2852e3a79343a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simulation with average eggs laid, egg size and group size, w/ and w/o parasitism | |
seqX <- seq(-3, 3, length.out = 100) | |
probsNoPar <- sapply(seqX, function(x){ | |
scenario <- ilogit(a + x*bA) | |
probs <- calculate(scenario, draws) | |
return(unlist(probs)) | |
}) | |
probsPar <- sapply(seqX, function(x){ | |
scenario <- ilogit(a + x*bA + bP + x*bPA) | |
probs <- calculate(scenario, draws) | |
return(unlist(probs)) | |
}) | |
plot(seqX, apply(probsNoPar, 2, mean), type = "l", ylim = 0:1, | |
xlab = "Min age (standardized)", ylab = "P(Successful)", | |
yaxp = c(0, 1, 2)) | |
rethinking::shade(apply(probsNoPar, 2, rethinking::HPDI, prob = .95), | |
seqX) | |
lines(seqX, apply(probsPar, 2, mean), lty = 2, col = "red") | |
rethinking::shade(apply(probsPar, 2, rethinking::HPDI, prob = .95), | |
seqX, col = rgb(1,0,0,.25)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment