-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Dear community / @robjhyndman / @mitchelloharawild
I am attempting to perform seasonal adjustments on a grouped tsibble dataset using X13_ARIMA_SEATS. However, all went well until I attempted to extract the components from the mable.
This error does not occur when I attempt decomposition using STL or X11
The error also does not occur when I filter the mable to extract only a single row.
May I ask if anyone in the community is aware of a remedy to this issue?
Thanks much!
SCRIPT BELOW
#Global Functions#
singstat_to_tsibble_qtrly <- function(x) {x[["Data"]][["row"]] %>%
tidyr::unnest(cols = columns) %>%
dplyr::rename(Date = key) %>%
dplyr::rename(GroupId = rowText) %>%
dplyr::mutate(Date = tsibble::yearquarter(Date)) %>%
dplyr::mutate(value = as.numeric(value)) %>%
tsibble::tsibble(index = Date, key = GroupId, regular = TRUE) %>%
tsibble::group_by_key() %>%
dplyr::select(!c(seriesNo, uoM, footnote))}
#Crawl Data from Singstat#
VApW_Qtr_nonSA_set1_current_TS <- jsonlite::fromJSON("https://tablebuilder.singstat.gov.sg/api/table/tabledata/M015801?limit=2000") %>% singstat_to_tsibble_qtrly()
VApW_Qtr_nonSA_set2_current_TS <- jsonlite::fromJSON("https://tablebuilder.singstat.gov.sg/api/table/tabledata/M015801?offset=2000&limit=2000") %>% singstat_to_tsibble_qtrly()
#Combine dataset into 1 tsibble#
VApW_Qtr_nonSA_current_TS <- dplyr::full_join(VApW_Qtr_nonSA_set1_current_TS, VApW_Qtr_nonSA_set2_current_TS) %>%
dplyr::mutate(IndicatorType = "Performance",
uoM = "Value-added Per Worker",
Terms = "Nominal",
AdjStatus = "nonSA",
AdjMethod = "O")
#fit X13_ARIMA_SEATS model#
fit <- VApW_Qtr_nonSA_current_TS %>%
fabletools::model(X13 = feasts::X_13ARIMA_SEATS(value ~ seats(),
na.action = seasonal::na.x13,
defaults = "seasonal"))
#Extract Components#
fit %>% components()
Error occurs when I attempt to extract components from the X13_ARIMA_SEATS model.
rlang::last_trace()
<error/dplyr:::mutate_error>
Error intransmute():
ℹ In argument:cmp = map(.fit, components).
Caused by error inmutate():
ℹ In argument:seasonal = dcmp[, "adjustfac"].
Caused by error indcmp[, "adjustfac"]:
! subscript out of bounds
Backtrace:
▆
- ├─VApW_Qtr_SA_current_TS_test %>% components()
- ├─generics::components(.)
- ├─fabletools:::components.mdl_df(.)
- │ ├─dplyr::transmute(...)
- │ └─dplyr:::transmute.data.frame(...)
- │ └─dplyr:::mutate_cols(.data, dots, by)
- │ ├─base::withCallingHandlers(...)
- │ └─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)
- │ └─mask$eval_all_mutate(quo)
- │ └─dplyr (local) eval()
- ├─fabletools:::map(.fit, components)
- │ └─base::lapply(.x, .f, ...)
- │ ├─generics (local) FUN(X[[i]], ...)
- │ └─fabletools:::components.mdl_ts(X[[i]], ...)
- │ ├─generics::components(object$fit, ...)
- │ └─feasts:::components.feasts_x13arimaseats(object$fit, ...)
- │ └─.data %>% ...
- ├─dplyr::mutate(...)
- └─dplyr:::mutate.data.frame(...)
- └─dplyr:::mutate_cols(.data, dplyr_quosures(...), by)
├─base::withCallingHandlers(...)└─dplyr:::mutate_col(dots[[i]], data, mask, new_columns)└─mask$eval_all_mutate(quo)└─dplyr (local) eval()