business-science/sweep

sw_tidy fails when coefs return numeric(0)

mdancho84 opened this issue · 0 comments

The sw_tidy() function fails when no model coefficients are present (i.e. calling coef on Arima model returns nothing).

library(tidyquant)
library(timekit)
library(forecast)
library(sweep)

# Get data for Arizona
az <- tq_get("AZNGSP", get = "economic.data", from = "2007-01-01", to = "2017-06-01")

# model
fit <- az %>%
    tk_ts(freq = 1, start = 2017, silent = TRUE) %>%  # Convert to ts
    auto.arima()  # Model

# Attempt tidy - Fails because coef() returns numeric(0) when no terms present
sw_tidy(fit)
#> Error: Column `term` must be a 1d atomic vector or a list