Both the historical economic data and the forecasts (in the scenarios dataset) are prepared before being used to predict the z-score.

![Macrodata Preparation Zone.png](ntZDjuWTcdQu)

First, the two datasets are stacked together to run the transformations on both of them at the same time. Then, in the [prepare recipe ](recipe:compute_macro_data_time), the quarter column is created. Initially the data was at a monthly level, but it is needed at a quarterly level to match the loan performance dataset. The [group by recipe](recipe:compute_macro_data_quarterly) agregates data at a quartely level, taking the average of the economic variables over the quarter, and the last date as a reference date.

Finally, on one side the [prepare recipe ](recipe:compute_macro_data_quarterly_prepared) folds the data to enable to plot all the economic series on the same chart. On the other side, lags are computed for each of the series using a [windows recipe](recipe:compute_macro_data_quarterly_windows) and the dataset is split back into historical data and scenarios.