Explanation: Type I: A linear functional response is represented as a * prey_density, where a is the attack rate. Type II: A decelerating curve based on Holling’s Disc Equation: (a * prey_density) / (1 + a * h * prey_density), where h is handling time. Type III: A sigmoid response function: (a * prey_density^d) / (1 + a * h * prey_density^d), where d controls the shape of the curve.
# Create a sequence of prey densities
prey_density <- seq(0, 50, by = 1)
# Type I: Linear increase with a constant rate
functional_response_type1 <- function(prey_density, a) {
return(a * prey_density)
}
# Type II: Holling's Disc Equation, a decelerating curve
functional_response_type2 <- function(prey_density, a, h) {
return((a * prey_density) / (1 + a * h * prey_density))
}
# Type III: Sigmoid functional response
functional_response_type3 <- function(prey_density, a, h, d) {
return((a * prey_density^d) / (1 + a * h * prey_density^d))
}
# Load necessary library
library(ggplot2)
# Parameters
a <- 0.9 # Attack rate
h <- 0.05 # Handling time
d <- 2 # Shape parameter for Type III
# Generate data for each functional response type
data <- data.frame(
prey_density = prey_density,
Type_I = functional_response_type1(prey_density, a),
Type_II = functional_response_type2(prey_density, a, h),
Type_III = functional_response_type3(prey_density, a, h, d)
)
# Convert to long format for ggplot2
library(reshape2)
data_long <- melt(data, id = "prey_density", variable.name = "Type", value.name = "Consumption_Rate")
# Plotting
ggplot(data_long, aes(x = prey_density, y = Consumption_Rate, color = Type)) +
geom_line(size = 1.2) +
labs(title = "Functional Response Curves",
x = "Prey Density",
y = "Consumption Rate") +
theme_minimal()
## Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
## ℹ Please use `linewidth` instead.
## This warning is displayed once every 8 hours.
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
Plot Interpretation: Type I: Linear until the prey density becomes large. Type II: Rapid increase at low densities, then saturation at high densities. Type III: Sigmoidal shape, showing low consumption at low densities, rapid increase at moderate densities, and then saturation at high densities.