Skip to content

Commit

Permalink
better conditional_effect plots; better error propagation of mgcv models
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Clark committed Nov 8, 2023
1 parent df5cd0c commit c4d53ed
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 18 deletions.
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ importFrom(brms,pstudent_t)
importFrom(brms,qstudent_t)
importFrom(brms,rstudent_t)
importFrom(brms,student)
importFrom(ggplot2,scale_colour_discrete)
importFrom(ggplot2,scale_fill_discrete)
importFrom(ggplot2,theme_classic)
importFrom(grDevices,devAskNewPage)
importFrom(grDevices,hcl.colors)
importFrom(grDevices,rgb)
Expand Down
11 changes: 7 additions & 4 deletions R/conditional_effects.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#' Display conditional effects of one or more numeric and/or categorical
#' predictors in `mvgam` models, including two-way interaction effects.
#' @importFrom brms conditional_effects
#' @importFrom ggplot2 scale_colour_discrete scale_fill_discrete theme_classic
#' @importFrom marginaleffects plot_predictions
#' @importFrom graphics plot
#' @importFrom grDevices devAskNewPage
Expand Down Expand Up @@ -114,7 +115,8 @@ conditional_effects.mvgam = function(x,
rug = rug,
...) +
scale_fill_discrete(label = roundlabs) +
scale_colour_discrete(label = roundlabs)
scale_colour_discrete(label = roundlabs) +
theme_classic()

}

Expand All @@ -128,7 +130,8 @@ conditional_effects.mvgam = function(x,
rug = rug,
...) +
scale_fill_discrete(label = roundlabs) +
scale_colour_discrete(label = roundlabs)
scale_colour_discrete(label = roundlabs) +
theme_classic()
}

if(length(cond_labs[[i]]) == 3){
Expand All @@ -142,7 +145,8 @@ conditional_effects.mvgam = function(x,
rug = rug,
...) +
scale_fill_discrete(label = roundlabs) +
scale_colour_discrete(label = roundlabs)
scale_colour_discrete(label = roundlabs) +
theme_classic()
}


Expand All @@ -161,7 +165,6 @@ conditional_effects.mvgam = function(x,
plot.mvgam_conditional_effects = function(x,
plot = TRUE,
ask = FALSE,
theme = NULL,
...){
out <- x
for(i in seq_along(out)){
Expand Down
6 changes: 2 additions & 4 deletions R/get_mvgam_priors.R
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,8 @@ get_mvgam_priors = function(formula,
stop(paste('Missing values found in data predictors:\n',
attr(ss_gam, 'condition')),
call. = FALSE)
}

if(grepl('fewer unique', ss_gam[1])){
stop('A term has fewer unique covariate combinations than specified maximum degrees of freedom',
} else {
stop(paste(ss_gam[1]),
call. = FALSE)
}
}
Expand Down
6 changes: 2 additions & 4 deletions R/mvgam.R
Original file line number Diff line number Diff line change
Expand Up @@ -755,10 +755,8 @@ mvgam = function(formula,
stop(paste('Missing values found in data predictors:\n',
attr(ss_gam, 'condition')),
call. = FALSE)
}

if(grepl('fewer unique', ss_gam[1])){
stop('A term has fewer unique covariate combinations than specified maximum degrees of freedom',
} else {
stop(paste(ss_gam[1]),
call. = FALSE)
}
}
Expand Down
7 changes: 1 addition & 6 deletions man/conditional_effects.mvgam.Rd

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

Binary file modified src/mvgam.dll
Binary file not shown.
Binary file modified tests/testthat/Rplots.pdf
Binary file not shown.

0 comments on commit c4d53ed

Please sign in to comment.