A code repository to reproduce the results presented in the paper Over the Stability Space of a Multivariate Time Series.
The repository contains four main directories:
source: This directory contains the source code for the algorithms implemented based on the article Over the Stability Space of a Multivariate Time Series. It includes the following files:
vectorial_methods.R: Implements the three methodologies proposed in the article for estimating the stable space of a multivariate time series.
simulations.R: Contains the main functions required to reproduce the simulation study presented in the article.
auxiliar_methods.R: Includes auxiliary functions for visualisation and error estimation.
-
notebooks: This directory contains Jupyter notebooks that demonstrate the use of the source code and provide step-by-step instructions to reproduce the various tables and figures from the paper. -
databases: Contains all datasets used in thenotebooksdirectory, including those for the practical examples. -
images: Contains the exact images used in the article. These can be reproduced using the notebooks, with some light post-processing. For instance,Figure_1.pngandFigure_2.pngare the result of running the notebookstability_space.ipynbfour times and then combining the corresponding images.
To run the notebooks in the notebooks directory and the scripts in the source directory, use R version 4.1.2.
Enjoy it ☕
Suppose we want to estimate the stability space of the following dataset using the three methodologies proposed in the article:
dt_inflation <- data.table::fread("../databases/variables_inflation.csv")First, we define the input matrices for each method:
X_inflation <- as.matrix(dt_inflation, rownames = "Date")
rownames(X_inflation) <- NULLThen, we run the following code lines—each corresponds to one of the methods:
# PLS, PCA
basis_inflation_PLS <- basis_stable(X_inflation, method = "pls")
basis_inflation_PCA <- basis_stable(scale(X_inflation), method="pca")
# SPCA
spca_para <- 1
basis_inflation_SPCA <- basis_stable(scale(X_inflation),method = "spca",
spca_engine = "elasticnet",
spca_sparse = "penalty",
spca_para = spca_para)
# Johansen
basis_inflation_johansen <- basis_stable(X_inflation, method = "johansen")Each basis_inflation_... object contains two elements: basis_S and basis_N, which represent the estimators of the stable space and the non-stable space basis, respectively.
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add a new feature'). - Push to the branch (
git push origin feature-branch). - Open a Pull Request.
This project is licensed under the MIT License – see the LICENSE file for details.