## 1jorea2022002

## Source details

**Canonical URL:** [1jorea2022002](https://www.imf.org/-/media/files/publications/cr/2022/english/1jorea2022002.pdf)

## Other formats

- [Markdown version](/-/media/files/publications/cr/2022/english/1jorea2022002.pdf.md)
- [Structured JSON version](/-/media/files/publications/cr/2022/english/1jorea2022002.pdf.json)

---

### Preface — Mission, Objective, Context
- Mission: A Monetary and Capital Markets (MCM) Department remote mission took place from April to June 2021 at the request of the Central Bank of Jordan (CBJ).
- Objective: Assist the CBJ in forecasting currency in circulation (CiC) to improve liquidity management.
- Context and current practice:
  - CBJ operates a fixed exchange rate arrangement against the US dollar since 1995 and manages domestic liquidity through a corridor system.
  - The CBJ publishes its liquidity forecast daily, but this forecast doesn’t include a formal model.
  - The central bank currently uses an Auto Regressive Integrated Moving Average (ARIMA) model with many indicator variables on daily CiC data, fitted using a standard maximum likelihood estimator.
- Mission engagements: Met with Nedal Azzam; Mohammad A. Khreisat; Rajeh A. Alkhdour; Rami A. Alhadid; Mohammed H. Shinnar; Mohammed N. Arar; Ibrahim Q. Naser; Tariq A. Almuhaissen; Mahmoud W. Qasem; Farah M. Khamash; Muna M. Alkurdi; Osama Alsayeh.
- Note: Treasury does not provide forecasts of expected cash flow movements to the CBJ; a forecasting arrangement (Staff Level Agreement (SLA) or Memorandum of Understanding (MoU)) would be beneficial.

### Executive summary — Main findings and framework
- Main findings:
  - The current ARIMA with binary seasonality is aligned with international practice but has substantial room for improvement.
  - Modeling seasonality with many indicator variables estimates many parameters, amplifying parametric noise, increasing risk of overfitting, and sensitivity to structural breaks.
  - Statistical literature over the last 20 years proposes more parsimonious methods (e.g., trigonometric seasonality, advanced smoothing, machine learning, neural networks).
- Proposed forecasting framework:
  - Two-tier forecasting framework developed by the IMF team:
    - First-tier: estimation of six different families of individual forecasting models.
    - Second-tier: dynamic model selection and model aggregation to maximize accuracy.
  - Framework features:
    - Automatically reparametrizes models to account for structural breaks and new data developments.
    - Handles different time series (currency in circulation, currency issued, individual banknotes) at different frequencies.
- Performance and recommendation trade-offs:
  - Dynamic model selection is the best overall performer.
  - An ARIMA with trigonometric seasonality delivers the best performance/complexity compromise among first-tier models.
  - The ARIMA with trigonometric seasonality:
    - Is parsimonious and straightforward to specify.
    - Outperforms ARIMA with binary seasonality substantially.
  - Recommendation: CBJ could prefer the trigonometric ARIMA for near-term operational use; dynamic model selection if CBJ chooses the best-available approach despite added complexity.
- Software and capacity building:
  - IMF provided fully automated software infrastructure implemented in R.
  - Code is documented and produces charts and tables on the fly.
  - IMF experts trained CBJ staff on software use for operational forecasting.

### Key recommendations (Table 1 summary)
- Use a trigonometric ARIMA instead of a binary ARIMA (Authority: CBJ) — Priority: High — Timeframe: Near-term
- Implement the two-tier forecasting framework and obtain the set of forecasts, leveraging the full range of models (Authority: CBJ) — Priority: Medium — Timeframe: Medium-term
- Produce monitoring forecasting reports and analyze the performance of the forecasts at a regular interval (Authority: CBJ) — Priority: Medium — Timeframe: Medium-term
- Publish the methodology to strengthen the transparence and the credibility of the central bank (Authority: CBJ) — Priority: Medium — Timeframe: Medium-term
- Note: Near term: < 12 months; Medium term: 12 to 24 months.

### Second-tier modeling framework — selection vs combination and performance
- Purpose: Improve forecasting accuracy of single models by combining or selecting them.
- Combination: averages forecasts of different models (potentially with weights) to reduce modeling risk.
- Model selection: picks the most appropriate model based on recent performance; advantage is rapid adjustment to structural breaks.
- Performance metrics and training/testing split:
  - Training group: 2010 to 2018
  - Testing group: 2018–2020
  - Models fitted on 2010 to 2018, then forecast 2018–2020 for performance assessment.
- Key model-performance findings for Jordan:
  - Best-performing individual model: ARIMA with trigonometric seasonality (models seasonality via sinusoidal functions rather than many indicator variables).
  - Best-performing overall approach: dynamic model selection (automatic re-parametrization and ability to change model type and parameters each period).
  - Trade-off:
    - Gain from dynamic model selection is relatively small compared to ARIMA with trigonometric seasonality.
    - ARIMA with trigonometric seasonality offers best compromise between accuracy and parsimony; recommended for daily operations unless CBJ opts for maximal accuracy.

### Empirical performance metrics (selected numeric results)
- Currency issued (selected entries from Table 3; metrics are Mean RMSE, Median RMSE, Mean Rank):
  - Naïve: 5 days Mean RMSE 29.62, Median RMSE 19.35, Mean Rank 4.70; 24 days Mean RMSE 49.27, Median RMSE 35.89, Mean Rank 4.34
  - ETS: 5 days 30.31, 21.94, 4.70; 24 days 56.93, 40.11, 4.94
  - ARIMA: 5 days 30.77, 23.14, 5.01; 24 days 54.44, 39.87, 4.73
  - ETStrig: 5 days 28.30, 18.15, 4.54; 24 days 64.45, 54.31, 5.54
  - ARIMAtrigA: 5 days 26.37, 18.27, 4.36; 24 days 48.21, 36.90, 4.31
  - ARIMAtrigB: 5 days 26.49, 19.58, 4.44; 24 days 46.58, 35.52, 4.27
  - Select: 5 days 24.79, 16.26, 4.03; 24 days 42.13, 30.91, 3.72
  - Combine: 5 days 25.96, 19.07, 4.22; 24 days 46.61, 34.88, 4.16
- Currency in circulation (CiC) (selected entries from Table 4):
  - Naïve: 5 days Mean RMSE 39.82, Median RMSE 29.49, Mean Rank 4.82; 24 days Mean RMSE 54.82, Median RMSE 42.79, Mean Rank 4.17
  - ETS: 5 days 42.09, 29.78, 4.81; 24 days 66.44, 51.65, 4.91
  - ARIMA: 5 days 42.21, 34.43, 5.49; 24 days 65.71, 49.56, 5.08
  - ETStrig: 5 days 38.96, 28.40, 4.97; 24 days 97.98, 87.97, 6.37
  - ARIMAtrigA: 5 days 31.50, 22.30, 4.54; 24 days 50.45, 40.51, 4.34
  - ARIMAtrigB: 5 days 27.92, 18.42, 3.83; 24 days 47.83, 33.00, 3.79
  - Select: 5 days 26.01, 16.92, 3.64; 24 days 44.49, 29.36, 3.63
  - Combine: 5 days 29.11, 20.01, 3.90; 24 days 45.07, 30.56, 3.70
- Findings from tests:
  - Dynamic selection provides the best results consistently across horizons and metrics for CiC.
  - ARIMAtrigB yields best mean rank of a single forecast for both horizons for CiC.
  - Including indicators for calendar events improves short-term accuracy; marginal or negative effects at longer horizons for CiC.

### Temporal hierarchies (THieF) — role and impact
- THieF purpose: combine models produced from temporally aggregating a time series to reduce modeling risk and extract components (monthly seasonality, annual dynamics).
- Aggregation levels considered: 1, 2, 4, 5, 10, 13, 20, 26, 52, 65, 130, and 260 days.
  - With five-day weeks, 260 days ≈ full year, 65 ≈ quarter.
- For CiC sample size constraints (series starts November 1, 2018) only first eight aggregation levels used.
- Impact on CiC performance (Table 5 differences — reported as Accuracy difference using temporal hierarchies):
  - ARIMAtrigB: 5-days Mean RMSE 0.53, Median RMSE -0.30; 24 days Mean RMSE 4.14, Median RMSE 2.12
  - Select: 5-days Mean RMSE -3.04, Median RMSE -4.08; 24 days Mean RMSE 5.20, Median RMSE 3.42
  - Combine: 5-days Mean RMSE 1.76, Median RMSE -0.21; 24 days Mean RMSE 7.10, Median RMSE 2.17
- Interpretation:
  - Marginal gains in Mean RMSE short-term, mixed median results.
  - Consistent gains for longer-term forecasts.
  - IMF recommendation: against routine usage of THieF for this application because complexity yields only modest gains.

### Modeling choices — seasonality, indicators, and parsimony
- Multiple seasonal cycles modeled: day in the week, day in the month, day in the year.
- Trigonometric encoding of seasonal cycles:
  - For season length ss, construct ss/2 pairs of trigonometric variables with i = 1,..., ss/2:
    - di = cos(2 i π t / ss)
    - di+ss/2 = sin(2 i π t / ss)
    - where t = 1,..., ss
  - If ss is odd, round up ss/2 to the closest integer.
  - Trigonometric encoding is mathematically equivalent to using s binary indicators; can set ss = 365.25 to capture leap-year effects.
- Filtering seasonal indicators for parsimony:
  - Two-step filtering:
    1. Fit simple ARIMA on series (with policy-effect indicators); use residuals as target.
    2. Jointly estimate inclusion of day-in-week and day-in-quarter trigonometric dummies with stepwise regression based on AIC; use Lasso for annual seasonality then pool and refilter with AIC.
- Indicator variables for holidays and policy/long-term effects:
  - Holidays captured by binary indicators with up to five days lead and lag effects (lead/lag construction for each indicator).
  - Long-term/policy effects encoded as indicators equal to 1 after effect starts and 0 before/after end (no leads/lags unless constructed).
  - Indicators selected via AIC stepwise regression applied to residuals of ARIMA with specified orders and trigonometric indicators.
- Advantages of trigonometric vs binary encoding:
  - Both equivalent when all indicators used; after filtering, trigonometric encoding provides smoother approximations and efficient sparse approximations where binary encoding can omit seasonal information.

### First-tier models, augmentations, and exclusions
- Benchmark models:
  - Naïve (random walk)
  - Exponential Smoothing (ETS)
  - Automatically specified ARIMA (includes Seasonal ARIMA via automatic specification)
- Advanced/augmented models:
  - ETStrig (ETS + trigonometric seasonality)
  - ARIMAtrigA (ARIMA with trigonometric seasonality, forecast package)
  - ARIMAtrigB (ARIMA with trigonometric seasonality, smooth package, simultaneous estimation)
- Models tested and excluded due to poor performance or practical issues:
  - NN-ELM (neural network extreme learning machine): provided unreliable forecasts for CrI and CiC; ensemble of 20 networks using median operator; removed.
  - TBATS: cannot include external variables (special-event indicators), faced difficulties with non-stationarity and COVID-19 shift; removed.
- Operational guidance:
  - Regular daily operation: run ARIMA with trigonometric seasonality with previously estimated parameters (single-model forecasts run in seconds).
  - Full re-estimation (all models) once a month or when a structural break occurs (computationally time-consuming).

### Data preprocessing, missing values, weekends, structural breaks
- Data span provided by CBJ: January 6, 2007, to February 15, 2021.
- Dataset components:
  - Daily records of Currency Issued (CrI) and Currency in Circulation (CiC).
  - Observations complete for CrI for full span.
  - CiC observations started on November 1, 2018.
- Missing-value treatment:
  - Continuity in dates essential; missing dates break periodicity.
  - IMF team imputed missing values by linear interpolation from neighboring values (chosen for robustness and simplicity given scarcity of missing values).
  - Alternative: provide indicator variables for each missing value (mathematically equivalent to excluding observations).
- Weekends and working-day adjustments:
  - Model fitted on five-day weeks; excludes non-working days (Fridays and Saturdays) from time series and inputs.
- Structural breaks and non-stationarity:
  - COVID-19 pandemic produced substantial shift in CiC and CrI; modeled using an indicator variable (0 before, 1 after).
  - Strong evidence of non-stationarity for both series.

### Forecast uncertainty, evaluation procedures, and statistical testing
- Out-of-sample rolling origin forecasts with five day ahead forecasts; last 100 days retained as test set.
  - Training set iteratively increases by one observation to produce forecasts for successive five-day windows.
- Metrics: Mean and median RMSE across forecast origins used to evaluate accuracy; mean vs median RMSE differences indicate presence of extreme errors.
- Dynamic model selection:
  - Uses mean RMSE of the t+1 to t+5 forecasts over the last five forecast origins as performance tracker.
- Forecast combination:
  - Equal weights used to limit estimation error in weights.
- Forecast pooling:
  - Pools top-performing models excluding Naïve and limiting to models that capture partial/complete seasonal information.
- Statistical testing:
  - Non-parametric Friedman and Nemenyi post-hoc tests at 5 percent significance used to assess significant differences in mean ranks; dynamic selection often significantly better for longer horizons.
- Probabilistic forecasts and intervals:
  - ARIMA with trigonometric seasonality and dynamic model selection provide prediction intervals (examples: 80 percent, 90 percent, and 95 percent).
  - Forecast combination does not readily provide analytical prediction intervals; empirical intervals possible.

### Software, scripts, and user guide (R implementation)
- Software: Fully automated R infrastructure; recommended R versions 4.1.0 or 4.1.1.
- Zipped third-party libraries provided as library_JOR.zip (approximately 197 MB); recommended to unzip on a shared mapped drive (example pattern \\sharedrive\IMF\library).
- R library path configuration recommendation:
  - .Library.site <- file.path("Z:/library")
  - .libPaths(.Library.site)
  - Replace Z:/library with mapped/unzipped location.
- Scripted workflow (high-level):
  - Step 0 (data cleaning): read raw Excel/csv from rawdatafile parameter; set start/end dates; add datatype column (data, holiday, imputed); remove weekends; linearly interpolate missing dates; save dataclean output; plot target variable to PDF.
  - Step 1 (adding features): read cleaned csv; generate daily biases for each day of week; generate trigonometric biases for day-in-month and day-in-year; add structural breaks; add bias terms around 20th of each month and for quarters; save dataFeat output and feature plots.
  - Step 2 (fitting models): read dataFeat csv; create matrix of features; run forecastLoop to run specified models over date range; save forecast results to Excel. Models implemented include Naive, SNaive, ETS, ARIMA, ETSfeat, ARIMAfeat, ARIMAtrigB, TBATS, TBATSfeat.
  - Step 3 (summary): read forecasts Excel; calculate errors and RMSE for each model; construct composite models (Select by rolling best, mean of several models); write RMSE csv; plot RMSE and forecasts; produce merged PDF of forecast plots per origin.
- Contacts for code help: Kei Moriya (kmoriya@imf.org), Romain Lafarguette (rlafarguette@imf.org); Annex II also lists Kei Moriya and Adeleke Adeyemi (IMF, IT Department) and aadeyemi@imf.org.

*IMF | Jordan Forecasting Framework for Currency in Circulation — Preface, Executive Summary, Chapters 11 and 30, and User Guide excerpts.*

### Preface.................................................................................................................

### Preface

### Mission and contacts
- A Monetary and Capital Markets (MCM) Department remote mission took place from April to June 2021 at the request of the Central Bank of Jordan (CBJ).
- The mission met with: Nedal Azzam; Mohammad A. Khreisat; Rajeh A. Alkhdour; Rami A. Alhadid; Mohammed H. Shinnar; Mohammed N. Arar; Ibrahim Q. Naser; Tariq A. Almuhaissen; Mahmoud W. Qasem; Farah M. Khamash; Muna M. Alkurdi; Osama Alsayeh.
- The mission thanks colleagues of the Central Bank of Jordan for their cooperation and productive discussions.

### Objective
- Assist the CBJ in forecasting currency in circulation (CiC) to improve liquidity management.

### Context and current practice
- CBJ operates a fixed exchange rate arrangement against the US dollar since 1995 and manages domestic liquidity through a corridor system.
- The CBJ publishes its liquidity forecast daily, but this forecast doesn’t include a formal model.
- The central bank currently uses an Auto Regressive Integrated Moving Average (ARIMA) model with many indicator variables on daily CiC data, fitted using a standard maximum likelihood estimator.

### Importance of accurate forecasts
- Accurate forecasts of autonomous factors (currency in circulation, the state account at the central bank, and net foreign assets) are crucial to calibrate CBJ operations and maintain an appropriate structural liquidity surplus.
- The Treasury does not provide forecasts of expected cash flow movements to the CBJ; forecasting the government position would benefit from an institutional arrangement (e.g., a Staff Level Agreement (SLA) or a Memorandum of Understanding (MoU)).
- The mission focused on CiC forecasts as a step towards full liquidity forecasting.

---

### Executive Summary

### Main findings
- The current ARIMA with binary seasonality is aligned with international practice but has substantial room for improvement.
- Modeling seasonality with many indicator variables estimates many parameters, amplifying parametric noise, increasing risk of overfitting, and sensitivity to structural breaks.
- Over the last 20 years, statistical literature has proposed more parsimonious and accurate methods to model seasonality (e.g., trigonometric seasonality, advanced smoothing, machine learning, neural networks).

### Proposed forecasting framework
- The IMF team developed a two-tier forecasting framework:
  - First-tier: estimation of six different families of individual forecasting models.
  - Second-tier: dynamic model selection and model aggregation to maximize accuracy.
- The framework automatically reparametrizes models to account for structural breaks and new data developments.
- The system handles different time series (currency in circulation, currency issued, individual banknotes) at different frequencies.

### Performance and recommendation trade-offs
- Dynamic model selection is the best overall performer.
- An ARIMA with trigonometric seasonality delivers the best performance/complexity compromise among first-tier models.
- The ARIMA with trigonometric seasonality:
  - Is parsimonious and straightforward to specify.
  - Outperforms ARIMA with binary seasonality substantially.
- While second-tier aggregation/selection improves accuracy, the extra complexity may not justify operational adoption; CBJ could prefer the trigonometric ARIMA for near-term operational use.

### Alternative strategies evaluated
- Aggregating forecasts at different frequencies (daily, weekly, monthly, quarterly) and forecasting banknotes by denomination were explored.
- These frontier strategies did not provide significant forecasting gains relative to their high complexity; not recommended.

### Software and capacity building
- The IMF provided a fully automated software infrastructure implemented in R.
- The code is documented and produces charts and tables on the fly.
- IMF experts trained CBJ staff on software use for operational forecasting.

---

### Key Recommendations (Table 1 summary)
- Use a trigonometric ARIMA instead of a binary ARIMA (Authority: CBJ) — Priority: High — Timeframe: Near-term
- Implement the two-tier forecasting framework and obtain the set of forecasts, leveraging the full range of models (Authority: CBJ) — Priority: Medium — Timeframe: Medium-term
- Produce monitoring forecasting reports and analyze the performance of the forecasts at a regular interval (Authority: CBJ) — Priority: Medium — Timeframe: Medium-term
- Publish the methodology to strengthen the transparence and the credibility of the central bank (Authority: CBJ) — Priority: Medium — Timeframe: Medium-term

- Note: Near term: < 12 months; Medium term: 12 to 24 months.

---

### Introduction and Forecasting Framework (methodology highlights)

### Rationale
- More complex models fit training data better but risk overfitting and increased forecast volatility as new data arrive; complexity should be adopted only when it yields substantial forecasting gains.

### First-tier (individual models)
- Tested models include:
  - Basic models: random walk (naïve), exponential smoothing, ARIMA with binary seasonality.
  - Augmented versions: seasonality modeled trigonometrically and holidays/special events added.
  - Neural networks and TBATS were tested but excluded due to poor performance.
- The software infrastructure automates estimation and provides projections, parameters, in-sample fit, and out-of-sample performance metrics on the fly.

### Second-tier (model evaluation, selection, aggregation)
- Employs dynamic model selection and model aggregation techniques to improve accuracy over individual models.
- Benchmarks and model choices are based on out-of-sample performance metrics.

---

*IMF | Jordan Forecasting Framework for Currency in Circulation — Preface.*

### 11. The second-tier modeling framework uses dynamic selection to optimally select

### 11. The second-tier modeling framework uses dynamic selection to optimally select the best model and parametrization based on recent performances.

### Second-tier framework and model combination vs selection
- Purpose: build on the first-tier to improve forecasting accuracy of single models either by combining them or selecting them.
- Combination of models: averages forecasts of different models (potentially with different weights) to reduce modeling risk.
- Model selection: selects the most appropriate model based on recent performance (e.g., if last week a model outperformed alternatives, it is chosen this week).
- Advantage of selection: quickly adjusts to structural breaks by shifting toward the most appropriate model when necessary.

### Performance metrics and training/testing split
- Uses both in-sample information criteria and out-of-sample performance metrics to benchmark models.
- Out-of-sample procedure described:
  - Training group: 2010 to 2018
  - Testing group: 2018–2020
  - Models are fitted on 2010 to 2018 and then forecast 2018–2020 for performance assessment.
- Rationale: out-of-sample metrics reduce overfitting risk and provide an accurate picture of actual performance.

### Alternative forecasting frameworks explored (results)
- Cross-sectional aggregation across banknote denomination and temporal aggregation of different frequencies were investigated.
- Findings:
  - Granular modeling by denomination increases volatility of sub-series and, in Jordan's case, provides worse quality forecasts than forecasting total CiC time series.
  - Decomposing by frequency (yearly, quarterly, monthly, etc.) increases granularity and volatility and does not outperform forecasts on total CiC for Jordan.

### Key model-performance findings for Jordan
- Best-performing individual model: ARIMA with trigonometric seasonality.
  - Improves over ARIMA with binary seasonality used by the CBJ by modeling seasonality through sinusoidal functions instead of many indicator variables.
  - Described as parsimonious yet accurate; incremental improvement rather than radical change.
- Best-performing overall approach: dynamic model selection.
  - Embeds automatic re-parametrization to adjust to structural breaks and new developments.
  - Allows changing both model type and parameters each period, maximizing accuracy and reacting fast to structural breaks and seasonal changes.
  - Performs better than aggregation approaches that average “good” and “bad” models at every point in time.
- Trade-off and operational recommendation:
  - The gain in forecasting accuracy from dynamic model selection is relatively small compared to ARIMA with trigonometric seasonality.
  - ARIMA with trigonometric seasonality offers the best compromise between accuracy and parsimony and is therefore more appealing for CBJ daily operations.
  - If CBJ wishes to use the best approach available, dynamic model selection should be chosen.
  - The IMF team provided open-source software infrastructure to replicate the entire forecasting framework and results.

### Data pre-processing and treatment of missing values
- Data span provided by CBJ: January 6, 2007, to February 15, 2021.
- Dataset contains daily records of Currency Issued (CrI) and Currency in Circulation (CiC).
  - Observations complete for CrI for full span.
  - CiC observations started on November 1, 2018.
- Calendar of special events across sample years provided by authorities.
- Missing-value treatment:
  - Continuity in dates is essential; missing dates break periodicity and complicate seasonal estimation.
  - IMF team imputed missing values by linear interpolation from neighboring values.
  - Linear interpolation chosen for robustness and simplicity given scarcity of missing values.
  - Alternative: provide indicator variables for each missing value (mathematically equivalent to excluding observations).

### Handling weekends and working-day adjustments
- Model is fitted on five day weeks to tackle weekends.
  - Excludes all non-working days (Fridays and Saturdays) from the time series and further inputs.
  - Periodicity and seasonal-pattern estimation are retained.

### Structural breaks and non-stationarity
- For both CiC and CrI there is a substantial shift in the time series in response to the COVID-19 pandemic.
  - This shift is modeled using an indicator variable (0 before, 1 after).
- Strong evidence of non-stationarity for both time series.

### Indicator variables for holidays and policy/long-term effects
- Holidays captured by binary indicator variables with up to five days lead and lag effects.
  - Indicator = 1 when special event occurs across years, 0 otherwise.
  - For each indicator, the team constructed five lagged and five leading versions by shifting the indicator by appropriate periods.
  - Indicators constructed for future periods as well.
- Long-term or policy effects encoded as indicators equal to 1 after the effect starts and 0 before or once ended (no leads/lags unless constructed).
- Example illustration in the source: "Table 2. Jordan: Example of Two Lags and Two Leads From a Binary Indicator Variable" (period/indicator/lag 1/lag 2/lead 1/lead 2).

### Modeling multiple seasonalities and encoding choices
- Multiple seasonal cycles incorporated: day in the week, day in the month, and day in the year.
- Three elements when modeling multiple seasonalities: length of seasonal cycles, their encoding, and encoding efficiency (parsimony).
- Day-in-week seasonality: five days in the week (weekends removed).
- Day-in-month seasonality: months have different days, so seasonality locked to a quarter (a quarter contains a fixed number of weeks/days).
- Seasonal visualization: Figure 3 shows seasonal plots (top row line plots, bottom row boxplots) for Currency Issued; CiC plots similar.

### Trigonometric encoding of seasonal cycles (technical encoding)
- Each seasonal cycle encoded using trigonometric indicator variables.
- Given length of a season of ss periods, the team constructed ss/2 pairs of trigonometric variables, with i = 1,..., ss/2:
  - di = cos(2 i π t / ss)
  - di+ss/2 = sin(2 i π t / ss)
  - where t = 1,..., ss with ss being the sample size.
- When ss is an odd number, round up ss/2 to the closest integer.
- Trigonometric encoding is mathematically equivalent to using s binary indicator variables; in some cases one indicator corresponds to a constant, resulting in ss − 1 informative indicator variables.
- Advantage: can encode complex seasonal effects such as leap years (e.g., set ss = 365.25 rather than 365). Example: for day in the year there will be 365/2 cosines and 365/2 sines when using integer ss.

### Filtering seasonal indicators for parsimony
- Two-step filtering approach:
  1. Fit a simple ARIMA on the time series (with automatically identified AR and MA terms and any policy-effect indicators). Use residuals of that ARIMA as target.
  2. Jointly estimate inclusion of day-in-week and day-in-quarter trigonometric dummies with stepwise regression based on Akaike’s Information Criterion (AIC).
- Use Lasso regression to eliminate superfluous terms for annual seasonality due to high number of indicators.
- After filtering two groups of trigonometric dummies, pool and refilter using AIC stepwise regression to exclude redundant variables.
- Note: procedure robust to different choices of information criterion.

### Advantages of trigonometric vs binary seasonal encoding
- Using all indicators, binary and trigonometric variables (for integer ss) give the same output.
- When superfluous terms are eliminated:
  - Binary encoding can omit all seasonal information for that period.
  - Trigonometric encoding provides a smoother approximation and efficient sparse approximation of seasonal patterns (illustrated in Figure 4).

### Selection of special-event indicators
- Chosen using an AIC stepwise regression similar to seasonality selection.
- Each indicator with its leads and lags is potentially filtered; after first-step filtering, all indicators are pooled and one last stepwise selection is performed.
- Target series for this process: residuals of an ARIMA with automatically specified orders including policy-effect indicators and trigonometric indicators.
- Seasonal indicators selected first, then special-event indicators (seasonal indicators typically explain more variance).

### First-tier: individual forecasting models and automatic specification
- Benchmark models used:
  - Naïve model (a random walk)
  - Automatically specified Exponential Smoothing (ETS)
  - Automatically specified ARIMA (term ARIMA also includes Seasonal ARIMA from automatic specification)
- Automatic specification uses AIC.
- Time series are differenced as needed to become level stationary; no seasonal differences are used.
- KPSS test used to identify appropriate level differencing.
- For ETS and ARIMA only the day-in-week seasonality is modeled in benchmarks.
- Exponential smoothing relies on state-space formulation enabling maximum likelihood estimation and automatic model selection.

### Advanced models and augmentations
- Augmented models include multiple seasonalities and inputs for special and policy events:
  - ETStrig (augmented ETS with trigonometric seasonality)
  - ARIMAtrigA and ARIMAtrigB (two augmented ARIMA variants)
    - ARIMAtrigA (forecast package for R): sequential estimation of parameters for indicators and ARMA orders; simpler specification but potentially biased parameters.
    - ARIMAtrigB (smooth package for R): simultaneous estimation; avoids bias but has more complex specification.

### Models tested and excluded
- NN-ELM (neural network extreme learning machine) and TBATS were tested but performed poorly and removed:
  - NN-ELM: feedforward extreme learning machine; ensemble of 20 networks using median operator; provided unreliable forecasts for CrI and CiC.
  - TBATS: encodes seasonality with trigonometric representation and allows ARMA errors and pre-transformation; cannot introduce external variables such as special-event indicators; faced substantial difficulties with non-stationarity and COVID-19 shift.
- Both NN-ELM and TBATS are consistently outperformed by advanced models and were excluded due to poor performance and substantial computational cost.

### Temporal Hierarchy Forecasting (THieF)
- THieF considered to augment model forecasts and capture different seasonal components:
  - Temporal aggregation can extract components that standard procedures may overlook (e.g., seasonality dominates at monthly frequency, long-term dynamics emerge at annual aggregation).
  - Temporal hierarchies can help recover valuable information carried by components with minimal variance at the original sampling frequency.

*Italic source attribution: IMF | Jordan Forecasting Framework for Currency in Circulation | Chapters 11–First-tier modeling (extracted content).*

### 30. THIeF also reduces modeling risks associated with the use of single models.

### 30. THIeF also reduces modeling risks associated with the use of single models.

### Temporal hierarchies (THieF) and model diversity
- THieF combines alternative models produced from temporally aggregating a time series to reduce modeling risk arising from specification and selection of a single model.
- Aggregation levels considered: 1, 2, 4, 5, 10, 13, 20, 26, 52, 65, 130, and 260 (number of days for aggregation).
  - Due to five-day weeks, aggregation over 260 days corresponds approximately to complete years, while 65 corresponds to quarters.
- Structural scaling is used to obtain combination weights for forecasts produced at different aggregation levels.
- For the CiC (currency in circulation) time series, due to limited sample size (series starts at the end of 2018), only the first eight aggregation levels are used; very aggregate levels have too few observations. The sample size is not a restriction for the CrI (currency issued).
- References for methodology: Athanasopoulos et al. (2017) and Kourentzes and Athanasopoulos (2021).

### Model evaluation, selection, and combination (methodology)
- Out-of-sample rolling origin forecasts with five day ahead forecasts; the last 100 days retained as test set.
  - Training set iteratively increases by one observation to produce forecasts for successive five-day windows until test set exhausted.
- Metrics:
  - Mean and median Root Mean Squared Error (RMSE) across forecast origins used to evaluate accuracy.
  - Mean and median RMSE comparison: similar values imply stable forecasts across origins; large differences (especially mean >> median) imply unreliable forecasts with extreme errors.
- Dynamic model selection:
  - Performance tracking uses mean RMSE of the t+1 to t+5 forecasts over the last five forecast origins (window of five-period origins is used).
  - Five-period window balances mitigation of randomness and retention of recent observations.
- Forecast combination:
  - Equal weights used to combine forecasts to limit estimation errors in weights.
  - Combination reduces reliance on any single potentially inappropriate forecast.
- Forecast pooling:
  - Pooling selects only well-performing forecasts (restricted to top-performing models) to offset variability from selection and combination.
  - Pool excludes Naïve (Random Walk) and limits pool to models that capture partial or complete seasonal information to preserve diversity.

### Empirical results (summary of reported tables and tests)
- Currency issued (Table 3) — selected metrics (5 days and 24 days forecasts shown as Mean RMSE, Median RMSE, Mean Rank):
  - Naïve: 5 days Mean RMSE 29.62, Median RMSE 19.35, Mean Rank 4.70; 24 days Mean RMSE 49.27, Median RMSE 35.89, Mean Rank 4.34
  - ETS: 5 days 30.31, 21.94, 4.70; 24 days 56.93, 40.11, 4.94
  - ARIMA: 5 days 30.77, 23.14, 5.01; 24 days 54.44, 39.87, 4.73
  - ETStrig: 5 days 28.30, 18.15, 4.54; 24 days 64.45, 54.31, 5.54
  - ARIMAtrigA: 5 days 26.37, 18.27, 4.36; 24 days 48.21, 36.90, 4.31
  - ARIMAtrigB: 5 days 26.49, 19.58, 4.44; 24 days 46.58, 35.52, 4.27
  - Select: 5 days 24.79, 16.26, 4.03; 24 days 42.13, 30.91, 3.72
  - Combine: 5 days 25.96, 19.07, 4.22; 24 days 46.61, 34.88, 4.16
- Key findings for currency issued:
  - ARIMAtrigA, ARIMAtrigB, and dynamic selection perform best overall.
  - Naïve benchmark is very competitive; ETStrig underperforms for longer horizons.
  - Differences between mean and median RMSE indicate multiple outlying forecast errors; mean rank useful for ranking.
  - For 5-day horizon ARIMAtrigA is best among single models; selection and combination perform better with selection best. Dynamic selection best for longer-term forecasts.
  - Including indicators for special days improves accuracy for eligible forecasts.

- Currency in circulation (CiC) (Table 4) — selected metrics:
  - Naïve: 5 days Mean RMSE 39.82, Median RMSE 29.49, Mean Rank 4.82; 24 days Mean RMSE 54.82, Median RMSE 42.79, Mean Rank 4.17
  - ETS: 5 days 42.09, 29.78, 4.81; 24 days 66.44, 51.65, 4.91
  - ARIMA: 5 days 42.21, 34.43, 5.49; 24 days 65.71, 49.56, 5.08
  - ETStrig: 5 days 38.96, 28.40, 4.97; 24 days 97.98, 87.97, 6.37
  - ARIMAtrigA: 5 days 31.50, 22.30, 4.54; 24 days 50.45, 40.51, 4.34
  - ARIMAtrigB: 5 days 27.92, 18.42, 3.83; 24 days 47.83, 33.00, 3.79
  - Select: 5 days 26.01, 16.92, 3.64; 24 days 44.49, 29.36, 3.63
  - Combine: 5 days 29.11, 20.01, 3.90; 24 days 45.07, 30.56, 3.70
- Key findings for CiC:
  - Dynamic selection provides the best results consistently across horizons and metrics.
  - ARIMAtrigB yields best mean rank of a single forecast for both horizons.
  - Selection and combination outperform single-model forecasts.
  - Including indicators for calendar events is beneficial short term but adds limited or marginally negative value at longer horizons (pattern differs from currency issued due to different sample sizes).

- Statistical testing and significance:
  - Non-parametric testing used (Friedman and Nemenyi post-hoc tests) at 5 percent significance.
  - Mean ranks and critical distances identify groups of forecasts with no evidence of significant difference.
  - For 5-day forecasts: benchmarks differ significantly while advanced models perform well.
  - For longer-term forecasts: dynamic model selection exhibits significantly different (better) accuracy than the rest.
  - Figures 5 and 6 (Nemenyi test visualizations) support these conclusions.

### Impact of THieF (Table 5) — difference in performance using temporal hierarchies for Currency in Circulation
- Accuracy difference (5-days; 24 days) for Mean RMSE and Median RMSE — differences reported for ARIMAtrigB, Select, and Combine:
  - ARIMAtrigB: 5-days Mean RMSE 0.53, Median RMSE -0.30; 24 days Mean RMSE 4.14, Median RMSE 2.12
  - Select: 5-days Mean RMSE -3.04, Median RMSE -4.08; 24 days Mean RMSE 5.20, Median RMSE 3.42
  - Combine: 5-days Mean RMSE 1.76, Median RMSE -0.21; 24 days Mean RMSE 7.10, Median RMSE 2.17
- Interpretation:
  - Marginal gains in Mean RMSE in the short-term but losses in the median for some methods.
  - For the long-term, THieF exhibits consistent gains in performance.
  - THieF documented to provide most gains for longer-term forecasts.
  - IMF team recommendation: against routine usage of temporal hierarchies for this application because increased complexity yields only modest gains in accuracy.

### Forecast uncertainty, operational recommendations, and software
- Probabilistic forecasts:
  - ARIMA with trigonometric seasonality and dynamic model selection provide prediction intervals.
  - Example intervals used: 80 percent, 90 percent, and 95 percent prediction intervals (Figure 7).
  - Forecast combination does not readily provide analytical prediction intervals, though empirical intervals could be calculated.
- Operational guidance for authorities:
  - Regularly operate the ARIMA with trigonometric seasonality model for daily use.
  - Update parameters of all models once a month—or when a structural break occurs—by executing the full re-estimation script (computationally time-consuming).
  - For daily operations, run the preferred single model (e.g., ARIMA with trigonometric seasonality) with previously estimated parameters; single model forecasts run in a few seconds and can be executed daily.
- Enhancements:
  - Incorporate central bank experts’ granular knowledge to improve construction and selection of indicators for special and policy events.
  - IMF team followed an agnostic, data-driven approach; contextual data and expertise can further refine modeling choices.

*Source: IMF staff*

### 1. Read in the specified Excel or csv files from the rawdatafile parameter in the

### 1jorea2022002 - 1. Read in the specified Excel or csv files from the rawdatafile parameter in the

### Data preprocessing (initial script / step 0)
- Read in the specified Excel or csv files from the rawdatafile parameter in the config file.
- Set the start and end dates and remove bad dates based on the config file parameters.
- Add a column datatype with values of data, holiday, and imputed.
- Remove weekends based on the exclude_days parameter in the config file.
- Linearly interpolate any dates that are missing in the data.
- Save the output as specified by the dataclean parameter in the config file.
- Create a plot of the target variable and save as PDF file.
- Notes on input format:
  - Original input file(s) should have dates in the first column.
  - The target variable column should be specified by the targetcol parameter in the config file.
  - In the simplest case, the file will have two columns, one for the date and another for the target variable, with targetcol being 2.

### Step 1 — Adding Features (step_001_features.R)
- Read in the cleaned csv file from step 0.
- Generate daily biases for each day of the week.
- Generate trigonometric biases for each day of the month.
- Generate trigonometric biases for each day of the year.
- Add structural breaks based on the structural_breaks parameter in the config file.
- Add bias terms around the 20th of each month.
- Add bias terms for the quarter.
- Combine all of the bias terms with the data and save as specified by the dataFeat parameter in the config file.
- Plot all features and save as PDF files.
- Technical notes:
  - Bias terms model seasonalities (e.g., weekday effects). If there are N weekdays used (typically with N=5), then there will be N-1 biases so each weekday gets a unique bias.
  - Structural breaks can be modeled as different biases via the structural_breaks parameter.
  - All biases are combined with the original data and saved as a csv file.

### Step 2 — Fitting the Model (step_002_model.R)
- Read in the csv output from step 1 containing the data and all features (biases).
- Create a matrix of features.
- Run the function forecastLoop that runs all models specified in the config file over a range of dates.
- Save the forecasted results as an Excel file.
- forecastLoop inputs and behavior:
  - Inputs: list of index values to run on, the data Y, the length of the validation set testLength, the forecast horizon horizon, the dates in the data dates, a matrix of features for each date X, and the models given by modelLabels.
  - Iterates over index values; for each index it generates a forecast for that date using all models in modelLabels.
  - Treats each forecast date independently.
  - modelLabels controls which models are run.
- Models available (as implemented):
  1. Naive — assumes a random walk; forecasts future values with the most recent value (benchmark).
  2. SNaive — “Seasonal Naïve”; uses base frequency (typically five days per week) and the five most recent values repeatedly.
  3. ETS — “ExponenTial Smoothing”; autoregression with coefficients weighted more heavily to recent dates.
  4. ARIMA — auto.arima used to select best ARIMA within specified max.d, max.p, max.q.
  5. ETSfeat — ETS with externally specified features (seasonal biases from step 1).
  6. ARIMAfeat — ARIMA with external features (seasonal biases from step 1).
  7. ARIMAtrigB — alternate ARIMAfeat using a state-space ARIMA model.
  8. TBATS — exponential smoothing state-space model with Box-Cox transformation.
  9. TBATSfeat — two-step: exponential smoothing for overall shape, then TBATS on residuals.
- Once all models are fit for all periods, forecast results are saved as an Excel file.

### Step 3 — Summarizing the Results (step_003_summary.R)
- Read in the Excel file of forecasts.
- Calculate the errors between the true values and the forecasts.
- Calculate the RMSE (root mean square error) for each model.
- Calculate further composite models:
  - Select the “best” model based on best rolling error of each model for several dates leading up to the forecast date (choose model with smallest errors).
  - Take the mean of several models.
- Write out the results of the RMSE calculation as a csv file.
- Plot the RMSE values and save as PDF.
- Plot the forecast values together with the original data.
- Produce a merged PDF of forecast plots and data with each page showing different forecast origins for visual inspection.

### Annex II — User guide and R environment setup (IMF R Programs/Libraries)
- R / RStudio:
  - Recommended R versions: 4.1.0 or 4.1.1.
  - RStudio download referenced at https://www.rstudio.com/.
- Zipped third-party libraries:
  - All third-party libraries used are zipped together as library_JOR.zip (approximately 197 MB).
  - Recommended to unzip and place the folder on a common network location (mapped drive) for shared access (example path pattern \\sharedrive\IMF\library).
- Setting up R library path:
  - Add at the beginning of each R script:
    - .Library.site <- file.path("Z:/library")
    - .libPaths(.Library.site)
  - Replace Z:/library with the mapped/unzipped location.
  - This ensures the mapped path appears first in .libPaths() while preserving original library locations.
- Running the R scripts:
  - After adding the .libPaths configuration lines, scripts can be run in RStudio via the Source button.
- Contact for help with the code:
  - Kei Moriya (kmoriya@imf.org)
  - Romain Lafarguette (rlafarguette@imf.org)
  - Additional contact in Annex II header: Kei Moriya, Adeleke Adeyemi (IMF, IT Department) and contact aadeyemi@imf.org mentioned in Annex II.

*IMF | Jordan Forecasting Framework for Currency in Circulation — user guide and R code instructions*

---


_Source: https://www.imf.org/-/media/files/publications/cr/2022/english/1jorea2022002.pdf_
