prior_alpha_beta | R Documentation |
The function prior_alpha_beta
determines both the parameters
alpha
and beta
that are used
in bayesian wavelet thresholding
of noisy data. Estimation is based on
minimizing the avarage of forecast error.
prior_alpha_beta(
x,
h,
k,
lags,
par = c(0.5, 1),
lower = c(0, 0),
upper = c(3, 3),
control = list(),
wtfunlist = list(),
...
)
x |
A vector or a time series containing the data (headline inflation). |
h |
An integer to set the desired horizon. |
k |
An integer to determine the number of observations to include in the out-of-sample set. |
lags |
A data frame generated by the function |
par |
Initial values for the parameters to be optimized over. |
lower |
Bounds on the variables for the "L-BFGS-B" method. See |
upper |
Bounds on the variables for the "L-BFGS-B" method. See |
control |
A list of control parameters. See |
wtfunlist |
A named list of parameters to pass to function |
... |
Additional parameters to pass to function |
A numeric vector of length two.
# Example 1
pq <- lags(1, 1)
ipca <- coreinf_br$ipca
prior_alpha_beta(
x = ipca, h = 2, k = 5, lags = pq,
lower = c(0.2, 0.5),
wtfunlist = list(type = "wavelet"),
type = "hard"
)
# Example 2
## Not run:
# Including the best priors for denoising
wthr_wd <- list(
filter.number = 1,
family = c("DaubExPhase"),
type = c("wavelet", "station")
)
# Note: initial alpha and beta must be included such
# that the appropriate structure of wthr_args is maitained
# after the inclusion of estimated priors
wthr_thr <- list(
type = c("soft"),
alpha = 0.5,
beta = 1
)
wthr_args <- wav_args_wthr(wthr_wd, wthr_thr, 3)
# Best priors estimation and inclusion in wthr_args
args_tbl2 <- wthr_args$args_tbl %>%
dplyr::mutate(ab = purrr::pmap(., ~purrr::possibly(prior_alpha_beta, NA)(
ipca, 2, 4, pq,
lower = c(0.4, 0.6), upper = c(0.6, 1.1),
control = list(reltol = 0.01),
wtfunlist = list(..1, ..2, ..3),
type = ..4, lr = ..7)),
alpha = purrr::map_dbl(ab, ~`[`(.x, 1)),
beta = purrr::map_dbl(ab, ~`[`(.x, 2))) %>%
dplyr::select(-ab)
wthr_args[[1]] <- args_tbl2
# Denoising after including estimated priors
wav_smooth(ipca, wthr_args)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.