# Central Banks Notes

## What's New in MATLAB for Economists?

Discover the latest features in MATLAB that help economists work with new models and low-code workflows. From econometric modeling to data cleaning and visualization, explore the tools and capabilities that help you gain insights and make more informed decisions in your research and analysis.

## Econometrics

### Using the Econometrics Modeler App

The Econometric Modeler app lets you perform cointegration tests on multiple time series using the Engle-Granger or Johansen cointegration tests. After evaluating cointegrating relationships among the series, you can fit vector autoregression (VAR) models with optional exogenous variables (VARX) or vector error-correction (VEC) models. Like univariate models, you can export variables to the workspace in MATLAB and generate code or reports summarizing your sessions.

For more information, refer to the Econometric Modeler App Overview.

### Creating Bayesian state-space models

The Bayesian state-space model (`bssm` object) framework lets you select from various non-Gaussian distributions for the conditional distribution of observation innovations, including Gaussian and Student's t distributions. This flexibility is beneficial when dealing with process or measurement errors that have excess kurtosis (fat-tailed or leptokurtic), display stochastic volatility, or exhibit skewness.

You can analyze linearized DSGE models by using Bayesian state-space model tools in Econometrics Toolbox to perform four main tasks:

1. Simulate data from a known state-space model
2. Estimate posterior moments of model parameters
3. Characterize the model's dynamic behavior
4. Forecast response variables

### Analyzing posterior distributions of random parameters in multivariate linear state-space models

Econometrics Toolbox offers Bayesian state-space models for analyzing multivariate time series data from a Bayesian perspective. The `bssm` function creates a model that characterizes the joint prior  distribution on state and observation equation parameters, including coefficient, state-disturbance-loading, and observation-innovation matrices.

You can create a Bayesian state-space model in two ways: convert a standard state-space model (`ssm` object) using the `ssm2bssm` function or provide a parameter-to-matrix mapping function and prior distribution of parameters to the `bssm` function.

After creating the model, you can combine it with data to form and analyze the posterior distribution, which assumes that state disturbances and observation innovations are multivariate Gaussian random variables with a mean of 0. The framework employs Metropolis-Hastings for sampling, as the posterior distribution lacks a closed form. Functions for forming and analyzing the posterior distribution include:

• Estimate (estimating posterior moments)
• Simulate (drawing random state-space model parameters)
• Tune (computing proposal distributions for the Metropolis-Hasting sampler)

## Choosing Business Cycle Filters

With Econometrics Toolbox, you can choose from three business cycle filters for time series data analysis, including Baxter-King, Christiano-Fitzgerald, and Hamilton filters. These filters complement the Hodrick-Prescott filter function and provide customizable tuning parameters. You can also plot the smoothed trend component alongside input data.

The time series decomposition example for choosing a time series filter for business cycle analysis compares the performance of the Hodrick-Prescott filter with Baxter-King, Christiano-Fitzgerald, one-sided Hodrick-Prescott, and Hamilton filters in the context of various economic data-generating processes. This example can help you decide on the best filter for your specific business cycle analysis needs.

## Core MATLAB

### Timetable events

To find and label events in a timetable, MATLAB lets you attach an event table, which is a timetable of events containing event time, length, label, and sometimes additional information. Attaching an event table lets you identify or label rows occurring during events in the timetable. MATLAB offers functions such as `eventtable`, `extractevents`, `eventfilter`, `syncevents` for creating event tables from input data, filtering timetable rows based on event times, and synchronizing events with timetables.

### Detrending data

##### Detrending tabular data

You can use the `detrend` function in MATLAB for detrending data in a table or timetable. You can specify tabular variables to detrend using the `DataVariables` name-value argument and append or replace variables containing detrended data using the `ReplaceValues` name-value argument. You can also specify sample points as a table variable using the `SamplePoints` name-value argument, though this is not supported when input data is a timetable. This function provides a simple yet effective tool for removing trends from data sets.

### Removing trends live editor task

The Find and Remove Trends task in the Live Editor offers improved functionality for interactively finding and removing periodic and polynomial trends. The task can identify periodic trends for regularly spaced input data, with the ability to select the Singular Spectrum Analysis (SSA) or Seasonal Trend Decomposition Using Loess (STL) algorithm for the Periodic trend type. You can also output polynomial and periodic trends, in addition to detrended data by specifying Output as Trends.

## Using Pivot Tables for MATLAB

The `pivot` function in MATLAB provides a convenient way for you to summarize tabular data using a pivot table. You can perform a pivoting operation on data in a table or timetable by specifying grouping variables with `colvars` or `rowvars`. You can also customize the operation by identifying additional name-value arguments, such as the data variable, function to apply to the data variable, and grouping variable binning schemes. This function provides a tool for organizing and summarizing complex data sets.

## Cleaning Data

The Data Cleaner app in MATLAB lets you:

• Access and import column-oriented data from a file or the workspace in MATLAB
• Explore data using visualization, data, and summary views
• Sort, rename, or remove variables
• Retime data in a timetable, stack or unstack table variables, clean missing or outlier data, smooth data, or normalize data
• Edit previously performed cleaning steps using the Cleaning Steps panel
• Export cleaned data to the workspace in MATLAB or as a script or function

## Working with Python

MATLAB Editor now includes support for Python® files, enabling you to view and edit Python code with syntax highlighting for keywords, strings, comments, and errors. MATLAB Editor also includes auto-indenting functionality and highlights matched and mismatched delimiters, such as parentheses, brackets, and braces, making it easier to write and debug Python code within the MATLAB environment.

If you're an economist looking to enhance your data analysis, modeling, and visualization workflows, MATLAB can help you achieve your goals. To learn more, visit MATLAB for Central Banks.