From 672ca9494e2e490e698b189fa587f3b2831e6c1e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 23:31:35 +0000 Subject: [PATCH 01/15] Initial plan From 1db6719c305bce2e1d60db1b12bca758faa27da3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 23:33:58 +0000 Subject: [PATCH 02/15] Convert man/CSEGriskfigure.Rd to Roxygen2 header in R/CSEGriskfigure.R Co-authored-by: eeholmes-uw <66437309+eeholmes-uw@users.noreply.github.com> Agent-Logs-Url: https://github.com/eeholmes-uw/MARSS/sessions/00fc5ffb-dcc6-47b6-9a7e-7528d933fc41 --- R/CSEGriskfigure.R | 49 +++++++++++++++++++++++++++++++++++++++ man/CSEGriskfigure.Rd | 53 ------------------------------------------- 2 files changed, 49 insertions(+), 53 deletions(-) delete mode 100644 man/CSEGriskfigure.Rd diff --git a/R/CSEGriskfigure.R b/R/CSEGriskfigure.R index e75a970e..41c8c4ce 100644 --- a/R/CSEGriskfigure.R +++ b/R/CSEGriskfigure.R @@ -1,3 +1,52 @@ +#' Plot Extinction Risk Metrics +#' +#' @description +#' Generates a six-panel plot of extinction risk metrics used in Population Viability Analysis (PVA). This is a function used by one of the vignettes in the [MARSS-package()]. +#' +#' @param data A data matrix with 2 columns; time in first column and counts in second column. Note time is down rows, which is different than the base [MARSS-package()] functions. +#' @param te Length of forecast period (positive integer) +#' @param absolutethresh Is extinction threshold an absolute number? (T/F) +#' @param threshold Extinction threshold either as an absolute number, if `absolutethresh=TRUE`, or as a fraction of current population count, if `absolutethresh=FALSE`. +#' @param datalogged Are the data already logged? (T/F) +#' @param silent Suppress printed output? (T/F) +#' @param return.model Return state-space model as [marssMLE()] object? (T/F) +#' @param CI.method Confidence interval method: "hessian", "parametric", "innovations", or "none". See [MARSSparamCIs()]. +#' @param CI.sim Number of simulations for bootstrap confidence intervals (positive integer). +#' +#' @details +#' Panel 1: Time-series plot of the data. +#' Panel 2: CDF of extinction risk. +#' Panel 3: PDF of time to reach threshold. +#' Panel 4: Probability of reaching different thresholds during forecast period. +#' Panel 5: Sample projections. +#' Panel 6: TMU plot (uncertainty as a function of the forecast). +#' +#' @return +#' If `return.model=TRUE`, an object of class [marssMLE()]. +#' +#' @references +#' Holmes, E. E., E. J. Ward, and M. D. Scheuerell (2012) Analysis of multivariate time-series using the MARSS package. NOAA Fisheries, Northwest Fisheries Science +#' Center, 2725 Montlake Blvd E., Seattle, WA 98112 Type `RShowDoc("UserGuide",package="MARSS")` to open a copy. +#' +#' (theory behind the figure) Holmes, E. E., J. L. Sabo, S. V. Viscido, and W. F. Fagan. (2007) A statistical approach to quasi-extinction forecasting. Ecology Letters 10:1182-1198. +#' +#' (CDF and PDF calculations) Dennis, B., P. L. Munholland, and J. M. Scott. (1991) Estimation of growth and extinction parameters for endangered species. Ecological Monographs 61:115-143. +#' +#' (TMU figure) Ellner, S. P. and E. E. Holmes. (2008) Resolving the debate on when extinction risk is predictable. Ecology Letters 11:E1-E5. +#' +#' @author +#' Eli Holmes, NOAA, Seattle, USA, and Steve Ellner, Cornell Univ. +#' +#' @seealso [MARSSboot()], [marssMLE()], [CSEGtmufigure()] +#' +#' @examples +#' d <- harborSeal[, 1:2] +#' kem <- CSEGriskfigure(d, datalogged = TRUE) +#' +#' @name CSEGriskfigure +#' @aliases CSEGriskfigure +#' @keywords experimental hplot +#' @export CSEGriskfigure <- function(data, te = 100, absolutethresh = FALSE, threshold = 0.1, datalogged = FALSE, silent = FALSE, return.model = FALSE, CI.method = "hessian", CI.sim = 1000) { if (!(CI.method %in% c("hessian", "parametric", "innovations", "none"))) { stop("Stopped in CSEGriskfigure(): Allowed values of 'CI.method' are \"none\", \"hessian\", \"parametric\", and \"innovations\".\n", call. = FALSE) diff --git a/man/CSEGriskfigure.Rd b/man/CSEGriskfigure.Rd deleted file mode 100644 index 4ddcfe1f..00000000 --- a/man/CSEGriskfigure.Rd +++ /dev/null @@ -1,53 +0,0 @@ -\name{CSEGriskfigure} -\alias{CSEGriskfigure} -\keyword{experimental} -\title{ Plot Extinction Risk Metrics } -\description{ - Generates a six-panel plot of extinction risk metrics used in Population Viability Analysis (PVA). This is a function used by one of the vignettes in the \code{\link{MARSS-package}}. -} -\usage{ -CSEGriskfigure(data, te = 100, absolutethresh = FALSE, threshold = 0.1, - datalogged = FALSE, silent = FALSE, return.model = FALSE, - CI.method = "hessian", CI.sim = 1000) -} -\arguments{ - \item{data}{ A data matrix with 2 columns; time in first column and counts in second column. Note time is down rows, which is different than the base \code{\link{MARSS-package}} functions.} - \item{te}{ Length of forecast period (positive integer) } - \item{absolutethresh}{ Is extinction threshold an absolute number? (T/F)} - \item{threshold}{ Extinction threshold either as an absolute number, if \code{absolutethresh=TRUE}, or as a fraction of current population count, if \code{absolutethresh=FALSE}. } - \item{datalogged}{ Are the data already logged? (T/F)} - \item{silent}{ Suppress printed output? (T/F) } - \item{return.model}{ Return state-space model as \code{\link{marssMLE}} object? (T/F)} - \item{CI.method}{ Confidence interval method: "hessian", "parametrc", "innovations", or "none". See \code{\link{MARSSparamCIs}}. } - \item{CI.sim}{ Number of simulations for bootstrap confidence intervals (positive integer). } -} -\details{ - Panel 1: Time-series plot of the data. - Panel 2: CDF of extinction risk. - Panel 3: PDF of time to reach threshold. - Panel 4: Probability of reaching different thresholds during forecast period. - Panel 5: Sample projections. - Panel 6: TMU plot (uncertainty as a function of the forecast). -} -\value{ - If \code{return.model=TRUE}, an object of class \code{\link{marssMLE}}. -} -\references{ -Holmes, E. E., E. J. Ward, and M. D. Scheuerell (2012) Analysis of multivariate time-series using the MARSS package. NOAA Fisheries, Northwest Fisheries Science -Center, 2725 Montlake Blvd E., Seattle, WA 98112 Type \code{RShowDoc("UserGuide",package="MARSS")} to open a copy. - -(theory behind the figure) Holmes, E. E., J. L. Sabo, S. V. Viscido, and W. F. Fagan. (2007) A statistical approach to quasi-extinction forecasting. Ecology Letters 10:1182-1198. - -(CDF and PDF calculations) Dennis, B., P. L. Munholland, and J. M. Scott. (1991) Estimation of growth and extinction parameters for endangered species. Ecological Monographs 61:115-143. - -(TMU figure) Ellner, S. P. and E. E. Holmes. (2008) Resolving the debate on when extinction risk is predictable. Ecology Letters 11:E1-E5. - } -\author{ - Eli Holmes, NOAA, Seattle, USA, and Steve Ellner, Cornell Univ. -} -\seealso{ \code{\link{MARSSboot}}, \code{\link{marssMLE}}, \code{\link{CSEGtmufigure}} } -\examples{ -d <- harborSeal[, 1:2] -kem <- CSEGriskfigure(d, datalogged = TRUE) -} -\keyword{ hplot } From 919da2303dcb4aa3197e55c1525d5142d0fd0fb4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 23 Mar 2026 23:53:21 +0000 Subject: [PATCH 03/15] Migrate CSEGriskfigure docs from hand-written .Rd to Roxygen2 Co-authored-by: eeholmes-uw <66437309+eeholmes-uw@users.noreply.github.com> Agent-Logs-Url: https://github.com/eeholmes-uw/MARSS/sessions/e5275a26-859f-4e7e-bcd5-f0f1a55a20eb --- R/CSEGriskfigure.R | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/R/CSEGriskfigure.R b/R/CSEGriskfigure.R index 41c8c4ce..5b038ca7 100644 --- a/R/CSEGriskfigure.R +++ b/R/CSEGriskfigure.R @@ -14,12 +14,12 @@ #' @param CI.sim Number of simulations for bootstrap confidence intervals (positive integer). #' #' @details -#' Panel 1: Time-series plot of the data. -#' Panel 2: CDF of extinction risk. -#' Panel 3: PDF of time to reach threshold. -#' Panel 4: Probability of reaching different thresholds during forecast period. -#' Panel 5: Sample projections. -#' Panel 6: TMU plot (uncertainty as a function of the forecast). +#' * Panel 1: Time-series plot of the data. +#' * Panel 2: CDF of extinction risk. +#' * Panel 3: PDF of time to reach threshold. +#' * Panel 4: Probability of reaching different thresholds during forecast period. +#' * Panel 5: Sample projections. +#' * Panel 6: TMU plot (uncertainty as a function of the forecast). #' #' @return #' If `return.model=TRUE`, an object of class [marssMLE()]. From 0e83792590d7717fae58405fe20d3799172ec60e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 00:01:07 +0000 Subject: [PATCH 04/15] Add GitHub Actions workflow: R CMD check + PDF manual + HTML docs artifacts Co-authored-by: eeholmes-uw <66437309+eeholmes-uw@users.noreply.github.com> Agent-Logs-Url: https://github.com/eeholmes-uw/MARSS/sessions/20e969b6-2399-4812-90f2-04bee8133b1f --- .github/workflows/check-and-docs.yaml | 102 ++++++++++++++++++++++++++ 1 file changed, 102 insertions(+) create mode 100644 .github/workflows/check-and-docs.yaml diff --git a/.github/workflows/check-and-docs.yaml b/.github/workflows/check-and-docs.yaml new file mode 100644 index 00000000..ff2ad335 --- /dev/null +++ b/.github/workflows/check-and-docs.yaml @@ -0,0 +1,102 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Runs R CMD check, builds the PDF manual, and builds a pkgdown HTML preview +# for the CSEGriskfigure documentation page. Artifacts are uploaded so they +# can be downloaded and inspected. +on: + push: + branches: [main, master, "copilot/**"] + pull_request: + branches: [main, master] + workflow_dispatch: + +name: check-and-docs + +jobs: + check-and-docs: + runs-on: ubuntu-latest + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_REMOTES_NO_ERRORS_FROM_WARNINGS: true + _R_CHECK_FORCE_SUGGESTS_: false + _R_CHECK_CRAN_INCOMING_: false + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + extra-repositories: https://atsa-es.r-universe.dev + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::rcmdcheck + any::roxygen2 + any::pkgdown + local::. + needs: check + + # Regenerate man/*.Rd from the inline Roxygen2 headers + - name: Roxygenise + run: roxygen2::roxygenise() + shell: Rscript {0} + + # Run R CMD check (mirrors the r-lib check-r-package action) + - name: R CMD check + id: rcmdcheck + run: | + options(crayon.enabled = TRUE) + if (Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "") == "") Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "false") + if (Sys.getenv("_R_CHECK_CRAN_INCOMING_", "") == "") Sys.setenv("_R_CHECK_CRAN_INCOMING_" = "false") + check_results <- rcmdcheck::rcmdcheck( + args = c("--no-manual", "--as-cran"), + build_args = "--no-manual", + error_on = "warning", + check_dir = "check" + ) + shell: Rscript {0} + + - name: Show testthat output + if: always() + run: | + find check -name 'testthat.Rout*' -exec cat '{}' \; || true + shell: bash + + # Build the PDF reference manual + - name: Build PDF manual + run: | + R CMD Rd2pdf --no-preview --output=MARSS-manual.pdf . + shell: bash + + # Build the full pkgdown site (HTML docs) + - name: Build pkgdown site + run: | + pkgdown::build_site(new_process = FALSE, install = FALSE) + shell: Rscript {0} + + # Upload the PDF manual as a downloadable artifact + - name: Upload PDF manual + if: always() + uses: actions/upload-artifact@v4 + with: + name: MARSS-pdf-manual + path: MARSS-manual.pdf + + # Upload the pkgdown HTML site as a downloadable artifact + - name: Upload HTML docs + if: always() + uses: actions/upload-artifact@v4 + with: + name: MARSS-html-docs + path: docs/ + + # Upload R CMD check results on failure + - name: Upload check results + if: failure() + uses: actions/upload-artifact@v4 + with: + name: check-results + path: check/ From 7cab275ecb34299fca38bd9f5d90e45699c39706 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 24 Mar 2026 00:13:35 +0000 Subject: [PATCH 05/15] Remove GitHub Actions workflow; add HTML preview of CSEGriskfigure docs Co-authored-by: eeholmes-uw <66437309+eeholmes-uw@users.noreply.github.com> Agent-Logs-Url: https://github.com/eeholmes-uw/MARSS/sessions/8d74b81d-528d-4ae0-a4c3-83098a0c7deb --- .github/workflows/check-and-docs.yaml | 102 ------------------ CSEGriskfigure_preview.html | 150 ++++++++++++++++++++++++++ 2 files changed, 150 insertions(+), 102 deletions(-) delete mode 100644 .github/workflows/check-and-docs.yaml create mode 100644 CSEGriskfigure_preview.html diff --git a/.github/workflows/check-and-docs.yaml b/.github/workflows/check-and-docs.yaml deleted file mode 100644 index ff2ad335..00000000 --- a/.github/workflows/check-and-docs.yaml +++ /dev/null @@ -1,102 +0,0 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples -# Runs R CMD check, builds the PDF manual, and builds a pkgdown HTML preview -# for the CSEGriskfigure documentation page. Artifacts are uploaded so they -# can be downloaded and inspected. -on: - push: - branches: [main, master, "copilot/**"] - pull_request: - branches: [main, master] - workflow_dispatch: - -name: check-and-docs - -jobs: - check-and-docs: - runs-on: ubuntu-latest - env: - GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} - R_REMOTES_NO_ERRORS_FROM_WARNINGS: true - _R_CHECK_FORCE_SUGGESTS_: false - _R_CHECK_CRAN_INCOMING_: false - - steps: - - uses: actions/checkout@v4 - - - uses: r-lib/actions/setup-pandoc@v2 - - - uses: r-lib/actions/setup-r@v2 - with: - use-public-rspm: true - extra-repositories: https://atsa-es.r-universe.dev - - - uses: r-lib/actions/setup-r-dependencies@v2 - with: - extra-packages: | - any::rcmdcheck - any::roxygen2 - any::pkgdown - local::. - needs: check - - # Regenerate man/*.Rd from the inline Roxygen2 headers - - name: Roxygenise - run: roxygen2::roxygenise() - shell: Rscript {0} - - # Run R CMD check (mirrors the r-lib check-r-package action) - - name: R CMD check - id: rcmdcheck - run: | - options(crayon.enabled = TRUE) - if (Sys.getenv("_R_CHECK_FORCE_SUGGESTS_", "") == "") Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "false") - if (Sys.getenv("_R_CHECK_CRAN_INCOMING_", "") == "") Sys.setenv("_R_CHECK_CRAN_INCOMING_" = "false") - check_results <- rcmdcheck::rcmdcheck( - args = c("--no-manual", "--as-cran"), - build_args = "--no-manual", - error_on = "warning", - check_dir = "check" - ) - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: | - find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - # Build the PDF reference manual - - name: Build PDF manual - run: | - R CMD Rd2pdf --no-preview --output=MARSS-manual.pdf . - shell: bash - - # Build the full pkgdown site (HTML docs) - - name: Build pkgdown site - run: | - pkgdown::build_site(new_process = FALSE, install = FALSE) - shell: Rscript {0} - - # Upload the PDF manual as a downloadable artifact - - name: Upload PDF manual - if: always() - uses: actions/upload-artifact@v4 - with: - name: MARSS-pdf-manual - path: MARSS-manual.pdf - - # Upload the pkgdown HTML site as a downloadable artifact - - name: Upload HTML docs - if: always() - uses: actions/upload-artifact@v4 - with: - name: MARSS-html-docs - path: docs/ - - # Upload R CMD check results on failure - - name: Upload check results - if: failure() - uses: actions/upload-artifact@v4 - with: - name: check-results - path: check/ diff --git a/CSEGriskfigure_preview.html b/CSEGriskfigure_preview.html new file mode 100644 index 00000000..ec6473e2 --- /dev/null +++ b/CSEGriskfigure_preview.html @@ -0,0 +1,150 @@ +
| CSEGriskfigure | R Documentation |
Generates a six-panel plot of extinction risk metrics used in Population Viability Analysis (PVA). This is a function used by one of the vignettes in the MARSS-package().
+
CSEGriskfigure(
+ data,
+ te = 100,
+ absolutethresh = FALSE,
+ threshold = 0.1,
+ datalogged = FALSE,
+ silent = FALSE,
+ return.model = FALSE,
+ CI.method = "hessian",
+ CI.sim = 1000
+)
+
+
+
+data |
+
+ A data matrix with 2 columns; time in first column and counts in second column. Note time is down rows, which is different than the base |
te |
+
+ Length of forecast period (positive integer) + |
absolutethresh |
+
+ Is extinction threshold an absolute number? (T/F) + |
threshold |
+
+ Extinction threshold either as an absolute number, if |
datalogged |
+
+ Are the data already logged? (T/F) + |
silent |
+
+ Suppress printed output? (T/F) + |
return.model |
+
+ Return state-space model as |
CI.method |
+
+ Confidence interval method: "hessian", "parametric", "innovations", or "none". See |
CI.sim |
+
+ Number of simulations for bootstrap confidence intervals (positive integer). + |
Panel 1: Time-series plot of the data. +
+Panel 2: CDF of extinction risk. +
+Panel 3: PDF of time to reach threshold. +
+Panel 4: Probability of reaching different thresholds during forecast period. +
+Panel 5: Sample projections. +
+Panel 6: TMU plot (uncertainty as a function of the forecast). +
+If return.model=TRUE, an object of class marssMLE().
+
Eli Holmes, NOAA, Seattle, USA, and Steve Ellner, Cornell Univ. +
+ + +Holmes, E. E., E. J. Ward, and M. D. Scheuerell (2012) Analysis of multivariate time-series using the MARSS package. NOAA Fisheries, Northwest Fisheries Science
+Center, 2725 Montlake Blvd E., Seattle, WA 98112 Type RShowDoc("UserGuide",package="MARSS") to open a copy.
+
(theory behind the figure) Holmes, E. E., J. L. Sabo, S. V. Viscido, and W. F. Fagan. (2007) A statistical approach to quasi-extinction forecasting. Ecology Letters 10:1182-1198. +
+(CDF and PDF calculations) Dennis, B., P. L. Munholland, and J. M. Scott. (1991) Estimation of growth and extinction parameters for endangered species. Ecological Monographs 61:115-143. +
+(TMU figure) Ellner, S. P. and E. E. Holmes. (2008) Resolving the debate on when extinction risk is predictable. Ecology Letters 11:E1-E5. +
+ + +MARSSboot(), marssMLE(), CSEGtmufigure()
+
d <- harborSeal[, 1:2]
+kem <- CSEGriskfigure(d, datalogged = TRUE)
+
+
+
+
+3!pxk4 dZJu}NtM#9f
kmqa8B2JszMq)d8N
zsvBQ!piQHZ`zBU2!|uT_3$O6|-mRqeB^Ayq=ecT;(YDFi9tU*`y!TsLn540KowSuc
zUuz|ab*=S8t1O;HJ~+Xu=15|Um!aN(Jc3_{IZ|@zR9qb5;vim0{W}9|ZAX34+FIdl#L^LQ}3)pgU>!B+|k419Fd7
z0ggawM;;+;N{=bjy{+XXMqiQ3M8L2At)a(%>W?}}S8oZsqKvKmw6Q4|c&R;(3K(V*
zeA2s_9_y)IvJ
#bB`x!U79H|ZW;n((p1)pV
zzMvFa@<^CK`yfG^fc;0=3qhj4WpMW2D@%^i_H
zQ1vqNmGP1Dyq*5ZHS}YbMF|}QA>#B4$$KqL`(m(r(Oj-QVy6BOEP8;44$ZSNwX
yn-F0Kxp!NMbHshkH!g=!6a#P+@u
h81i-X`QGocmBfBiEd*PUZeGL5wW^&otwB3ff~liJ#P;2r>xa)kpR$b9#;sw(
zNps2)7XJ^~1s(zx6AbPeH7a?ANw2P8B5QbmY)MRobT&meY@9vvAm38}g;smRpC
zo^dK(jpm2jxbnI1ym!HQz^7mEpxcyc%X
P
z)7$)1K?Zm^x|;fSBE4FNb#wwiehJD=Dmby;`%>HS6YY6f`~-fU+{|iokxCXFn^?#b
zM0?a_g&*8gvs<*X>F8*pluQM_lN9eet>iT3xl{XTc9&;xmGD`va@VkgTCFuQO!!w1
z5PQOfydq!xh<@74gOHVZ`+RnfQOb5vtmTtOtzi9-Wi49fXR(dh-hXOkt@BkAudA*>
znR;)Dv{k=|us@NKO2qbqNk`&ef#W^3CZMr^DJLmOFdocg9#CMbG235~eMm~vc`5Z}
zZ7#O=judV