Description Usage Arguments Value Author(s) References Examples
View source: R/check_basis_vec_error.R
This is a function to check the output of maeve:::models_in_list() called from maeve::model_study(). A relatively common error in the automatic calling is to have an untenably low or high number of spline basis_vecs designated in the formula to gamm4() within maeve:::models_in_list(). This function attempts to auto-detect which error is being made (too few basis_vecs or too many?) and suggest an augmented count to facilitate a successful model fit.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | check_basis_vec_error(
fitted_model_list,
Min_Basis_Vec_n = NA,
Basis_Vec_n = NA,
Max_Basis_Vec_n = NA,
step_up = 1,
step_down = 1,
too_low_message = "Error: grouping factors must have > 1 sampled level\n",
too_high_message = paste0("Error in ",
"smooth.construct.tp.smooth.spec(object, dk$data, dk$knots): ",
"A term has fewer unique covariate combinations ",
"than specified maximum degrees of freedom\n"),
stop_for_other_error = TRUE,
other_error_message = paste("Unknown error in fitted_model_list object.",
"Hands-on investigation required.\n")
)
|
fitted_model_list |
any R object with a class() attribute. Anything for which class( fitted_model_list ) != "try-error" will be returned unchanged. |
Min_Basis_Vec_n |
numeric minimum number of basis_vecs required for gamm4() fit. Should match the value sent to maeve::model_study() |
Basis_Vec_n |
numeric target number of basis_vecs required for gamm4() fit. Should match the value sent to maeve::model_study() |
Max_Basis_Vec_n |
numeric maximum number of basis_vecs required for gamm4() fit. Should match the value sent to maeve::model_study() |
step_up |
numeric number by which to increase the target basis_vec count if the number of basis_vecs appears to be too low. |
step_down |
numeric number by which to decrease the target basis_vec count if the number of basis_vecs appears to be too high. |
too_low_message |
character expected error message if the number of basis_vecs is too low. |
too_high_message |
character expected error message if the number of basis_vecs is too high. |
stop_for_other_error |
logical should there be a stop if the input is a "try-error", but not with either of the expected error messages? |
other_error_message |
character error message returned in the list if the function does not stop and returns a list from an alternate try-error. |
A list with current & suggested numbers of spline basis_vecs.
Bill Forrest <forrest@gene.com>
Bill Forrest forrest@gene.com
1 2 3 4 5 | test_check_basis_vec_error <-
maeve:::check_basis_vec_error(
try( log( 'cat' ), silent = TRUE ),
stop_for_other_error = FALSE
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.