Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ License: GPL-3
URL: http://feasts.tidyverts.org/, https://github.com/tidyverts/feasts/
BugReports: https://github.com/tidyverts/feasts/issues
Encoding: UTF-8
RoxygenNote: 7.3.2.9000
RoxygenNote: 7.3.3
Roxygen: list(markdown = TRUE, roclets=c('rd', 'collate', 'namespace'))
Language: en-GB
RdMacros: lifecycle
10 changes: 5 additions & 5 deletions R/features.R
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ feat_stl <- function(x, .period, s.window = 11, ...){
#' @rdname unitroot
#' @export
unitroot_kpss <- function(x, type = c("mu", "tau"), lags = c("short", "long", "nil"), ...) {
require_package("urca")
check_installed("urca")
result <- urca::ur.kpss(x, type = type, lags = lags, ...)
pval <- stats::approx(result@cval[1,], as.numeric(sub("pct", "", colnames(result@cval)))/100, xout=result@teststat[1], rule=2)$y
c(kpss_stat = result@teststat, kpss_pvalue = pval)
Expand All @@ -151,7 +151,7 @@ unitroot_kpss <- function(x, type = c("mu", "tau"), lags = c("short", "long", "n
#' @export
unitroot_pp <- function(x, type = c("Z-tau", "Z-alpha"), model = c("constant", "trend"),
lags = c("short", "long"), ...) {
require_package("urca")
check_installed("urca")
result <- urca::ur.pp(x, type = match.arg(type), model = match.arg(model),
lags = match.arg(lags), ...)
pval <- stats::approx(result@cval[1,], as.numeric(sub("pct", "", colnames(result@cval)))/100, xout=result@teststat[1], rule=2)$y
Expand Down Expand Up @@ -247,7 +247,7 @@ unitroot_nsdiffs <- function(x, alpha = 0.05, unitroot_fn = ~ feat_stl(.,.period
#'
#' @export
cointegration_johansen <- function(x, ...) {
require_package("urca")
check_installed("urca")
result <- urca::ca.jo(x, ...)

pct <- as.numeric(sub("pct", "", colnames(result@cval)))/100
Expand All @@ -273,7 +273,7 @@ cointegration_johansen <- function(x, ...) {
#'
#' @export
cointegration_phillips_ouliaris <- function(x, ...) {
require_package("urca")
check_installed("urca")
result <- urca::ca.po(x, ...)
pval <- stats::approx(result@cval[1,], as.numeric(sub("pct", "", colnames(result@cval)))/100, xout=result@teststat[1], rule=2)$y
c(phillips_ouliaris_stat = result@teststat, phillips_ouliaris_pvalue = pval)
Expand Down Expand Up @@ -315,7 +315,7 @@ n_flat_spots <- function(x) {
#'
#' @export
coef_hurst <- function(x) {
require_package("fracdiff")
check_installed("fracdiff")
# Hurst=d+0.5 where d is fractional difference.
return(c(coef_hurst = suppressWarnings(fracdiff::fracdiff(na.contiguous(x), 0, 0)[["d"]] + 0.5)))
}
Expand Down
8 changes: 3 additions & 5 deletions R/graphics.R
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ gg_season <- function(data, y = NULL, period = NULL, facet_period = NULL,

if(labels != "none"){
labeller <- if(labels_repel) {
require_package("ggrepel")
check_installed("ggrepel")
function(...) ggrepel::geom_text_repel(..., direction = "y", segment.colour = NA)
} else {
ggplot2::geom_text
Expand Down Expand Up @@ -652,7 +652,7 @@ gg_tsdisplay <- function(data, y = NULL, plot_type = c("auto", "partial", "seaso
if(n_keys(data) > 1){
abort("The data provided to contains more than one time series. Please filter a single time series to use `gg_tsdisplay()`")
}
require_package("grid")
check_installed("grid")

y <- guess_plot_var(data, !!enquo(y))

Expand Down Expand Up @@ -744,14 +744,12 @@ gg_tsdisplay <- function(data, y = NULL, plot_type = c("auto", "partial", "seaso
#' and practice}, 3rd edition, OTexts: Melbourne, Australia.
#' \url{https://OTexts.com/fpp3/}
#'
#' @examples
#' if (requireNamespace("fable", quietly = TRUE)) {
#' @examplesIf rlang::is_installed("fable")
#' library(fable)
#'
#' tsibbledata::aus_production %>%
#' model(ETS(Beer)) %>%
#' gg_tsresiduals()
#' }
#'
#' @importFrom ggplot2 ggplot aes geom_point geom_histogram ylim
#' @importFrom stats na.exclude complete.cases
Expand Down
2 changes: 1 addition & 1 deletion R/seats.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ specials_seats <- fabletools::new_specials(
)

train_seats <- function(.data, formula, specials, x11, x11.mode, ...){
require_package("seasonal")
check_installed("seasonal")
stopifnot(is_tsibble(.data))

if(!missing(x11) || !missing(x11.mode)){
Expand Down
8 changes: 0 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,6 @@ add_class <- function(x, new_class){
if (is.null(x)) y else x
}

require_package <- function(pkg){
if(!requireNamespace(pkg, quietly = TRUE)){
abort(
sprintf('The `%s` package must be installed to use this functionality. It can be installed with install.packages("%s")', pkg, pkg)
)
}
}

`%empty%` <- function(x, y) {
if (length(x) == 0) y else x
}
Expand Down
2 changes: 1 addition & 1 deletion R/x11.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ specials_X11 <- fabletools::new_specials(
)

train_X11 <- function(.data, formula, specials, type, ...){
require_package("seasonal")
check_installed("seasonal")
stopifnot(is_tsibble(.data))

if(length(specials$season) != 1){
Expand Down
2 changes: 1 addition & 1 deletion R/x13arimaseats.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ specials_x13arimaseats <- fabletools::new_specials(

train_x13arimaseats <- function(.data, formula, specials, ...,
defaults, na.action = seasonal::na.x13){
require_package("seasonal")
check_installed("seasonal")
stopifnot(is_tsibble(.data))
series_name <- measured_vars(.data)

Expand Down
5 changes: 2 additions & 3 deletions man/gg_tsresiduals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.