Skip to content

Commit

Permalink
use gaussian wherever possible for setting up the mgcv model; saves time
Browse files Browse the repository at this point in the history
nicholasjclark committed Nov 16, 2023
1 parent b4eeb55 commit fb723ac
Showing 6 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/families.R
Original file line number Diff line number Diff line change
@@ -342,13 +342,15 @@ family_to_brmsfam = function(family){
}

#' Set which family to use when setting up the gam object
#' Stick to Gaussian where possible to ensure the initial setup
#' doesn't fail
#' @noRd
family_to_mgcvfam = function(family){
if(family$family == 'beta'){
mgcv::betar()
} else if(family$family == 'student'){
gaussian()
} else if(family$family == 'lognormal'){
} else if(family$family %in% c('gamma', 'Gamma', 'lognormal')){
gaussian()
} else if(family$family == 'tweedie'){
mgcv::Tweedie(p = 1.5, link = 'log')
2 changes: 1 addition & 1 deletion R/gp.R
Original file line number Diff line number Diff line change
@@ -50,7 +50,7 @@ make_gp_additions = function(gp_details, data,

# Find the correct k to ensure that the total number of coefficients
# when using gp(k = k) is the same as when using s(k = k + 1)
smooth_terms <- unlist(purrr::map(mgcv_model$smooth, 'term'))
smooth_terms <- unlist(paste0(purrr::map(mgcv_model$smooth, 'term')))
smooth_bys <- unlist(purrr::map(mgcv_model$smooth, 'by'))
if(any(smooth_bys == 'NA')){
smooth_bys[smooth_bys == 'NA'] <- NA
Binary file modified src/RcppExports.o
Binary file not shown.
Binary file modified src/mvgam.dll
Binary file not shown.
Binary file modified src/trend_funs.o
Binary file not shown.
Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.

0 comments on commit fb723ac

Please sign in to comment.