diff --git a/.gitignore b/.gitignore index e79957e..6dd1f42 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ - +.Rhistory +.RData sync.ffs_db *.ffs_db +.Rproj.user diff --git a/DESCRIPTION b/DESCRIPTION index ad8e332..b085f56 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,16 +1,22 @@ Package: tsutils Type: Package Title: Time Series Exploration, Modelling and Forecasting -Version: 0.9.2 +Version: 0.9.3 Authors@R: c( person("Nikolaos", "Kourentzes",, "nikolaos@kourentzes.com", c("aut", "cre")), person("Ivan", "Svetunkov",, "ivan@svetunkov.ru", c("ctb")), person("Oliver", "Schaer",, "info@oliverschaer.ch", c("ctb"))) Description: Includes: (i) tests and visualisations that can help the modeller explore time series components and perform decomposition; (ii) modelling shortcuts, such as functions to construct lagmatrices and seasonal dummy variables of various forms; (iii) an implementation of the Theta method; (iv) tools to facilitate the design of the forecasting process, such as ABC-XYZ analyses; and (v) "quality of life" functions, such as treating time series for trailing and leading values. -Imports: RColorBrewer, forecast, MAPA, plotrix +Imports: + RColorBrewer, + forecast, + MAPA, + plotrix, + generics Suggests: thief License: GPL-3 Encoding: UTF-8 LazyData: true URL: https://github.com/trnnick/tsutils/ -RoxygenNote: 6.1.1 +RoxygenNote: 7.1.2 +Roxygen: list(old_usage = TRUE) diff --git a/NAMESPACE b/NAMESPACE index a753f6a..37a984c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -39,7 +39,7 @@ importFrom(RColorBrewer,brewer.pal) importFrom(forecast,Arima) importFrom(forecast,ets) importFrom(forecast,forecast) -importFrom(forecast,forecast.ets) +importFrom(generics,forecast) importFrom(grDevices,colorRampPalette) importFrom(grDevices,gray) importFrom(grDevices,rainbow) diff --git a/NEWS.md b/NEWS.md index 676c768..870846f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# VERSION 0.9.2 (07 Mar 2022) +- Import forecast from generics + # VERSION 0.9.2 (06 Feb 2020) - Added functions Sthief and plotSthief. - Fixed class() check for abc.R, xyz.R and theta.R diff --git a/R/cmav.R b/R/cmav.R index 0119e85..a629610 100644 --- a/R/cmav.R +++ b/R/cmav.R @@ -20,6 +20,7 @@ #' @examples #' cmav(referrals,outplot=TRUE) #' +#' @importFrom forecast ets #' @export cmav cmav <- function(y,ma=NULL,fill=c(TRUE,FALSE),outplot=c(FALSE,TRUE),fast=c(TRUE,FALSE)){ @@ -68,20 +69,20 @@ cmav <- function(y,ma=NULL,fill=c(TRUE,FALSE),outplot=c(FALSE,TRUE),fast=c(TRUE, if (fill == TRUE){ if (fast == FALSE){ if ((n-mlbounds[2]) >= 1){ - cma[(mlbounds[2]+1):n] <- as.vector(forecast::forecast.ets(forecast::ets(cma[(mlbounds[1]:mlbounds[2])], - model="ZZN"),h=(n-mlbounds[2]))$mean) + cma[(mlbounds[2]+1):n] <- as.vector(forecast(ets(cma[(mlbounds[1]:mlbounds[2])], + model="ZZN"),h=(n-mlbounds[2]))$mean) } if ((mlbounds[1]-1) >= 1){ - cma[1:(mlbounds[1]-1)] <- rev(as.vector(forecast::forecast.ets(forecast::ets(rev(cma[(mlbounds[1]:mlbounds[2])]), - model="ZZN"),h=(mlbounds[1]-1))$mean)) + cma[1:(mlbounds[1]-1)] <- rev(as.vector(forecast(ets(rev(cma[(mlbounds[1]:mlbounds[2])]), + model="ZZN"),h=(mlbounds[1]-1))$mean)) } } else { - fit <- forecast::ets(cma[(mlbounds[1]:mlbounds[2])],model="AZN") + fit <- ets(cma[(mlbounds[1]:mlbounds[2])],model="AZN") if ((n-mlbounds[2]) >= 1){ - cma[(mlbounds[2]+1):n] <- as.vector(forecast::forecast.ets(fit,h=(n-mlbounds[2]))$mean) + cma[(mlbounds[2]+1):n] <- as.vector(forecast(fit,h=(n-mlbounds[2]))$mean) } if ((mlbounds[1]-1) >= 1){ - cma[1:(mlbounds[1]-1)] <- rev(as.vector(forecast::forecast.ets(forecast::ets(rev(cma[mlbounds[1]:mlbounds[2]]), + cma[1:(mlbounds[1]-1)] <- rev(as.vector(forecast(ets(rev(cma[mlbounds[1]:mlbounds[2]]), fit,use.initial.values=FALSE),h=(mlbounds[1]-1))$mean)) } } diff --git a/R/tsutils-package.R b/R/tsutils-package.R index 81b34b8..0f391c7 100644 --- a/R/tsutils-package.R +++ b/R/tsutils-package.R @@ -54,7 +54,8 @@ #' #' @importFrom graphics plot lines par points polygon axis image abline box text boxplot legend mtext #' @importFrom stats frequency friedman.test qtukey na.exclude sd ts pbinom median density quantile start cor.test deltat end optim time tsp -#' @importFrom forecast ets forecast.ets Arima forecast +#' @importFrom forecast ets Arima +#' @importFrom generics forecast #' @importFrom RColorBrewer brewer.pal #' @importFrom grDevices colorRampPalette gray rgb rainbow #' @importFrom utils tail head diff --git a/man/coxstuart.Rd b/man/coxstuart.Rd index 5c28812..c000da5 100644 --- a/man/coxstuart.Rd +++ b/man/coxstuart.Rd @@ -4,8 +4,7 @@ \alias{coxstuart} \title{Cox-Stuart test} \usage{ -coxstuart(y, type = c("trend", "deviation", "dispersion"), - alpha = 0.05) +coxstuart(y, type = c("trend", "deviation", "dispersion"), alpha = 0.05) } \arguments{ \item{y}{input data.} diff --git a/man/decomp.Rd b/man/decomp.Rd index 376c549..f29c642 100644 --- a/man/decomp.Rd +++ b/man/decomp.Rd @@ -4,9 +4,9 @@ \alias{decomp} \title{Classical time series decomposition} \usage{ -decomp(y, m = NULL, s = NULL, trend = NULL, outplot = c(FALSE, - TRUE), decomposition = c("multiplicative", "additive", "auto"), - h = 0, type = c("mean", "median", "pure.seasonal"), w = NULL) +decomp(y, m = NULL, s = NULL, trend = NULL, outplot = c(FALSE, TRUE), + decomposition = c("multiplicative", "additive", "auto"), h = 0, + type = c("mean", "median", "pure.seasonal"), w = NULL) } \arguments{ \item{y}{input time series. Can be \code{ts} object.} diff --git a/man/seasdummy.Rd b/man/seasdummy.Rd index dda0744..2ca8eef 100644 --- a/man/seasdummy.Rd +++ b/man/seasdummy.Rd @@ -4,8 +4,7 @@ \alias{seasdummy} \title{Create seasonal dummy variables.} \usage{ -seasdummy(n, m = NULL, y = NULL, type = c("bin", "trg"), - full = c(FALSE, TRUE)) +seasdummy(n, m = NULL, y = NULL, type = c("bin", "trg"), full = c(FALSE, TRUE)) } \arguments{ \item{n}{number of observations to create.} diff --git a/man/theta.Rd b/man/theta.Rd index c8df005..7c601b4 100644 --- a/man/theta.Rd +++ b/man/theta.Rd @@ -9,8 +9,8 @@ \usage{ theta(y, m = NULL, sign.level = 0.05, cost0 = c("MSE", "MdSE", "MAE", "MdAE"), cost2 = c("MSE", "MdSE", "MAE", "MdAE"), costs = c("MSE", - "MdSE", "MAE", "MdAE"), multiplicative = c("multiplicative", - "additive", "auto"), cma = NULL, outliers = NULL) + "MdSE", "MAE", "MdAE"), multiplicative = c("multiplicative", "additive", + "auto"), cma = NULL, outliers = NULL) \method{forecast}{theta}(object, h = NULL, ...) diff --git a/man/tsutils.Rd b/man/tsutils.Rd index ecbb58e..565bb3f 100644 --- a/man/tsutils.Rd +++ b/man/tsutils.Rd @@ -3,7 +3,6 @@ \docType{package} \name{tsutils} \alias{tsutils} -\alias{tsutils-package} \title{tsutils: Time Series Exploration, Modelling and Forecasting} \description{ The \pkg{tsutils} package provides functions to support various aspects of time series and forecasting modelling. In particular this package includes: (i) tests and visualisations that can help the modeller explore time series components and perform decomposition; (ii) modelling shortcuts, such as functions to construct lagmatrices and seasonal dummy variables of various forms; (iii) an implementation of the Theta method; (iv) tools to facilitate the design of the forecasting process, such as ABC-XYZ analyses; and (v) "quality of life" tools, such as treating time series for trailing and leading values. diff --git a/man/xyz.Rd b/man/xyz.Rd index ed4354f..0df7510 100644 --- a/man/xyz.Rd +++ b/man/xyz.Rd @@ -4,8 +4,7 @@ \alias{xyz} \title{XYZ analysis} \usage{ -xyz(x, m = NULL, prc = c(0.2, 0.3, 0.5), type = c("naive", "ets", - "cv")) +xyz(x, m = NULL, prc = c(0.2, 0.3, 0.5), type = c("naive", "ets", "cv")) } \arguments{ \item{x}{this can either be an array, where each column is a series, or a vector of values. If \code{x} is a vector of values forecastability is not calculated and the input is used as such.}