Fits a Bayesian time-varying regression on a 'tidyFit' R6 class. The function can be used with regress.

# S3 method for class 'tvp'
.fit(self, data = NULL)

Arguments

self

a 'tidyFit' R6 class.

data

a data frame, data frame extension (e.g. a tibble), or a lazy data frame (e.g. from dbplyr or dtplyr).

Value

A fitted 'tidyFit' class model.

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

Author

Johann Pfitzinger

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 = 10, 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.678   1.29    0.00779        0.628 196307
#>  2 tvp   (Intercept)   0.742   1.48    0.180          0.606 196308
#>  3 tvp   (Intercept)   1.00    1.36    0.728          0.307 196309
#>  4 tvp   (Intercept)   1.43    1.81    1.07           0.334 196310
#>  5 tvp   (Intercept)   0.849   1.56    0.369          0.537 196311
#>  6 tvp   (Intercept)   0.398   1.22   -0.308          0.662 196312
#>  7 tvp   (Intercept)  -0.0740  0.768  -0.653          0.637 196401
#>  8 tvp   (Intercept)  -0.0771  0.295  -0.484          0.336 196402
#>  9 tvp   (Intercept)  -0.267   0.254  -0.834          0.493 196403
#> 10 tvp   (Intercept)  -0.766  -0.0158 -1.51           0.702 196404
#> # ℹ 4,946 more rows