Skip to content

Commit

Permalink
Improve, again, visreg messages
Browse files Browse the repository at this point in the history
  • Loading branch information
seananderson committed Mar 26, 2024
1 parent 3f50fbe commit ffe6b6f
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions R/residuals.R
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ residuals.sdmTMB <- function(object,
...) {
type_was_missing <- missing(type)
type <- match.arg(type[[1]], choices = c("mle-mvn", "mle-laplace", "mle-eb", "mle-mcmc", "response", "pearson"))
if (!"visreg_model" %in% names(object)) {

# retrieve function that called this:
sys_calls <- unlist(lapply(sys.calls(), deparse))
visreg_call <- any(grepl("setupV", substr(sys_calls, 1, 7)))
if (!visreg_call) {
if (type_was_missing || type == "mle-laplace") {
msg <- paste0("Note what used to be the default sdmTMB residuals ",
"(before version 0.4.3.9005) are now `type = 'mle-eb'`. We recommend using ",
Expand All @@ -321,18 +325,6 @@ residuals.sdmTMB <- function(object,
# need to re-attach environment if in fresh session
reinitialize(object)

# retrieve function that called this:
sys_calls <- unlist(lapply(sys.calls(), deparse))
visreg_call <- any(grepl("setupV", substr(sys_calls, 1, 7)))

if (!visreg_call) {
msg <- c(
"We recommend using the slower `type = 'mle-mcmc'` for final inference.",
"See the ?residuals.sdmTMB 'Details' section."
)
if (type == "randomized-quantile") cli_inform(msg)
}

fam <- object$family$family
nd <- NULL
est_column <- "est"
Expand Down

0 comments on commit ffe6b6f

Please sign in to comment.