Fits a Bayesian time-varying regression on a 'tidyFit' R6
class. The function can be used with regress
.
Details
Hyperparameters:
None. Cross validation not applicable.
Important method arguments (passed to m
)
mod_type
niter
(number of MCMC iterations)
The function provides a wrapper for shrinkTVP::shrinkTVP
. See ?shrinkTVP
for more details.
Implementation
An argument index_col
can be passed, which allows a custom index to be added to coef(m("tvp"))
(e.g. a date index, see Examples).
References
Peter Knaus, Angela Bitto-Nemling, Annalisa Cadonna and Sylvia Frühwirth-Schnatter (2021).
Shrinkage in the Time-Varying Parameter Model Framework Using the R Package shrinkTVP.
Journal of Statistical Software 100(13), 1–32.
doi:10.18637/jss.v100.i13
.
See also
.fit.bayes
, .fit.mslm
and m
methods
Examples
# Load data
data <- tidyfit::Factor_Industry_Returns
data <- dplyr::filter(data, Industry == "HiTec")
data <- dplyr::select(data, -Industry)
# Within 'regress' function (using low niter for illustration)
fit <- regress(data, Return ~ ., m("tvp", niter = 50, index_col = "Date"))
tidyr::unnest(coef(fit), model_info)
#> # A tibble: 4,956 × 7
#> # Groups: model [1]
#> model term estimate upper lower posterior.sd index
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 tvp (Intercept) 0.617 0.930 0.280 0.249 196307
#> 2 tvp (Intercept) 0.621 0.915 0.270 0.253 196308
#> 3 tvp (Intercept) 0.627 0.927 0.286 0.246 196309
#> 4 tvp (Intercept) 0.630 0.890 0.245 0.245 196310
#> 5 tvp (Intercept) 0.618 0.898 0.190 0.258 196311
#> 6 tvp (Intercept) 0.629 0.905 0.206 0.241 196312
#> 7 tvp (Intercept) 0.651 0.932 0.300 0.240 196401
#> 8 tvp (Intercept) 0.653 0.933 0.281 0.242 196402
#> 9 tvp (Intercept) 0.642 0.937 0.301 0.250 196403
#> 10 tvp (Intercept) 0.645 0.913 0.207 0.258 196404
#> # ℹ 4,946 more rows