From db1546e396e132b071f056bd50a733c52eccf068 Mon Sep 17 00:00:00 2001 From: Ivan Svetunkov Date: Tue, 2 May 2023 18:09:17 +0100 Subject: [PATCH] Fixes for smoothType and modelLags. Related to issue #204 --- R/adam.R | 6 ------ R/methods.R | 17 +++++------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/R/adam.R b/R/adam.R index 47ba7df9..0eafa9ee 100644 --- a/R/adam.R +++ b/R/adam.R @@ -10225,12 +10225,6 @@ errorType.adam <- function(object, ...){ } } -# This is an internal function, no need to export it -# modelLags <- function(object, ...) UseMethod("modelLags") -modelLags.adam <- function(object, ...){ - return(object$lagsAll); -} - #' @export orders.adam <- function(object, ...){ return(object$orders); diff --git a/R/methods.R b/R/methods.R index d20df3ac..3894faf8 100644 --- a/R/methods.R +++ b/R/methods.R @@ -74,10 +74,6 @@ modelName <- function(object, ...) UseMethod("modelName") #' @export modelType modelType <- function(object, ...) UseMethod("modelType") -modelLags <- function(object, ...) UseMethod("modelLags") - -smoothType <- function(object, ...) UseMethod("smoothType") - ##### Likelihood function and stuff ##### #' @importFrom greybox AICc @@ -987,11 +983,14 @@ errorType.smooth <- function(object, ...){ errorType.smooth.sim <- errorType.smooth; ##### Function returns the modelLags from the model - internal function ##### -modelLags.default <- function(object, ...){ +modelLags <- function(object, ...){ modelLags <- NA; if(is.msarima(object)){ modelLags <- object$modelLags; } + else if(is.adam(object)){ + modelLags <- object$lagsAll; + } else{ smoothType <- smoothType(object); if(smoothType=="ETS"){ @@ -2613,11 +2612,7 @@ simulate.smooth <- function(object, nsim=1, seed=NULL, obs=NULL, ...){ } #### Type of smooth model. Internal function #### -smoothType.default <- function(object, ...){ - return(NA); -} - -smoothType.smooth <- function(object, ...){ +smoothType <- function(object, ...){ if(!is.list(object$model)){ if(gregexpr("ETS",object$model)!=-1){ smoothType <- "ETS"; @@ -2651,8 +2646,6 @@ smoothType.smooth <- function(object, ...){ return(smoothType); } -smoothType.smooth.sim <- smoothType.smooth; - #### Summary of objects #### #' @export summary.smooth <- function(object, ...){