diff --git a/DESCRIPTION b/DESCRIPTION index 747fc27..e622ea6 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -47,6 +47,7 @@ Depends: ggplot2 Imports: stats, + utils, methods, tidyr, proxy diff --git a/NAMESPACE b/NAMESPACE index d553015..f839554 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -12,7 +12,9 @@ importFrom(methods,as) importFrom(proxy,dist) importFrom(stats,model.frame) importFrom(stats,predict) +importFrom(stats,resid) importFrom(tidyr,nest) importFrom(tidyr,pivot_longer) importFrom(tidyr,pivot_wider) importFrom(tidyr,unnest) +importFrom(utils,methods) diff --git a/R/train.R b/R/train.R index ac05e09..ba416af 100644 --- a/R/train.R +++ b/R/train.R @@ -247,11 +247,14 @@ print.twdtw_knn1 <- function(x, ...) { print(x$call) # Printing the smooth_fun, if available - cat("\nAdjusted R-squared of smooth models:\n") + cat("\nRoot Mean Squared Error (RMSE) of smooth models:\n") if(is.null(x$smooth_models)){ print(NULL) } else { - print(sapply(x$smooth_models, function(m1) sapply(m1, function(m2) summary(m2)$adj.r.squared))) + print(sapply(x$smooth_models, function(m1) sapply(m1, function(m2){ + residuals <- try(resid(m2)) + ifelse(is.numeric(residuals), sqrt(mean(residuals^2)), NA) + }))) } # Printing the data summary diff --git a/R/zzz.R b/R/zzz.R index c3f862d..36f72cb 100644 --- a/R/zzz.R +++ b/R/zzz.R @@ -2,8 +2,9 @@ #' @import sf #' @import stars #' @import ggplot2 -#' @importFrom stats predict model.frame +#' @importFrom stats predict model.frame resid #' @importFrom methods as +#' @importFrom utils methods #' @importFrom tidyr pivot_longer pivot_wider nest unnest #' @importFrom proxy dist #'