---
params:
  new_bn: NA
  old_bn: NA
  hfserie_name: NA
  lfserie_name: NA
title: "Benchmark report `r deparse(params$hfserie_name)` on `r deparse(params$lfserie_name)`"
date: "`r format(Sys.time(), '%d %B %Y')`"
---

```{r include=F}
knitr::opts_chunk$set(fig.height = 2.5,out.width = "100%")
knitr::opts_knit$set(global.par = TRUE)
hfserie <- disaggR:::neither_outlier_nor_constant.twoStepsBenchmark(params$new_bn)

# the parameters not affected by preset models are kept (i.e. time series, outliers and time boundaries)

list_args <- c(list(hfserie= hfserie,
                    outliers = outliers(params$new_bn)),  
               model.list(params$new_bn)[c("lfserie",
                                           "start.coeff.calc","end.coeff.calc",
                                           "start.benchmark","end.benchmark",
                                           "start.domain","end.domain")]
)

presets_list <- do.call(disaggR:::presets_list_fun, list_args)
```

# Presets

:::: {.columns}

::: {.column width="50%"}

Model 1 (*differences --- with constant*)

```{r echo=FALSE}
plot(in_sample(presets_list[[1]]))
```

Model 3 (*levels --- with constant*)

```{r echo=FALSE}
plot(in_sample(presets_list[[3]]))
```

Model 5 (*levels --- without constant*)

```{r echo=FALSE}
plot(in_sample(presets_list[[5]]))
```

:::

::: {.column width="50%"}

Model 2 (*differences --- without constant*)

```{r echo=FALSE}
plot(in_sample(presets_list[[2]]))
```

Model 4 (*autocorrelated levels --- with constant*)

```{r echo=FALSE}
plot(in_sample(presets_list[[4]]))
```

Model 6 (*autocorrelated levels --- without constant*)

```{r echo=FALSE}
plot(in_sample(presets_list[[6]]))
```

:::

::::

```{r echo=FALSE,results = 'asis'}
htmltools::HTML(
  as.character(
    disaggR:::summary_table_html(presets_list,
                                 params$old_bn,
                                 2L)
    ))
```

# Scatter plot

:::: {.columns}

::: {.column width="100%"}

```{r echo=FALSE}
plot(in_scatter(params$new_bn))
```

:::

::::

# Benchmark

:::: {.columns}

::: {.column width="100%"}

```{r echo=FALSE,comment="\t"}
cat(disaggR:::get_benchmark_call(params$new_bn,params$hfserie_name,params$lfserie_name))
```

```{r echo=FALSE, fig.width=14}
plot(params$new_bn)
```

:::

::::

# In-sample predictions

:::: {.columns}

::: {.column width="100%"}

```{r echo=FALSE, fig.width=14}
plot(in_sample(params$new_bn,type="levels"),
     ylab = "Levels")
plot(in_sample(params$new_bn,type="changes"),
     ylab = "Changes")
```

:::

::::

# Benchmark summary

:::: {.columns}

::: {.column width="100%"}

```{r echo=FALSE, fig.width=14}
print(summary(params$new_bn),call=FALSE)
```

:::

::::

# Comparison benchmark/input

:::: {.columns}

::: {.column width="100%"}

```{r echo=FALSE,fig.width = 14}
plot(in_disaggr(params$new_bn,type="levels-rebased"),
     ylab = "Rebased levels")
plot(in_disaggr(params$new_bn,type="changes"),
     ylab = "Changes")
plot(in_disaggr(params$new_bn,type="contributions"),
     ylab = "Contributions")
```

:::

::::