Skip to content

Instantly share code, notes, and snippets.

@troyhill
Last active May 31, 2019 13:47
Show Gist options
  • Save troyhill/83314644b89a5571c0348d6dcdee9da3 to your computer and use it in GitHub Desktop.
Save troyhill/83314644b89a5571c0348d6dcdee9da3 to your computer and use it in GitHub Desktop.
recreates pink shrimp survival rate calculations from Browder et al. 2002
### function to calculate equations 4, 3, and 5 from Browder et al. 2002
sv.rate <- function(salinity, temperature, daily = FALSE) {
LP <- -4.6019 + (0.7039 * temperature) + (0.2186 * salinity) +
(-0.0250 * temperature^2) + (-0.0077 * salinity^2) +
(0.0115 * temperature * salinity) # equation 4, using survival rate coefficients from Table 1
ifelse(daily == TRUE,
M1 <- -log(exp(LP)) * (exp(LP) + 1)^-1 / 28, # daily survival # equation 3
M1 <- -log(exp(LP)) * (exp(LP) + 1)^-1 # 28-day survival
)
SV <- exp(-M1) # equation 5
SV
}
### range of values in figure 4, top panel (Browder et al. 2002)
x <- seq(from = 0, to = 70, by = 5)
y <- seq(from = 10, to = 40, by = 5)
z <- outer(x, y, sv.rate, daily = TRUE)
persp(x, y, z, theta = -60, phi = 30,
shade = 0.75, col = "lightblue", xlab = "salinity", ylab = "temperature", zlab = "daily survival",
ticktype = "detailed", expand = 0.75)
z <- outer(x, y, sv.rate, daily = FALSE)
persp(x, y, z, theta = -60, phi = 30,
shade = 0.75, col = "lightblue", xlab = "salinity", ylab = "temperature", zlab = "28-day survival",
ticktype = "detailed", expand = 0.75)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment