Skip to content

Commit

Permalink
Merge pull request #55 from adamlilith/daisywheel
Browse files Browse the repository at this point in the history
Work w factors w >2 levels; remove unconverged models
  • Loading branch information
adamlilith authored Dec 8, 2024
2 parents 583ce6b + babd6df commit 05b640f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions R/trainGlm.r
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -70,7 +70,7 @@ trainGLM <- function(
w = TRUE,
family = stats::binomial(),
removeInvalid = TRUE,
failIfInvalid = TRUE,
failIfNoValid = TRUE,
out = 'model',
cores = 1,
verbose = FALSE,
Expand All @@ -94,7 +94,7 @@ trainGLM <- function(
maxTerms <- 8
w <- TRUE
removeInvalid <- TRUE
failIfInvalid <- TRUE
failIfNoValid <- TRUE
scale <- TRUE
family <- stats::binomial()
out <- 'model'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions R/trainNs.r
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,7 +62,7 @@ trainNS <- function(
w = TRUE,
family = 'binomial',
removeInvalid = TRUE,
failIfInvalid = TRUE,
failIfNoValid = TRUE,
out = 'model',
cores = 1,
verbose = FALSE,
Expand All @@ -83,7 +83,7 @@ trainNS <- function(
w <- TRUE
family <- 'binomial'
removeInvalid <- TRUE
failIfInvalid <- TRUE
failIfNoValid <- TRUE
out <- 'model'
cores <- 1
verbose <- TRUE
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions man/trainGlm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/trainNs.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05b640f

Please sign in to comment.