From 9ac23cb8646c79cd923aae44c06d1f78a85d1ced Mon Sep 17 00:00:00 2001 From: Feng Li Date: Sun, 7 Apr 2024 19:02:07 +0800 Subject: [PATCH] Fixed CRAN dependencies --- DESCRIPTION | 90 ++++++++++++++++++++++------------------ NAMESPACE | 2 + R/arima_model.R | 4 +- R/gratis-package.R | 5 +-- R/mar_model.R | 2 +- R/rmixmorm.R | 6 +-- inst/CITATION | 2 +- man/gratis-package.Rd | 2 +- man/mar_model.Rd | 2 + man/rmixnorm_ts.Rd | 2 + vignettes/QuickStart.Rmd | 7 ++-- 11 files changed, 69 insertions(+), 55 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 1524d17..a3033ae 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,49 +1,57 @@ -Package: gratis Type: Package -Title: Generating Time Series with Diverse and Controllable Characteristics +Package: gratis +Title: Generating Time Series with Diverse and Controllable + Characteristics Version: 1.0.5 Authors@R: c( - person("Yanfei", "Kang", role = c("aut"), email = "yanfeikang@buaa.edu.cn", comment = c(ORCID = "0000-0001-8769-6650")), - person("Feng", "Li", role = c("aut", "cre"), email = "feng.li@cufe.edu.cn", comment = c(ORCID = "0000-0002-4248-9778")), - person("Rob", "Hyndman", role = c("aut"), email = "rob.hyndman@monash.edu", comment = c(ORCID = "0000-0002-2140-5352")), - person("Mitchell", "O'Hara-Wild", role = "ctb", email = "mail@mitchelloharawild.com", comment = c(ORCID = "0000-0001-6729-7695")), - person("Bocong", "Zhao", role = "ctb", email = "bocongzhao@163.com", comment = c(ORCID = "0000-0001-8434-9047")) - ) -Description: - Generates synthetic time series based on various univariate time series models - including MAR and ARIMA processes. Kang, Y., Hyndman, R.J., Li, F.(2020) . -LazyLoad: yes -Repository: CRAN + person("Yanfei", "Kang", , "yanfeikang@buaa.edu.cn", role = "aut", + comment = c(ORCID = "0000-0001-8769-6650")), + person("Feng", "Li", , "feng.li@cufe.edu.cn", role = c("aut", "cre"), + comment = c(ORCID = "0000-0002-4248-9778")), + person("Rob", "Hyndman", , "rob.hyndman@monash.edu", role = "aut", + comment = c(ORCID = "0000-0002-2140-5352")), + person("Mitchell", "O'Hara-Wild", , "mail@mitchelloharawild.com", role = "ctb", + comment = c(ORCID = "0000-0001-6729-7695")), + person("Bocong", "Zhao", , "bocongzhao@163.com", role = "ctb", + comment = c(ORCID = "0000-0001-8434-9047")) + ) +Description: Generates synthetic time series based on various univariate + time series models including MAR and ARIMA processes. Kang, Y., + Hyndman, R.J., Li, F.(2020) . +License: GPL-3 URL: https://github.com/ykang/gratis BugReports: https://github.com/ykang/gratis/issues/ -Depends: R (>= 3.5.0) +Depends: + R (>= 3.5.0) Imports: - doRNG, - dplyr, - foreach, - forecast (>= 8.16), - GA, - generics, - magrittr, - methods, - mvtnorm, - polynom, - purrr, - stats, - tibble, - tsfeatures, - tsibble, - utils, - shiny + doRNG, + dplyr, + feasts, + fGarch, + foreach, + forecast (>= 8.16), + GA, + generics, + magrittr, + methods, + mvtnorm, + polynom, + purrr, + shiny, + stats, + tibble, + tsfeatures, + tsibble, + utils Suggests: - feasts, - fGarch, - knitr, - rmarkdown, - rlang, - shinydashboard -NeedsCompilation: no -License: GPL-3 + knitr, + rlang, + rmarkdown, + shinydashboard +VignetteBuilder: + knitr Encoding: UTF-8 -RoxygenNote: 7.2.3 -VignetteBuilder: knitr +LazyLoad: yes +NeedsCompilation: no +Repository: CRAN +RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index e50d5f3..d6252e3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -18,6 +18,8 @@ export(pi_coefficients) export(rmixnorm) export(rmixnorm_ts) export(simulate_target) +import(fGarch) +import(feasts) import(shiny) importFrom(GA,ga) importFrom(GA,gaControl) diff --git a/R/arima_model.R b/R/arima_model.R index 95b3a31..c60f242 100644 --- a/R/arima_model.R +++ b/R/arima_model.R @@ -220,11 +220,11 @@ pi_coefficients <- function(ar = 0, d = 0L, ma = 0, sar = 0, D = 0L, sma = 0, m } n <- 500L - theta <- -c(coef(ma * sma))[-1] + theta <- -c(stats::coef(ma * sma))[-1] if (length(theta) == 0L) { theta <- 0 } - phi <- -c(coef(ar * sar)[-1], numeric(n)) + phi <- -c(stats::coef(ar * sar)[-1], numeric(n)) q <- length(theta) pie <- c(numeric(q), 1, numeric(n)) for (j in seq(n)) { diff --git a/R/gratis-package.R b/R/gratis-package.R index 2ba996c..52f860e 100644 --- a/R/gratis-package.R +++ b/R/gratis-package.R @@ -23,12 +23,11 @@ #' @importFrom GA startParallel garun #' @importFrom tsfeatures tsfeatures #' @importFrom doRNG "%dorng%" +#' @import fGarch #' @import shiny +#' @import feasts #' @keywords internal "_PACKAGE" NULL - -# utils::globalVariables(c(".", "x", "Season2")) -# magrittr::`%>%` diff --git a/R/mar_model.R b/R/mar_model.R index 487f82d..ac39458 100644 --- a/R/mar_model.R +++ b/R/mar_model.R @@ -41,7 +41,7 @@ #' \code{phi}, \code{Phi}, \code{sigmas} and \code{weights}. #' @author Rob J Hyndman #' @seealso \code{\link{simulate.mar}} -#' @examples +#' @examplesIf require("fGarch", quietly=TRUE) #' n <- 100 #' # Quarterly MAR model with randomly selected parameters #' model1 <- mar_model(seasonal_periods = 4) diff --git a/R/rmixmorm.R b/R/rmixmorm.R index 2412eb9..ace3762 100644 --- a/R/rmixmorm.R +++ b/R/rmixmorm.R @@ -39,8 +39,8 @@ rmixnorm <- function(n, means, sigmas, weights) { for (i in seq(k)) { if (nsamp[i] > 0) { data[idx == i, ] <- mvtnorm::rmvnorm( - n = nsamp[i], mean = means[, i], - sigma = as.matrix(sigmas[, , i]), + n = nsamp[i], mean = means[, i], + sigma = as.matrix(sigmas[, , i]), checkSymmetry = FALSE ) } @@ -113,7 +113,7 @@ dmixnorm <- function(x, means, sigmas, weights, log = FALSE) { #' Conditional Distributions using Smooth Mixtures of Asymmetric Student T Densities, #' Journal of Statistical Planning and Inference, 140(12), pp. 3638-3654. #' @author Feng Li, Central University of Finance and Economics. -#' @examples +#' @examplesIf require("fGarch", quietly=TRUE) #' n <- 1000 #' means.ar.par.list <- list(c(0, 0.8), c(0, 0.6, 0.3)) #' require("fGarch") diff --git a/inst/CITATION b/inst/CITATION index 04e098d..d375636 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -9,7 +9,7 @@ vers <- paste("R package version", vers) citHeader("To cite the gratis package in publications, please use:") bibentry(bibtype = "Manual", - title = "{gratis}: {GeneRAting TIme Series} with diverse and controllable characteristics", + title = "{gratis}: An R package for {GeneRAting TIme Series} with diverse and controllable characteristics", author = c(as.person("Yanfei Kang"), as.person("Feng Li"), as.person("Rob J Hyndman"), diff --git a/man/gratis-package.Rd b/man/gratis-package.Rd index 5f05a9c..9152cae 100644 --- a/man/gratis-package.Rd +++ b/man/gratis-package.Rd @@ -2,8 +2,8 @@ % Please edit documentation in R/gratis-package.R \docType{package} \name{gratis-package} +\alias{gratis} \alias{gratis-package} -\alias{_PACKAGE} \title{gratis: GeneRAting TIme Series with diverse and controllable characteristics} \description{ The gratis package generates synthetic time series data based on various diff --git a/man/mar_model.Rd b/man/mar_model.Rd index 60da360..19f00f5 100644 --- a/man/mar_model.Rd +++ b/man/mar_model.Rd @@ -74,6 +74,7 @@ The sigmas are uniformly sampled on (1,5) and the weights are uniformly sampled The number of components is uniformly sampled on \{1,2,3,4,5\}. } \examples{ +\dontshow{if (require("fGarch", quietly=TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} n <- 100 # Quarterly MAR model with randomly selected parameters model1 <- mar_model(seasonal_periods = 4) @@ -93,6 +94,7 @@ sigmas.spec <- list( fGarch::garchSpec(model = list(alpha = c(0.05, 0.05))) ) model4 <- mar_model(phi = phi, sigmas = sigmas.spec, weights = weights) +\dontshow{\}) # examplesIf} } \seealso{ \code{\link{simulate.mar}} diff --git a/man/rmixnorm_ts.Rd b/man/rmixnorm_ts.Rd index f113282..def6369 100644 --- a/man/rmixnorm_ts.Rd +++ b/man/rmixnorm_ts.Rd @@ -25,6 +25,7 @@ This function simulates random samples from a finite mixture of Gaussian distrib where the mean from each components are AR(p) process. } \examples{ +\dontshow{if (require("fGarch", quietly=TRUE)) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} n <- 1000 means.ar.par.list <- list(c(0, 0.8), c(0, 0.6, 0.3)) require("fGarch") @@ -42,6 +43,7 @@ y <- rmixnorm_ts( weights = weights ) plot(y) +\dontshow{\}) # examplesIf} } \references{ Feng Li, Mattias Villani, and Robert Kohn. (2010). Flexible Modeling of diff --git a/vignettes/QuickStart.Rmd b/vignettes/QuickStart.Rmd index e8ce60c..f76aba8 100644 --- a/vignettes/QuickStart.Rmd +++ b/vignettes/QuickStart.Rmd @@ -5,6 +5,7 @@ output: rmarkdown::html_vignette vignette: > %\VignetteIndexEntry{Introduction to gratis} %\VignetteEngine{knitr::rmarkdown} + %\VignetteDepends{feasts} %\VignetteEncoding{UTF-8} --- @@ -62,11 +63,11 @@ qmar %>% autoplot(value) ``` -Each of these series comes from the same MAR model, but with different stochastic inputs. Although the two ARIMA models are seasonal, the seasonality is too weak to been in the plots. +Each of these series comes from the same MAR model but with different stochastic inputs. Although the two ARIMA models are seasonal, the seasonality is too weak to been in the plots. -# Generate mutiple seasonal time series +# Generate multiple seasonal time series -Time series can exhibit multiple seasonal pattern of different length, especially when series observed at a high frequency such as daily or hourly data. Here is an example in which we generate 1 hourly time series of length 2 weeks. +Time series can exhibit multiple seasonal patterns of different lengths, especially when series are observed at a high frequency such as daily or hourly data. Here is an example in which we generate 1 hourly time series of length 2 weeks. ```{r hmarmodel} hmar <- mar_model(seasonal_periods = c(24, 7*24))