-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
working in a standard plot_effects function
- Loading branch information
1 parent
2383d1c
commit 4d1362b
Showing
15 changed files
with
321 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#' Effect plot as implemented in \pkg{marginaleffects} | ||
#' | ||
#' Convenient way to call marginal or conditional effect plotting functions | ||
#' implemented in the \pkg{marginaleffects} package | ||
#' @importFrom marginaleffects plot_predictions | ||
#' @name plot_effects.mvgam | ||
#' @inheritParams marginaleffects::plot_predictions | ||
#' @return A \code{\link[ggplot2:ggplot]{ggplot}} object | ||
#' that can be further customized using the \pkg{ggplot2} package | ||
#'@export | ||
plot_effects <- function(object, ...){ | ||
UseMethod("plot_effects", object) | ||
} | ||
|
||
#' @name plot_effects.mvgam | ||
#' @method plot_effects mvgam | ||
#' @export | ||
plot_effects.mvgam = function(model, | ||
condition = NULL, | ||
by = NULL, | ||
newdata = NULL, | ||
type = NULL, | ||
conf_level = 0.95, | ||
wts = NULL, | ||
transform = NULL, | ||
points = 0, | ||
rug = FALSE, | ||
...){ | ||
# Set colour scheme | ||
col_scheme <- attr(bayesplot::color_scheme_get(), | ||
'scheme_name') | ||
bayesplot::color_scheme_set('viridis') | ||
|
||
# Generate plot and reset colour scheme | ||
out_plot <- plot_predictions(model = model, | ||
condition = condition, | ||
by = by, | ||
newdata = newdata, | ||
type = type, | ||
vcov = NULL, | ||
conf_level = conf_level, | ||
wts = wts, | ||
transform = transform, | ||
points = points, | ||
rug = rug, | ||
gray = FALSE, | ||
draw = TRUE, | ||
...) + bayesplot::bayesplot_theme_get() | ||
color_scheme_set(col_scheme) | ||
|
||
# Return the plot | ||
return(out_plot) | ||
} |
Oops, something went wrong.