Skip to content

Uncertainty tools - #76

Closed
anon-lupineuncertainty wants to merge 37 commits into
padrinoDB:mainfrom
anon-lupineuncertainty:uncertainty-tools
Closed

anon-lupineuncertainty wants to merge 37 commits into
padrinoDB:mainfrom
anon-lupineuncertainty:uncertainty-tools

Conversation

@anon-lupineuncertainty

Copy link
Copy Markdown

Add uncertainty analysis of IPMs

Comment thread R/sensitivity.R
Comment on lines +134 to +144

perturb_lambda <- function(par, value) {
vpar <- pars_all
vpar[[par]] <- value
ipm_tmp <- ipm$proto_ipm
parameters(ipm_tmp) <- vpar
ker <- ipm_tmp %>%
make_ipm(iterate = FALSE) %>%
make_iter_kernel(mega_mat = mega_mat)
dominant_eigen(ker[[1]])
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small thing, but does this need to be defined within the scope of sensitivity? Or could it live outside of this function?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could definitely live outside of this function and be reused in uncertainty too!

Comment thread R/uncertainty.R
Comment on lines +136 to +139
cluster <- parallel::makePSOCKcluster(cores)
on.exit(parallel::stopCluster(cluster), add = TRUE)

parallel::clusterEvalQ(cluster, {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remember if parallel is considered "base R" or not, but if not, then need to add @importFrom parallel makPSOCKcluster stopCluster clusterEvalQ clusterExport to the Roxygen block above

Comment thread R/uncertainty.R
#' # enter_SB1, SB1_SB1, SB2_SB1,
#' # enter_SB2, SB1_SB2, SB2_SB2)"
#'
#' @importFrom dplyr bind_rows left_join rename group_by summarize join_by

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will probably be too much effort to be worth it, but I was trying to avoid having dependence on most tidyverse packages (except rlang because it was basically unavoidable, and purrr because I couldn't figure out my own version of flatten). If it's easy enough to alter, I'd suggest going that route, though I don't feel strongly enough about this anymore to say it's a must.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is definitely doable, for uncertainty and sensitivity too.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before you do anything with this - did you make the figures in the manuscript with the plot functions? They're beautiful! ggplot2 doesn't directly import dplyr, but chances are most folks who use this probably already have it installed.

Comment thread DESCRIPTION
patchwork,
reshape2,
stringr
Depends: R (>= 3.4)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ggplot2 requires R>4.1, so need to bump this here

@levisc8
levisc8 marked this pull request as ready for review August 28, 2026 11:26
@levisc8 levisc8 closed this Aug 28, 2026
@levisc8

levisc8 commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Closing this as discussed. Let me know when you're ready to create it from your account!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants