
generate detection range models Create logistic curve for detection efficiency with depth extrapolation
Source:R/1.4_function_detection_range_models.R
create_logistic_curve_depth.Rd
Generates a logistic detection efficiency model that varies with both distance and depth. The function interpolates d50 and d95 parameters linearly between minimum and maximum depths, creating a 3D detection efficiency surface.
Usage
create_logistic_curve_depth(
min_depth,
max_depth,
d50_min_depth,
d95_min_depth,
d50_max_depth,
d95_max_depth,
dist_step = 5,
depth_step = 1,
color_option = "magma",
plot = TRUE,
return_model = TRUE,
return_object = TRUE
)
Arguments
- min_depth
Numeric. Minimum depth in meters for the model.
- max_depth
Numeric. Maximum depth in meters for the model.
- d50_min_depth
Numeric. Distance (m) at which detection efficiency = 50% at minimum depth.
- d95_min_depth
Numeric. Distance (m) at which detection efficiency = 95% at minimum depth.
- d50_max_depth
Numeric. Distance (m) at which detection efficiency = 50% at maximum depth.
- d95_max_depth
Numeric. Distance (m) at which detection efficiency = 95% at maximum depth.
- dist_step
Numeric. Distance step size for grid predictions. Default is 5.
- depth_step
Numeric. Depth step size for grid predictions. Default is 1.
- color_option
Character. Viridis color palette option for plots. Default is "magma".
- plot
Logical. Whether to display visualization plots. Default is TRUE.
- return_model
Logical. Whether to fit and return a logistic regression model. Default is TRUE.
- return_object
Logical. Whether to return the complete function object. Default is TRUE.
Value
If return_object = TRUE, returns a list containing:
- func
The logistic function for calculating detection efficiency
- predict_grid
Function for generating prediction grids
- predictions
Data frame with distance, depth, and DE predictions
- params
List of input parameters
- log_model
Fitted logistic regression model (if return_model = TRUE)
- line_plot
ggplot2 line plot object (if plot = TRUE)
- heatmap_plot
ggplot2 heatmap object (if plot = TRUE)
- combined_plot
Combined plot using patchwork (if plot = TRUE)
If return_object = FALSE, returns invisibly or displays plots only.
Details
The function creates a logistic detection efficiency model where:
d50 and d95 parameters vary linearly with depth
Detection efficiency = 1 / (1 + exp(a + b * distance))
b = 2.944 / (d95 - d50)
a = -b * d50
The model assumes that detection efficiency decreases with distance and that the detection range changes with depth in a predictable manner.
Examples
if (FALSE) {
# Create a basic detection efficiency model
de_model <- create_logistic_curve_depth(
min_depth = 2,
max_depth = 30,
d50_min_depth = 50,
d95_min_depth = 20,
d50_max_depth = 150,
d95_max_depth = 60
)
# Use the model to predict detection efficiency
efficiency <- de_model$func(dist_m = 100, depth_m = 15)
# Generate custom predictions
custom_grid <- de_model$predict_grid(
dist_range = seq(0, 200, by = 10),
depth_range = seq(5, 25, by = 2)
)
# Create model without plots
de_model_quiet <- create_logistic_curve_depth(
min_depth = 2, max_depth = 30,
d50_min_depth = 50, d95_min_depth = 20,
d50_max_depth = 150, d95_max_depth = 60,
plot = FALSE
)
}