Skip to content

Commit 5784633

Browse files
author
Nicholas Clark
committed
add eval_smooth general method
1 parent 65c0687 commit 5784633

File tree

5 files changed

+29
-11
lines changed

5 files changed

+29
-11
lines changed

DESCRIPTION

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ Suggests:
5353
coda,
5454
runjags,
5555
tibble (>= 3.0.0),
56+
gratia,
5657
usethis,
5758
testthat
5859
Additional_repositories: https://mc-stan.org/r-packages/

NAMESPACE

+1-9
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ export(code)
7878
export(compare_mvgams)
7979
export(dynamic)
8080
export(eval_mvgam)
81+
export(eval_smooth)
8182
export(forecast)
8283
export(get_mvgam_priors)
8384
export(hindcast)
@@ -157,14 +158,6 @@ importFrom(graphics,polygon)
157158
importFrom(graphics,rect)
158159
importFrom(graphics,rug)
159160
importFrom(graphics,title)
160-
importFrom(gratia,by_level)
161-
importFrom(gratia,by_variable)
162-
importFrom(gratia,eval_smooth)
163-
importFrom(gratia,is_factor_by_smooth)
164-
importFrom(gratia,smooth_dim)
165-
importFrom(gratia,smooth_label)
166-
importFrom(gratia,smooths)
167-
importFrom(gratia,spline_values)
168161
importFrom(insight,find_predictors)
169162
importFrom(insight,get_data)
170163
importFrom(insight,get_predictors)
@@ -282,7 +275,6 @@ importFrom(stats,ts)
282275
importFrom(stats,update)
283276
importFrom(stats,update.formula)
284277
importFrom(stats,var)
285-
importFrom(tibble,add_column)
286278
importFrom(utils,getFromNamespace)
287279
importFrom(utils,head)
288280
importFrom(utils,lsf.str)

R/monotonic.R

+11-2
Original file line numberDiff line numberDiff line change
@@ -413,10 +413,17 @@ add_mono_model_file = function(model_file,
413413
model_data = model_data))
414414
}
415415

416+
#' S3 methods to evaluate individual smooths
417+
#' @param smooth currently an object that inherits from class `mgcv.smooth`
418+
#' @param ... arguments passed to other methods
419+
#' @export
420+
`eval_smooth` <- function(smooth, ...) {
421+
UseMethod("eval_smooth")
422+
}
423+
416424
#' Evaluation of a monotonically increasing function
417425
#' These evaluation functions are needed so that gratia::draw methods work with mvgam
418426
#' monotonic smooths
419-
#' @importFrom gratia eval_smooth smooths by_variable smooth_label spline_values is_factor_by_smooth by_level smooth_dim
420427
#' @rdname monotonic
421428
#' @export
422429
eval_smooth.moi.smooth = function(smooth,
@@ -429,6 +436,8 @@ eval_smooth.moi.smooth = function(smooth,
429436
overall_uncertainty = TRUE,
430437
dist = NULL,
431438
...) {
439+
440+
insight::check_if_installed("gratia")
432441
model$cmX <- model$coefficients
433442

434443
## deal with data if supplied
@@ -511,6 +520,7 @@ eval_smooth.mod.smooth = function(smooth,
511520
overall_uncertainty = TRUE,
512521
dist = NULL,
513522
...) {
523+
insight::check_if_installed("gratia")
514524
model$cmX <- model$coefficients
515525

516526
## deal with data if supplied
@@ -614,7 +624,6 @@ eval_smooth.mod.smooth = function(smooth,
614624
data
615625
}
616626

617-
#' @importFrom tibble add_column
618627
#' @noRd
619628
`add_by_var_column` <- function(object, by_var, n = NULL) {
620629
if (is.null(n)) {

man/eval_smooth.Rd

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/mvgam.dll

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)