Created
April 9, 2020 20:56
-
-
Save Myfanwy/bce18dacca3c55d9fb8904e51c83ad4b to your computer and use it in GitHub Desktop.
This file contains 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
library(tidyverse) | |
# Previous version of SBM used 120 mm cutoff for rearing | |
# Exploring idea of using hypothetical continuous relationship between rearing probability and fork length | |
## Four-parameter logistic model gives nice control over the curve | |
# a = max value | |
# b = steepness of the curve | |
# c = inflection point | |
# d = min value | |
logistic_4p <- function(fl, a, b, c, d){ | |
d + (a - d)/(1 + (fl / c)^b) | |
} | |
tibble(FL = 30:150, | |
Prob = logistic_4p(FL, 1, 7, 75, 0)) %>% | |
ggplot(aes(x = FL, y = Prob)) + | |
geom_line() + | |
labs(x = "Fork length (mm)", y = "Probability of rearing") + | |
coord_cartesian(ylim = c(0, 1)) + | |
scale_x_continuous(breaks = seq(30, 150, 10)) + | |
theme_minimal() | |
## simple linear relationship with logit transformation | |
inv_logit = function (x){ | |
p = 1/(1 + exp(-x)) | |
p[is.infinite(p)] = 1 | |
p | |
} | |
intercept = 10 | |
slope = -0.12 | |
tibble(FL = 30:150, | |
Prob = inv_logit(intercept + slope * FL)) %>% | |
ggplot(aes(x = FL, y = Prob)) + | |
geom_line() + | |
labs(x = "Fork length (mm)", y = "Probability of rearing") + | |
coord_cartesian(ylim = c(0, 1)) + | |
scale_x_continuous(breaks = seq(30, 150, 10)) + | |
theme_minimal() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment