Selfreport - #11
Open
ericward-noaa wants to merge 4 commits into
Open
Conversation
Added self-reporting probability sub-model inputs and validation checks to fit_bycatch function. Enhanced data aggregation for self-reporting vessels.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds support for self-reporting as an additional monitoring stream in fit_bycatch(), including an optional Stan sub-model to estimate (with posterior uncertainty) the probability that monitored vessels also self-report, and uses that to adjust expansion effort to avoid double-counting coverage.
Changes:
- Introduces a 4th “self-report” stream (
takes_selfreport/effort_selfreport) alongside obs/em/both infit_bycatch(). - Adds an optional binomial sub-model (
covrate_selfreport+vessels_observed) to estimate pooledp_reportand adjust expansion effort in generated quantities. - Updates Rd documentation/examples and adjusts roxygen metadata in
DESCRIPTION.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
R/fitting.R |
Adds self-report stream inputs, validation, and yearly aggregation for self-report probability sub-model Stan data. |
inst/stan/bycatch.stan |
Extends the Stan model with a self-report stream likelihood plus a pooled p_report sub-model and expansion-effort adjustment. |
man/fit_bycatch.Rd |
Documents new parameters and adds a self-report usage example; fixes rstan link targets. |
DESCRIPTION |
Updates roxygen-related metadata (removes RoxygenNote, adds Config/roxygen2/version). |
Files not reviewed (1)
- man/fit_bycatch.Rd: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+28
to
+38
| if (estimate_self_report) { | ||
| row_n_observed <- data[[vessels_observed]] | ||
| row_n_self_report <- round(data[[covrate_selfreport]] / 100 * row_n_observed) | ||
|
|
||
| for (i in seq_len(nrow(data))) { | ||
| t <- time_idx[i] | ||
| n_vessels_observed[t] <- n_vessels_observed[t] + row_n_observed[i] | ||
| n_vessels_self_report[t] <- n_vessels_self_report[t] + row_n_self_report[i] | ||
| } | ||
| cli_inform("Self-report sub-model: {sum(n_vessels_observed)} observed vessels, {sum(n_vessels_self_report)} implied self-reporters") | ||
| } |
Comment on lines
+290
to
+295
| if (!is.null(covrate_selfreport)) { | ||
| if (any(data[[covrate_selfreport]] < 0 | data[[covrate_selfreport]] > 100, na.rm = TRUE)) { | ||
| stop("covrate_selfreport must be a percentage between 0 and 100") | ||
| } | ||
| } | ||
|
|
Comment on lines
+269
to
+276
| # Validate self-report stream inputs (a 4th stream, like em/both) | ||
| if (!is.null(takes_selfreport) && is.null(effort_selfreport)) { | ||
| stop("If takes_selfreport is provided, effort_selfreport must also be provided") | ||
| } | ||
| if (!is.null(effort_selfreport) && is.null(takes_selfreport)) { | ||
| stop("If effort_selfreport is provided, takes_selfreport must also be provided") | ||
| } | ||
|
|
Comment on lines
+786
to
+792
| for(t in 1:n_year) { | ||
| real expected_overlap = 0; | ||
| if(estimate_self_report == 1) { | ||
| expected_overlap = p_report[t] * effort_monitored_by_year[t]; | ||
| } | ||
| effort_selfreport_new_coverage[t] = fmax(effort_selfreport_by_year[t] - expected_overlap, 0); | ||
| new_effort_adjusted[t] = fmax(new_effort_by_year[t] - effort_selfreport_new_coverage[t], 0); |
Comment on lines
44
to
+49
| VignetteBuilder: knitr | ||
| Roxygen: list(markdown = TRUE) | ||
| SystemRequirements: GNU make | ||
| Biarch: true | ||
| Config/testthat/edition: 3 | ||
| Config/roxygen2/version: 8.0.0 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.