From babd6df38f3028fb8d2e85a30db15edaec37629d Mon Sep 17 00:00:00 2001 From: "Adam B. Smith" Date: Sat, 7 Dec 2024 23:44:57 -0600 Subject: [PATCH] Work w factors w >2 levels; remove unconverged models --- R/trainGlm.r | 14 +++++++------- R/trainNs.r | 10 +++++----- man/trainGlm.Rd | 4 ++-- man/trainNs.Rd | 4 ++-- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/R/trainGlm.r b/R/trainGlm.r index ac3a011..c59e453 100644 --- a/R/trainGlm.r +++ b/R/trainGlm.r @@ -26,7 +26,7 @@ #' \item The name of the column in \code{data} that contains site weights. #' } #' @param removeInvalid Logical. If \code{TRUE} (default), remove models that either did not converge or have parameter estimates near the boundaries (usually negative or positive infinity). If you run this function with `construct = TRUE` (i.e., construct a "full" model from the best "small" models), then any small model that either did not converge or had parameters that are near the boundary (usually negative or positive infinity) are removed from consideration as terms in "full" model. -#' @param failIfInvalid Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case. +#' @param failIfNoValid Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case. #' @param out Character vector. One or more values: #' \itemize{ #' \item \code{'model'}: Model with the lowest AICc. @@ -70,7 +70,7 @@ trainGLM <- function( w = TRUE, family = stats::binomial(), removeInvalid = TRUE, - failIfInvalid = TRUE, + failIfNoValid = TRUE, out = 'model', cores = 1, verbose = FALSE, @@ -94,7 +94,7 @@ trainGLM <- function( maxTerms <- 8 w <- TRUE removeInvalid <- TRUE - failIfInvalid <- TRUE + failIfNoValid <- TRUE scale <- TRUE family <- stats::binomial() out <- 'model' @@ -211,7 +211,7 @@ trainGLM <- function( if (nrow(assess) == 0) { msg <- 'No single-term models converged or all models had parameter estimates near the boundary.' - if (failIfInvalid) { + if (failIfNoValid) { stop(msg) } else { warning(msg) @@ -290,7 +290,7 @@ trainGLM <- function( msg <- 'The model did not converge and/or estimates are near boundary conditions.' if (removeInvalid) { - if (failIfInvalid) { + if (failIfNoValid) { stop(msg) } else { warning(msg) @@ -453,7 +453,7 @@ trainGLM <- function( if (nrow(tuning) == 0) { msg <- 'No models converged or all had parameter estimates near the boundary of parameter space.' - if (failIfInvalid) { + if (failIfNoValid) { stop(msg) } else { warning(msg) @@ -519,7 +519,7 @@ trainGLM <- function( msg <- 'The model did not converge and/or parameters are near the boundary space.' if (removeInvalid) { - if (failIfInvalid) { + if (failIfNoValid) { stop(msg) } else { warning(msg) diff --git a/R/trainNs.r b/R/trainNs.r index 64604e6..0ada204 100644 --- a/R/trainNs.r +++ b/R/trainNs.r @@ -21,7 +21,7 @@ #' } #' @param family Name of family for data error structure (see \code{\link[stats]{family}}). #' @param removeInvalid Logical. If \code{TRUE} (default), remove models that either did not converge or have parameter estimates near the boundaries (usually negative or positive infinity). -#' @param failIfInvalid Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case. +#' @param failIfNoValid Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case. #' @param out Character vector. One or more values: #' \itemize{ #' \item \code{'model'}: Model with the lowest AICc. @@ -62,7 +62,7 @@ trainNS <- function( w = TRUE, family = 'binomial', removeInvalid = TRUE, - failIfInvalid = TRUE, + failIfNoValid = TRUE, out = 'model', cores = 1, verbose = FALSE, @@ -83,7 +83,7 @@ trainNS <- function( w <- TRUE family <- 'binomial' removeInvalid <- TRUE - failIfInvalid <- TRUE + failIfNoValid <- TRUE out <- 'model' cores <- 1 verbose <- TRUE @@ -238,7 +238,7 @@ trainNS <- function( if (nrow(work) == 0) { msg <- 'No single-term models converged or all models had parameter estimates near the boundary.' - if (failIfInvalid) { + if (failIfNoValid) { stop(msg) } else { warning(msg) @@ -357,7 +357,7 @@ trainNS <- function( if (nrow(work) == 0) { msg <- 'No single-term models converged or all models had parameter estimates near the boundary.' - if (failIfInvalid) { + if (failIfNoValid) { stop(msg) } else { warning(msg) diff --git a/man/trainGlm.Rd b/man/trainGlm.Rd index 36d0fa0..2a1f3f2 100644 --- a/man/trainGlm.Rd +++ b/man/trainGlm.Rd @@ -21,7 +21,7 @@ trainGLM( w = TRUE, family = stats::binomial(), removeInvalid = TRUE, - failIfInvalid = TRUE, + failIfNoValid = TRUE, out = "model", cores = 1, verbose = FALSE, @@ -67,7 +67,7 @@ trainGLM( \item{removeInvalid}{Logical. If \code{TRUE} (default), remove models that either did not converge or have parameter estimates near the boundaries (usually negative or positive infinity). If you run this function with `construct = TRUE` (i.e., construct a "full" model from the best "small" models), then any small model that either did not converge or had parameters that are near the boundary (usually negative or positive infinity) are removed from consideration as terms in "full" model.} -\item{failIfInvalid}{Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case.} +\item{failIfNoValid}{Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case.} \item{out}{Character vector. One or more values: \itemize{ diff --git a/man/trainNs.Rd b/man/trainNs.Rd index 32990db..9a1bb5e 100644 --- a/man/trainNs.Rd +++ b/man/trainNs.Rd @@ -18,7 +18,7 @@ trainNS( w = TRUE, family = "binomial", removeInvalid = TRUE, - failIfInvalid = TRUE, + failIfNoValid = TRUE, out = "model", cores = 1, verbose = FALSE, @@ -58,7 +58,7 @@ trainNS( \item{removeInvalid}{Logical. If \code{TRUE} (default), remove models that either did not converge or have parameter estimates near the boundaries (usually negative or positive infinity).} -\item{failIfInvalid}{Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case.} +\item{failIfNoValid}{Logical. If \code{TRUE} (default), and the "full" model either does not converge or has parameters near the boundary, then the function will fail. If \code{FALSE}, then return \code{NULL} in this case.} \item{out}{Character vector. One or more values: \itemize{