Skip to content

Commit

Permalink
change warning about 'stack imbalance' to appear only once, after the…
Browse files Browse the repository at this point in the history
… first call to a model fitting function if the data are filebacked
  • Loading branch information
tabpeter committed Feb 10, 2025
1 parent 853dbb9 commit 78c4e8d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
19 changes: 18 additions & 1 deletion R/plmm_checks.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ plmm_checks <- function(design,
# set default init
if(is.null(init)){init <- rep(0, std_X_p)}

# set default gamma (gamma not used in 'lasso' option)
# set default gamma (gamma not used in 'lasso' option)
if (missing(gamma)) gamma <- switch(penalty, SCAD = 3.7, MCP = 3, lasso = 1)

# error checking design matrix ---------------------------------------------
Expand Down Expand Up @@ -121,6 +121,23 @@ plmm_checks <- function(design,
plink_flag <- FALSE
}

# warn about bigalgebra issues if this is user's first call to filebacked analysis
# Check if the warning has been shown
if (!.plmmr_env$warning_shown & fbm_flag) {

warning("Note: plmmr depends on the package bigalgebra, the current GitHub \n
version of which is throwing some warnings for filebacked analysis. \n
See https://github.com/fbertran/bigalgebra/issues/2 \n
If you see a warning about 'stack imbalance' appear while you are \n
fitting a model with plmm() or cv_plmm(), we recommend downloading \n
the last stable version of bigalebra.\n
This message is displayed after your first call to fit a model \n
using filebacked data.\n")

# Update the state
.plmmr_env$warning_shown <- TRUE
}

# return list for model preparation ---------------------------------
ret <- list(
std_X = std_X,
Expand Down
15 changes: 8 additions & 7 deletions R/zzz.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
.onAttach <- function(libname, pkgname) {
packageStartupMessage("This is version ", utils::packageVersion(pkgname),
" of ", pkgname, ".\n",
"Note: ", pkgname, " depends on the package bigalgebra, the current GitHub version of which is throwing some warnings for filebacked analysis.
\n https://github.com/fbertran/bigalgebra/issues/2 \n
If you see a warning about 'stack imbalance' appear while you are fitting a model with plmm() or cv_plmm(), we recommend downloading the last stable version of bigalebra.
If you are analyzing data stored in your R session memory, you can disregard this message.")
}
packageStartupMessage("This is ", pkgname, " ", utils::packageVersion(pkgname), ".\n")
}

# Define an environment to store the state
.plmmr_env <- new.env()

# Initialize the state
.plmmr_env$warning_shown <- FALSE

0 comments on commit 78c4e8d

Please sign in to comment.