Helpers
Helper function to find tb from Phillips and Shi (2020)
ps_tb ps_tb(n, freq = c("monthly", "quarterly", "annual", "weekly"), size = 2) This function finds the number of observations in the window over which size is to be controlled.
Arguments
| n | A positive integer. The sample size. |
| freq | The type of date-interval. |
| size | The size to be controlled. |
Value
A single integer, the length of the training window in observations, suitable for the r_star argument of monitor.
Examples
These examples are copied from the package's own documentation and are run by R CMD check on every release.
The printed output (after #>) and the plots were produced by running them against the current package source.
# Training window that controls size over a 2-year span of monthly data
tb <- ps_tb(100, freq = "monthly", size = 2)
tb
#> [1] 42
# Use it directly as the training window of monitor()
monitor(sim_data, r_star = tb, boundary = "kurozumi")
#>
#> ── monitor (T* = 42 / 100, minw = 19, sig_lvl = 95%, boundary = kurozumi) ──────
#>
#> series boundary alarm alarm_date
#> psy1 1.038 50 50
#> psy2 1.038 NA <NA>
#> evans 1.038 NA <NA>
#> div 1.038 NA <NA>
#> blan 1.038 NA <NA> References
Phillips, P. C., & Shi, S. (2020). Real time monitoring of asset markets: Bubbles and crises. In Handbook of Statistics (Vol. 42, pp. 61-80). Elsevier.
Shi, S., Hurn, S., Phillips, P.C.B., 2018. Causal change detection in possibly integrated systems: Revisiting the money-income relationship.
exuber