From bf246e271381a3b21170f37ca7d4abb718087d86 Mon Sep 17 00:00:00 2001 From: Jonathan Berrisch Date: Sun, 25 May 2025 20:25:24 +0200 Subject: [PATCH] Table consistency, VolDep progress --- custom.scss | 5 ++ index.qmd | 189 ++++++++++++++++++++++++++++------------------------ 2 files changed, 107 insertions(+), 87 deletions(-) diff --git a/custom.scss b/custom.scss index f429844..9bfd78e 100644 --- a/custom.scss +++ b/custom.scss @@ -230,4 +230,9 @@ .zero-width { display: inline-block; width: 0px; +} + +.fa { + width: 1.25em; + text-align: center; } \ No newline at end of file diff --git a/index.qmd b/index.qmd index b1d8390..9c084e8 100644 --- a/index.qmd +++ b/index.qmd @@ -44,24 +44,23 @@ $$ $$ ::: -::: {style="font-size: 150%;"} +
+ +:::: {style="font-size: 150%;"} + +   [Research Motivation](#motivation) + +   Overview of the Thesis + +   Online Aggregation + +   Probabilistic Forecasting of European Carbon and Energy Prices + +   Contributions & Outlook + ::: -
- -[{{< fa bars-staggered >}}]{style="color: #404040;"}   [Introduction & Research Motivation](#motivation) - -[{{< fa bars-staggered >}}]{style="color: #404040;"}   Overview of the Thesis - -[{{< fa table >}}]{style="color: #404040;"}   Online Learning - -[{{< fa circle-nodes >}}]{style="color: #404040;"}   Probabilistic Forecasting of European Carbon and Energy Prices - -[{{< fa lightbulb >}}]{style="color: #404040;"}   Limitations - -[{{< fa binoculars >}}]{style="color: #404040;"}   Contributions & Outlook - ```{r, setup, include=FALSE} # Compile with: rmarkdown::render("crps_learning.Rmd") library(latex2exp) @@ -538,7 +537,7 @@ Using the CRPS, we can calculate time-adaptive weights $w_{t,k}$. However, what \label{eq_boa_opt_conv} \end{equation} -`r fontawesome::fa("arrow-right", fill ="#000000")` Almost optimal w.r.t *convex aggregation* \eqref{eq_optp_conv} @wintenberger2017optimal. +`r fontawesome::fa("arrow-right", fill ="#000000")` Almost optimal w.r.t. *convex aggregation* \eqref{eq_optp_conv} @wintenberger2017optimal. The same algorithm satisfies that there exist a $C>0$ such that for $x>0$ it holds that \begin{equation} @@ -550,7 +549,7 @@ The same algorithm satisfies that there exist a $C>0$ such that for $x>0$ it hol if $Y_t$ is bounded, the considered loss $\ell$ is convex $G$-Lipschitz and weak exp-concave in its first coordinate. -`r fontawesome::fa("arrow-right", fill ="#000000")` Almost optimal w.r.t *selection* \eqref{eq_optp_select} @gaillard2018efficient. +`r fontawesome::fa("arrow-right", fill ="#000000")` Almost optimal w.r.t. *selection* \eqref{eq_optp_select} @gaillard2018efficient. `r fontawesome::fa("arrow-right", fill ="#000000")` We show that this holds for QL under feasible conditions. @@ -579,7 +578,7 @@ for all $x_1,x_2 \in \mathbb{R}$ and $t>0$ that \mathbb{E}\left[ \left. \left( \alpha(\ell'(x_1, Y_t)(x_1 - x_2))^{2}\right)^{1/\beta} \right|\mathcal{F}_{t-1}\right] \end{align*} -`r fontawesome::fa("arrow-right", fill ="#000000")` Almost optimal w.r.t *selection* \eqref{eq_optp_select} @gaillard2018efficient. +`r fontawesome::fa("arrow-right", fill ="#000000")` Almost optimal w.r.t. *selection* \eqref{eq_optp_select} @gaillard2018efficient. ::: @@ -1247,12 +1246,8 @@ TTinit <- 1 ## without first, as all comb. are uniform RQL <- apply(QL[1:KK, -c(1:TTinit), ], c(1, 3), mean) dimnames(RQL) <- list(mnames, Qgrid) RQLm <- apply(RQL, c(1), mean, na.rm = TRUE) -# sort(RQLm - RQLm[K + 1]) ## qq <- apply(QL[1:KK, -c(1:TTinit), ], c(1, 2), mean) -# t.test(qq[K + 1, ] - qq[K + 3, ]) -# t.test(qq[K + 1, ] - qq[K + 4, ]) - library(xtable) Pall <- numeric(KK) @@ -1290,12 +1285,13 @@ for (i.p in 1:MO) { fblue <- round(approxfun(seq(crange[1], crange[2], length = length(cblue)), cblue)(pmin(xxx[, i.p], xmax)), 3) tmp <- format(round(xxx[, i.p], 3), nsmall = 3) xxxx[, i.p] <- paste("\\cellcolor[rgb]{", fred, ",", fgreen, ",", fblue, "}", tmp, " {\\footnotesize (", Pallout[IDX[i.p]], ")}", sep = "") - table[, i.p] <- paste0(tmp, " (", Pallout[i.p], ")") + table[, i.p] <- paste0(tmp, " (", Pallout[i.p], ")") # TODO: Improve here? table_col[, i.p] <- rgb(fred, fgreen, fblue, maxColorValue = 1) } # i.p table_out <- kbl(table, align = rep("c", ncol(table)), bootstrap_options = c("condensed")) %>% - kable_paper(full_width = TRUE) + kable_paper(full_width = TRUE) %>% + row_spec(0:nrow(table), color = cols[9, "grey"]) for (j in 1:ncol(table)) { table_out <- table_out %>% @@ -1333,7 +1329,8 @@ for (i.p in 1:MO) { } # i.p table_out2 <- kableExtra::kbl(table2, align = rep("c", ncol(table2)), bootstrap_options = c("condensed")) %>% - kable_paper(full_width = TRUE) + kable_paper(full_width = TRUE) %>% + row_spec(0:nrow(table2), color = cols[9, "grey"]) for (j in 1:ncol(table2)) { table_out2 <- table_out2 %>% @@ -1623,7 +1620,7 @@ table_naive <- naive_table_df %>% align = c("c", rep("c", ncol(naive_table_df) - 1)) ) %>% kable_paper(full_width = TRUE) %>% - row_spec(0:1, color = cols[10, "grey"]) %>% + row_spec(0:1, color = cols[9, "grey"]) %>% kable_styling(font_size = 16) @@ -1694,7 +1691,7 @@ table_performance <- performance_loss_tibble %>% align = c("l", "l", rep("c", ncol(performance_loss_tibble)-2)) ) %>% kable_paper(full_width = TRUE) %>% - row_spec(0:nrow(performance_loss_tibble), color = cols[10, "grey"]) + row_spec(0:nrow(performance_loss_tibble), color = cols[9, "grey"]) # %% @@ -2214,23 +2211,33 @@ Berrisch, J., Pappert, S., Ziel, F., & Arsova, A. (2023). *Finance Research Lett --- -## Motivation +##   :::: {.columns} ::: {.column width="48%"} -- Understanding European Allowances (EUA) dynamics is important +### Motivation + +Understanding European Allowances (EUA) dynamics is important for several fields: -- - Portfolio & Risk Management, -- - Sustainability Planing -- - Political decisions -- - ... + + Portfolio & Risk Management, + + Sustainability Planing + + Political decisions EUA prices are obviously connected to the energy market How can the dynamics be characterized? +Several Questions arise: + +- Data (Pre)processing +- Modeling Approach +- Evaluation + ::: ::: {.column width="2%"} @@ -2239,13 +2246,25 @@ How can the dynamics be characterized? ::: {.column width="48%"} -
+### Data -- Several Questions arise: +EUA, natural gas, Brent crude oil, coal -- - Data (Pre)processing -- - Modeling Approach -- - Evaluation +March 15, 2010, until October 14, 2022 + +Data was normalized w.r.t. $\text{CO}_2$ emissions + +Emission-adjusted prices reflects one tonne of $\text{CO}_2$ + +We adjusted for inflation by Eurostat's HICP, excluding energy + +Log transformation of the data to stabilize the variance + +ADF Test: All series are stationary in first differences + +Johansen’s likelihood ratio trace test suggests two cointegrating relationships (levels) + +Johansen’s likelihood ratio trace test suggests no cointegrating relationships (logs) ::: @@ -2253,24 +2272,6 @@ How can the dynamics be characterized? ## Data -- EUA, natural gas, Brent crude oil, coal -- March 15, 2010, until October 14, 2022 - -- Data was normalized w.r.t. $\text{CO}_2$ emissions -- Emission-adjusted prices reflects one tonne of $\text{CO}_2$ - -- We adjusted for inflation by Eurostat's HICP, excluding energy - - -- Log transformation of the data to stabilize the variance - -- ADF Test: All series are stationary in first differences - -- Johansen’s likelihood ratio trace test suggests two cointegrating relationships (levels) -- Johansen’s likelihood ratio trace test suggests no cointegrating relationships (logs) - -## Data - ```{r, echo=FALSE, fig.width = 12, fig.height = 6, fig.align="center", cache = TRUE} readr::read_csv("assets/voldep/2022_10_14_eur_ref_co2_adj_hvpi_ex_nrg.csv") %>% select(-EUR_USD, -hvpi_x_nrg) %>% @@ -2339,15 +2340,17 @@ readr::read_csv("assets/voldep/2022_10_14_eur_ref_co2_adj_hvpi_ex_nrg.csv") %>% ### GARCH: Generalized Autoregressive Conditional Heteroscedasticity - - Captures the variance dynamics + - Captures dynamics in conditional variance ### Copula: Captures the dependence structure - - Captures: conditional cross-sectional dependence structure + - Captures: conditional cross-sectional dependencies - Dependence allowed to vary over time -## Modeling Approach: Overview +## Modeling Approach: Notation + +
:::: {.columns} @@ -2400,15 +2403,17 @@ We take $C$ as the $t$-copula ## Modeling Approach: Mean and Variance +
+ :::: {.columns} ::: {.column width="48%"} -#### Individual marginal distributions: +### Individual marginal distributions: $$\mathbf{F} = (F_1, \ldots, F_K)^{\intercal}$$ -#### Generalized non-central t-distributions +### Generalized non-central t-distributions - To account for heavy tails - Time varying - expectation: $\boldsymbol{\mu}_t = (\mu_{1,t}, \ldots, \mu_{K,t})^{\intercal}$ @@ -2425,7 +2430,7 @@ $$\mathbf{F} = (F_1, \ldots, F_K)^{\intercal}$$ ::: {.column width="48%"} -#### VECM Model +### VECM Model \begin{align} \Delta \boldsymbol{\mu}_t = \Pi \boldsymbol{x}_{t-1} + \Gamma \Delta \boldsymbol{x}_{t-1} \nonumber @@ -2433,7 +2438,7 @@ $$\mathbf{F} = (F_1, \ldots, F_K)^{\intercal}$$ where $\Pi = \alpha \beta^{\intercal}$ is the cointegrating matrix of rank $r$, $0 \leq r\leq K$. -#### GARCH model +### GARCH model \begin{align} \sigma_{i,t}^2 = & \omega_i + \alpha^+_{i} (\epsilon_{i,t-1}^+)^2 + \alpha^-_{i} (\epsilon_{i,t-1}^-)^2 + \beta_i \sigma_{i,t-1}^2 \nonumber @@ -2449,11 +2454,13 @@ Separate coefficients for positive and negative innovations to capture leverage ## Modeling Approach: Dependence +
+ :::: {.columns} ::: {.column width="48%"} -#### Time-varying dependence parameters +### Time-varying dependence parameters \begin{align*} \Xi_{t} = & \Lambda\left(\boldsymbol{\xi}_{t}\right) @@ -2479,7 +2486,7 @@ $\Lambda(\cdot)$ is a link function ::: {.column width="48%"} -#### Maximum Likelihood Estimation +### Maximum Likelihood Estimation All parameters can be estimated jointly. Using conditional independence: \begin{align*} @@ -2498,11 +2505,13 @@ The copula density $c$ can be derived analytically. ## Study Design and Evaluation +
+ :::: {.columns} ::: {.column width="48%"} -#### Rolling-window forecasting study +### Rolling-window forecasting study - 3257 observations total - Window size: 1000 days (~ four years) @@ -2516,18 +2525,18 @@ We draw $2^{12}= 2048$ trajectories from the joint predictive distribution ::: -::: {.column width="2%"} +::: {.column width="4%"} ::: ::: {.column width="48%"} -#### Evaluation +### Evaluation Forecasts are evaluated by the energy score (ES) \begin{align*} - \text{ES}_t(F, \mathbf{x}_t) = \mathbb{E}_{F} \left(||\tilde{\mathbf{X}}_t - \mathbf{x}_t||_2\right) - \frac{1}{2} \mathbb{E}_F \left(||\tilde{\mathbf{X}}_t - \tilde{\mathbf{X}}_t'||_2 \right) + \text{ES}_t(F, \mathbf{x}_t) = \mathbb{E}_{F} \left(||\tilde{\mathbf{X}}_t - \mathbf{x}_t||_2\right) - \\ \frac{1}{2} \mathbb{E}_F \left(||\tilde{\mathbf{X}}_t - \tilde{\mathbf{X}}_t'||_2 \right) \end{align*} where $\mathbf{x}_t$ is the observed $K$-dimensional realization and $\tilde{\mathbf{X}}_t$, respectively $\tilde{\mathbf{X}}_t'$ are independent random vectors distributed according to $F$ @@ -2538,17 +2547,21 @@ For univariate cases the Energy Score becomes the Continuous Ranked Probability :::: +## Results + +::: {.panel-tabset} + ## Energy Scores :::: {.columns} -::: {.column width="48%"} +::: {.column width="55%"} Relative improvement in ES compared to $\text{RW}^{\sigma, \rho}$ -Cellcolor: w.r.t test statistic of Diebold-Mariano test (testing wether the model outperformes the benchmark, greener = better). +Cellcolor: w.r.t. test statistic of Diebold-Mariano test (testing wether the model outperformes the benchmark, greener = better). -```{r, echo=FALSE, results='asis', cache = TRUE} +```{r, echo=FALSE, results='asis', width = 'revert-layer', cache = TRUE} load("assets/voldep/energy_df.Rdata") table_energy <- energy %>% kbl( @@ -2571,8 +2584,8 @@ table_energy <- energy %>% format = "html", align = c("l", rep("r", ncol(energy) - 1)) ) %>% - kable_paper(full_width = FALSE) %>% - row_spec(0:nrow(energy), color = cols[10, "grey"]) + kable_paper(full_width = TRUE) %>% + row_spec(0:nrow(energy), color = cols[9, "grey"]) for (i in 2:ncol(energy)) { bold_cells <- rep(FALSE, times = nrow(energy)) @@ -2598,18 +2611,17 @@ for (i in 2:ncol(energy)) { table_energy %>% kable_styling( bootstrap_options = c("condensed"), - full_width = TRUE, font_size = 14 ) ``` ::: -::: {.column width="2%"} +::: {.column width="4%"} ::: -::: {.column width="48%"} +::: {.column width="41%"} - Benchmarks: - $\text{RW}^{\sigma, \rho}$: Random walk with constant volatility and correlation @@ -2640,7 +2652,7 @@ table_energy %>% ::: -::: {.column width="2%"} +::: {.column width="4%"} ::: @@ -2659,7 +2671,7 @@ table_crps <- crps %>% # Dont replace any string, dataframe has to be valid latex code ... escape = FALSE, format = "html", - booktabs = TRUE, + booktabs = FALSE, align = c("l", rep("r", ncol(crps) - 1)) ) %>% kable_paper(full_width = FALSE) @@ -2683,7 +2695,8 @@ for (i in 2:ncol(crps)) { } table_crps <- table_crps %>% - add_header_above(c(" ", "EUA" = 3, "Oil" = 3, "NGas" = 3, "Coal" = 3)) + add_header_above(c(" ", "EUA" = 3, "Oil" = 3, "NGas" = 3, "Coal" = 3)) %>% + row_spec(0:nrow(crps), color = cols[9, "grey"]) table_crps %>% kable_styling( @@ -2718,13 +2731,12 @@ Conclusion: the Improvements seen before must be attributed to other parts of th ::: -::: {.column width="2%"} +::: {.column width="4%"} ::: ::: {.column width="68%"} - Improvement in RMSE score of selected models relative to $\textrm{RW}^{\sigma, \rho}_{}$ in % (higher = better). Colored according to the test statistic of a DM-Test comparing to $\textrm{RW}^{\sigma, \rho}_{}$ (greener means lower test statistic i.e., better performance compared to $\textrm{RW}^{\sigma, \rho}_{}$). ```{r, echo=FALSE, results = 'asis', cache = TRUE} @@ -2761,7 +2773,8 @@ for (i in 2:ncol(rmsq)) { } table_rmsq <- table_rmsq %>% - add_header_above(c(" ", "EUA" = 3, "Oil" = 3, "NGas" = 3, "Coal" = 3)) + add_header_above(c(" ", "EUA" = 3, "Oil" = 3, "NGas" = 3, "Coal" = 3)) %>% + row_spec(0:nrow(rmsq), color = cols[9, "grey"]) table_rmsq %>% kable_styling( @@ -2777,7 +2790,7 @@ table_rmsq %>% ## Evolution of Linear Dependence $\Xi$ -```{r, echo=FALSE, fig.width = 12, fig.height = 6, fig.align="center", cache = TRUE} +```{r, echo=FALSE, fig.width = 12, fig.height = 5.5, fig.align="center", cache = TRUE} load("assets/voldep/plot_rho_df.Rdata") ggplot() + geom_line( @@ -2860,9 +2873,9 @@ ggplot() + ) ``` -## Predictive Quantiles (Russian Invasion) +## Predictive Quantiles -```{r, echo=FALSE, fig.width = 12, fig.height = 6, fig.align="center", cache = TRUE} +```{r, echo=FALSE, fig.width = 12, fig.height = 5.5, fig.align="center", cache = TRUE} load("assets/voldep/plot_quant_df.Rdata") plot_quant_data %>% ggplot(aes(x = date, y = value)) + @@ -2922,6 +2935,8 @@ plot_quant_data %>% ggplot(aes(x = date, y = value)) + ``` +:::: + ## Conclusion :::: {.columns} @@ -2938,7 +2953,7 @@ Accounting for heteroscedasticity or stabilizing the variance via log transforma ::: -::: {.column width="2%"} +::: {.column width="4%"} :::