Skip to content

Commit

Permalink
Merge pull request #10 from IDSIA/vignette_IJF
Browse files Browse the repository at this point in the history
Vignette ijf
  • Loading branch information
nicorbtt authored Dec 14, 2023
2 parents d4f9560 + 6fc3992 commit c55fd9c
Show file tree
Hide file tree
Showing 20 changed files with 901 additions and 460 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
^codecov\.yml$
^doc$
^Meta$
^data-raw$
2 changes: 1 addition & 1 deletion R/bayesRecon-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#'
#' Corani, G., Azzimonti, D., Rubattu, N. (2023). *Probabilistic reconciliation of count time series*. \doi{10.1016/j.ijforecast.2023.04.003}.
#'
#' Zambon, L., Azzimonti, D. & Corani, G. (2022). *Efficient probabilistic reconciliation of forecasts for real-valued and count time series*. \doi{10.48550/arXiv.2210.02286}.
#' Zambon, L., Azzimonti, D. & Corani, G. (2024). *Efficient probabilistic reconciliation of forecasts for real-valued and count time series*. \doi{10.1007/s11222-023-10343-y}.
#'
#' Zambon, L., Agosto, A., Giudici, P., Corani, G. (2023). *Properties of the reconciled distributions for Gaussian and count forecasts*. \doi{10.48550/arXiv.2303.15135}.
#'
Expand Down
26 changes: 26 additions & 0 deletions R/extr_mkt_events.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#' Extreme market events dataset
#'
#' Count time series of extreme market events in five economic sectors.
#' The data refer to the trading days between 2004/12/31 and 2018/12/19 (3508 trading days in total).
#'
#' The counts are computed by considering 29 companies included in the Euro Stoxx
#' 50 index and observing if the value of the CDS spread on a given day exceeds
#' the 90-th percentile of its distribution in the last trading year.
#' The companies are divided in the following sectors: Financial (FIN), Information
#' and Communication Technology (ICT), Manufacturing (MFG), Energy (ENG), and Trade (TRD).
#'
#' There are 6 time series:
#' - 5 bottom time series, corresponding to the daily counts for each sector
#' - 1 upper time series, which is the sum of all the bottom (ALL)
#'
#' @format
#' A multivariate time series of class \link[stats]{ts}.
#'
#' @source
#' Zambon, L., Agosto, A., Giudici, P., Corani, G. (2023). *Properties of the reconciled distributions for Gaussian and count forecasts*. \doi{10.48550/arXiv.2303.15135}.
#'
#' @references
#' Zambon, L., Agosto, A., Giudici, P., Corani, G. (2023). *Properties of the reconciled distributions for Gaussian and count forecasts*. \doi{10.48550/arXiv.2303.15135}.
#'
#' Agosto, A. (2022). *Multivariate Score-Driven Models for Count Time Series to Assess Financial Contagion*. \doi{10.2139/ssrn.4119895}
"extr_mkt_events"
27 changes: 27 additions & 0 deletions R/extr_mkt_events_basefc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#' Base forecasts for the extreme market events dataset
#'
#' Base forecasts for the `extr_mkt_events` dataset, computed using the model by
#' Agosto, A. (2022). *Multivariate Score-Driven Models for Count Time Series to Assess Financial Contagion*. \doi{10.2139/ssrn.4119895}.
#'
#' The predictive distribution for the bottom time series is a multivariate negative
#' binomial with a static vector of dispersion parameters and a time-varying vector
#' of location parameters following a score-driven dynamics.
#' The base forecasts for the upper time series are computed using a univariate version of this model.
#' They are in-sample forecasts: for each training instant, they are computed for
#' time t+1 by conditioning on the counts observed up to time t.
#'
#' @format
#' A list `extr_mkt_events_basefc` containing
#' \describe{
#' \item{`extr_mkt_events_basefc$mu`}{data frame of the base forecast means, for each day}
#' \item{`extr_mkt_events_basefc$size`}{data frame of the static base forecast size parameters}
#' }
#'
#' @source
#' Agosto, A. (2022). *Multivariate Score-Driven Models for Count Time Series to Assess Financial Contagion*. \doi{10.2139/ssrn.4119895}
#'
#' @references
#' Agosto, A. (2022). *Multivariate Score-Driven Models for Count Time Series to Assess Financial Contagion*. \doi{10.2139/ssrn.4119895}
#'
#' Zambon, L., Agosto, A., Giudici, P., Corani, G. (2023). *Properties of the reconciled distributions for Gaussian and count forecasts*. \doi{10.48550/arXiv.2303.15135}.
"extr_mkt_events_basefc"
2 changes: 1 addition & 1 deletion R/reconc.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@
#'print(rowMeans(samples_buis))
#'
#' @references
#' Zambon, L., Azzimonti, D. & Corani, G. (2022). *Efficient probabilistic reconciliation of forecasts for real-valued and count time series*. \doi{10.48550/arXiv.2210.02286}.
#' Zambon, L., Azzimonti, D. & Corani, G. (2024). *Efficient probabilistic reconciliation of forecasts for real-valued and count time series*. \doi{10.1007/s11222-023-10343-y}.
#'
#'
#' @seealso
Expand Down
4 changes: 2 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ Corani, G., Azzimonti, D., Augusto, J.P.S.C., Zaffalon, M. (2021). *Probabilisti
Corani, G., Azzimonti, D., Rubattu, N. (2023). *Probabilistic reconciliation of count
time series*. [DOI](https://doi.org/10.1016/j.ijforecast.2023.04.003)

Zambon, L., Azzimonti, D. & Corani, G. (2022). *Efficient probabilistic reconciliation of forecasts
for real-valued and count time series*. [DOI](https://doi.org/10.48550/arXiv.2210.02286)
Zambon, L., Azzimonti, D. & Corani, G. (2024). *Efficient probabilistic reconciliation of forecasts
for real-valued and count time series*. [DOI](https://doi.org/10.1007/s11222-023-10343-y)

Zambon, L., Agosto, A., Giudici, P., Corani, G. (2023). *Properties of the reconciled distributions for Gaussian and count forecasts*. [DOI](https://doi.org/10.48550/arXiv.2303.15135)

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,9 @@ Corani, G., Azzimonti, D., Rubattu, N. (2023). *Probabilistic
reconciliation of count time series*.
[DOI](https://doi.org/10.1016/j.ijforecast.2023.04.003)

Zambon, L., Azzimonti, D. & Corani, G. (2022). *Efficient probabilistic
Zambon, L., Azzimonti, D. & Corani, G. (2024). *Efficient probabilistic
reconciliation of forecasts for real-valued and count time series*.
[DOI](https://doi.org/10.48550/arXiv.2210.02286)
[DOI](https://doi.org/10.1007/s11222-023-10343-y)

Zambon, L., Agosto, A., Giudici, P., Corani, G. (2023). *Properties of
the reconciled distributions for Gaussian and count forecasts*.
Expand Down
Binary file added data-raw/NB_score_driven_forecasts.xlsx
Binary file not shown.
9 changes: 9 additions & 0 deletions data-raw/extr_mkt_events.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
library(readxl)

dir_path <- dirname(rstudioapi::getSourceEditorContext()$path)
setwd(dir_path)

data <- read_excel("NB_score_driven_forecasts.xlsx", sheet = "Data")
extr_mkt_events <- ts(data)

usethis::use_data(extr_mkt_events, overwrite = TRUE)
12 changes: 12 additions & 0 deletions data-raw/extr_mkt_events_basefc.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
library(readxl)

dir_path <- dirname(rstudioapi::getSourceEditorContext()$path)
setwd(dir_path)

predictions <- read_excel("NB_score_driven_forecasts.xlsx", sheet = "Predictions")
alpha <- read_excel("NB_score_driven_forecasts.xlsx", sheet = "alpha", n_max = 1)

extr_mkt_events_basefc <- list(mu = data.frame(predictions),
size = data.frame(1 / alpha))

usethis::use_data(extr_mkt_events_basefc, overwrite = TRUE)
Binary file added data/extr_mkt_events.rda
Binary file not shown.
Binary file added data/extr_mkt_events_basefc.rda
Binary file not shown.
2 changes: 1 addition & 1 deletion man/bayesRecon-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions man/extr_mkt_events.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 37 additions & 0 deletions man/extr_mkt_events_basefc.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/reconc_BUIS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c55fd9c

Please sign in to comment.