model_error_wave: Error Prediction Wavelet Models

model_error_waveR Documentation

Error Prediction Wavelet Models

Description

model_error_wave estimates the prediction error of models fitted by the function model_est when the x variable is a wavelet-based signal estimation of y. For each new observation k included in the out-of-sample set, the wavelet-based signal is reestimated. This function supports several specifications of wavelet models being a generalization of model_error_wave_single.

Usage

model_error_wave(x, y, h, lags, k, RMSE = TRUE)

Arguments

x

An object of class args_wshr, args_ebthr or args_wthr.

y

A numeric vector or a time series for wavelet-based signal estimation. Headline inflation for estimation of a wavelet core inflation measure.

h

An integer to set the desired horizon.

lags

A data frame generated by the function lags.

k

An integer to determine the number of observations to include in the out-of-sample set.

RMSE

logical: if TRUE returns RMSE, if FALSE returns MAE.

Value

A vector of errors for every wavelet model considered.

See Also

wav_smooth, model_est, model_best, model_fcast

Examples

wthr_wd <- list(
  filter.number = 4,
  type = c("wavelet", "station")
)

wthr_thr <- list(
  type = c("soft", "hard"),
  policy = c(
    "universal",
    "BayesThresh"
  )
)

wthr_args <- wav_args_wthr(wthr_wd, wthr_thr, 4:5)

h <- 1:3
names(h) <- paste0("h", h)

pq <- lags(2, 1)

inf_head <- coreinf_br[["ipca"]]

# h = 2

model_error_wave(wthr_args, inf_head, h = 2, pq, 12, RMSE = TRUE)

# h = 1:3 (mean of the errors for each wavelet model estimated)
## Not run: 

pred_wthr <- purrr::map_df(
  h,
  ~ model_error_wave(wthr_args, inf_head, .x, pq, 12, RMSE = TRUE)
) %>%
  dplyr::mutate(pred = purrr::possibly(rowMeans, NA)(.)) %>%
  dplyr::select(pred)

pred_wthr

## End(Not run)


nelson16silva/wavcoreinf documentation built on Feb. 17, 2025, 7:10 p.m.