Case #5

Calculating the standard deviation interval around a mean

Objective

Calculating the mean of a series and standard deviation bands

Adding recession bands

Adding the last value of a series on the Y-axis

Solution

If you get stuck, use the worksheet to see what to do next.

If you need more detailed help, have a look at the learning resources below.

The Macrobond document is also available for download here.

Worksheet

Learning resources for this case

Statistics analysis

Graph layout

Worksheet – Case #4 – Calculating the mean of a series for several time periods

Finding Data

To find the time series used in this example we will access the tree by Country & Region as most global commodity spot prices can be found under the region World.

Go to:

Country & Region > World > Commodities & Energy > Spot Prices > Energy > Crude Oil.

Locate and add:

  • World, Crude Oil, Brent, Spot, FOB North Sea, ICE, Close, USD

You can also use the short code by simply writing “oil” in the expression box in “Series list”.

Data Preparation

Changing frequency

The oil price is originally a daily series. In the chart displayed, we decided to use a monthly frequency to make the chart easier to read. To do so:

  • Select “Series list” in the tree
  • Click on the drop-down “Frequency” setting
  • Change the frequency from “Highest (daily)” to “Monthly”

To control how the frequency conversion is done, you can:

  • Go to the “Conversion settings” tab
  • Select the method of your choice under “to Lower frequency conversion method”

Analysis

Statistics

If you wish to calculate the mean of a specific series, you should use the Statistics analysis.

  • Select “Time chart” in the tree
  • Click on “Insert” and choose Statistics
  • In the Statistics Analysis, click on the “Add” button and select "Mean” as calculation.

Now, add four mean-calculations to the document. The date ranges used are:

From To
1986 2004
2005 2009
2010 2013
2014

Note! To limit the graph lines to the period over which the mean is calculated you must uncheck the Extrapolate tick-box for each calculation.

Charting

Adding value labels

In this case, we’ve added observation labels for each mean, displaying the value and the period. You can create them manually one by one, but you can also automate the process, using dynamic properties.

First, create one observation label, which will be used later a default.

  • In “Time chart”, select “Chart annotations” at the top
  • Select Observation label under “Annotations”
  • Click on one of the mean-lines in the graph to add the observation label to it.

Next step is to edit the text. To automate the process, you should:

  • Click once on the observation label
  • Look up to Presentation Properties > Text > and click on “Edit Default”

You should write a text structured as: [analysis]: [value]$. In the new window, you should use dynamic properties:

  • Delete the current text
  • Go to the dynamic properties' menu on the right side
  • Add “Analysis Description” from the branch “current”
  • Add then “value” from the branch “current”, and add the sign $ at the end.

This is how the expression will look like: {s .AnalysesDescription}: {s .Value} $

You can now close the window. Your next step is to duplicate this observation label for the other mean series.

You can simply use a copy/paste function:

  • Right click on the observation label you just created, and select “copy”
  • Right click on another mean series, and select paste
  • Repeat the process for each mean series.

Other changes

  • The title has been edited
  • The legend has been removed

Case #4

Calculating the mean of a series for several time periods

Objectives

Changing the frequency of the document

Using Statistics to calculate the mean of the series for several time periods.

Creating several observation labels displaying the same information

Solution

If you get stuck, use the worksheet to see what to do next.

If you need more detailed help, have a look at the learning resources below.

The Macrobond document is also available for download here.

Worksheet

Learning resources for this case

Changing the frequency of a series

Working with Observation labels

Graph layout

Dynamic Text

 

Case #3

Building a simple regression model

Objective

Performing a simple regression analysis

Adding a pane to the chart

Using dynamic properties to adjust an observation label

Solution

If you get stuck, use the worksheet to see what to do next.

If you need more detailed help, have a look at the learning resources below.

The Macrobond document is also available for download here.

Worksheet

Learning resources for this case

Regression analysis

Using chart panes

Working with Observation labels

Dynamic text

Graph layout

Worksheet – Case #3 – Building a simple regression model

Finding Data 

In this case, we will reuse the document from Step 1 Case #9 which can be downloaded here. As such, all data needed for the exercise will already be in the document. 

Analysis

Regression

In the case #10 from Level 1, we established that the ISM PMI is a leading indicator of the Industrial Production in the US, by 4 months.  

Now, you will have to build a regression model using this information.  

Remember that the correlation results were based using a data sample starting in 2000-01. 

  • Select “Rate of change” in the tree 
  • Click on “Add” and choose Regression 

The first step will be to set the model and the outputs needed: 

  • Set the Start range to 2000 
  • Check the tick-box “Output the dependent series” 
  • In the output, include “Residuals” and “Residuals for forecast” 

Now, you should set the model itself: you want to explain the Industrial Production by the ISM PMI.  

  • Check “Include for both series” 
  • Pick Industrial Production as the dependent series 

Also, the best correlation between the two series was when the ISM PMI was lagged by 4 months. You should include this in the model: 

  • For the ISM PMI, Set “Lag from” and “Lag to” to 4 

Finally, and since you are lagging the explanatory series, you can calculate forecasts (for 4 months).  

  • Tick the box “Calculate forecasts” 

Regression Report  

As default, you always get a Report as first output of the regression analysis. You can check here several econometric statistics as well as the equation of the model.  

Charting 

  • Add a “Time Chart” after the Regression analysis 

Adding a separate pane

In our chart, we displayed the residuals in a secondary chart, below the main one. In Macrobond, we call this “Panes”. To add panes, you should: 

  • Go to Graph Layout 
  • Click on “Add pane” 
  • Drag the “residuals” time series to the new pane 
  • Change its type from “Line” to “Column” 

You can also automatically set the proportion of the panes.  

  • For our case, click on the 3rd option from the right (2:1) 

(You can also manually adjust the ratio between the two panes by dragging the lower edge of upper chart up or down) 

Adding a title to the lower pane

Each Pane can have subtitles.  

We begin by removing the redundant “%” sign on the lower pane: 

  • Click on it and hit delete.  

Now, click on the background of the lower chart 

  • In “Presentation properties” Locate “Subtitle” in the “Elements group”, click on Edit… 
  • Having added your desired text, click on it and adjust the settings in “Presentation properties” to center the text 

Customizing an observation label

We will now briefly explore Dynamic properties to customize a text in Macrobond. First, add a chart annotation to the Industrial production: 

  • Go to the “Chart annotations” tab 
  • Choose “Observation label” 
  • Click on the last observation of the predicted series 

To edit the text: 

  • Double-click the newly created observation label 
  • Change the text to: “Forecast for” 

Then, add dynamic properties after this text:  

  • Open the dynamic properties menu, on the right 
  • In the tree, add “Current > Date” with the red + sign 
  • Go to a new line, and add “Current > Value”, followed by a ‘%’ sign 

Finally, you can edit the format of the dynamic text: 

  • Click on the expression “{s.Date} 
  • Change the format to “Y”, using the drop-down menu 

This will change the date-format to displaying the name of the month instead of the number.  

However, right now, this observation label is associated to a specific date. You might want to always refer to the last predicted value when the chart will be updated. To remedy this:  

  • Click on the observation label 
  • On the “Presentation properties” tab, locate “Range” 
  • Change both the start and end of the interval to +0 

The observation label will now always point to the last value of the Industrial Production series, and the text created using dynamic properties will also get updated automatically.  

Other changes:

  • Chart title 
  • Legend text 
  • Legend position 
  • Y-axis text for the top pane 

Case #2

Using Slice to look at the seasonal pattern of a series &

using Change Region to replicate a file for another country.

Objectives

Calculating the monthly performance of a series over time 

Using Slice to create one series per year 

Using Cross Section to calculate the average of the sliced series 

Using Change Region to replicate the file for another country 

Solution

If you get stuck, use the worksheet to see what to do next.  

If you need more detailed help, have a look at the learning resources below. 

The Macrobond document is also available for download here. 

Worksheet

Learning resources for this case

Category chart

Rate of change analysis

Cross section analysis

Slice analysis

Changing the frequency of a series

Change region

 

Worksheet – Case #2 – Using Slice to look at the seasonal pattern of a series & using Change Region to replicate a file for another country.

Finding Data

In this case, you will have to use the S&P 500 index. 

Using the data tree, you can locate the data here: 

Country & Region > United States > Equity Market > Equity Indices > S&P > 500 > Composite > Price return 

Add: 

  • Index (highlighted with an exclamation mark) 

You can also directly type its short code as Expression in Series List: spx 

Data preparation

You first need to calculate the monthly returns (in %) of the series, meaning that you are looking for one value per month. However, the original series is in a daily frequency. Therefore, you will have to make some adjustments in Series List: 

  • Select “Series list” in the tree 
  • Go to “Frequency” and choose Monthly 
  • Go to the “Conversion Settings” tab and choose Last for “To lower frequency conversion method” 

The series will become a monthly one, using the last value in each month. 

Analysis

Rate of change 

To calculate the monthly return, you will have to use the Rate of Change analysis: 

  • Select “Time chart” in the tree 
  • Click on “Insert” and choose Rate of change 
  • Change “Method” to be Change over period % 
  • Set the “Length” to 1 month 

Slice 

Next step is to create one series for each year, the S&P series stating in 1928.  

  • Select “Rate of change” in the tree 
  • Click on “Add” and choose Slice

In the Slice analysis, just make sure that “Periods” is set to Year. 

Cross section

You now have one category series for each year, starting in 1928, with values going from January to December. What you would like is now to calculate the average for each month. Since you are working with a large set of series, you should use Cross Section: 

  • Select “Slice” in the tree 
  • Click on “Add” and choose Cross section 
  • In “Calculations, click on “Add” and choose Mean 

In the chart, we are comparing the average with 2018 values. Following these steps will output the average versus the 2018 year. Please note that average values on our screenshot will differ from the one you are making.

Click on the series' name to see all year-series. Exclude year 2018 from the calculation by unticking “include” for the last series in the list.

  • Untick the setting “include only observation where there are values for all series” 

For instance, the series for 1928 only starts in February. If you do not untick the setting the Application will not calculate a value for January.  

 

Charting

Add a Category chart after Cross Section. 

Graph Layout

To display the series as columns: 

  • Go to Graph Layout 
  • Change “Line to “Column” 

Adjusting the columns’ margin

To change the width of the columns and the space between them, 

  • Click on one of them 
  • In “Presentation properties” change “Group margin” to 30% 
  • Change “Margin” to None 

Other changes

  • The legends have been edited, and placed in the chart.  
  • Title: United States: S&P 500 average monthly performance since 1928 
  • Axis synchronization: Value  

Changing region

You might want to look at the same chart for another equity market. Instead of recreating the analyses from scratch, you can first duplicate the file: 

  • Click on "File" at the top left corner 
  • Select "Duplicate" 

You now have an exact copy of the document. The next step is to change the region of the series: 

  • Click on "File" again 
  • Select "Change region..." 
  • From the drop-down menu, select the new region you are interested in, for instance United Kingdom to look at the FTSE. 
  • Click on "Apply" 

This will change the original series used in the document while keeping the exact structure and analyses applied. You might however do a few manual changes in this specific case: 

  • In Cross Section: making sure the current year is not included in the calculations 
  • Changing the title of the chart 

Case #1

Using Slice to compare one series at different periods in time

Objectives

Using Slice to compare one series across different time periods

Exporting the underlying data into Excel

Solution

If you get stuck, use the worksheet to see what to do next.

If you need more detailed help, have a look at the learning resources below.

The Macrobond document is also available for download here.

Worksheet

Learning resources for this case

Category chart

Slice analysis

Worksheet – Case #1 – Using Slice to compare one series at different periods in time

Finding Data

In this case, you will have to use the S&P 500 index.

Using the data tree, you can locate the data here:

Country & Region > United States > Equity Market > Equity Indices > S&P > 500 > Composite > Price return

Add:

  • Index (highlighted with an exclamation mark)

You can also directly type its short code as Expression in Series List: spx

 

Analysis

Slice

To create the chart, you have to compare the performance of the S&P across different time periods. The Slice analysis will help you doing so.

  • Select “Series List” in the tree
  • Click on “Add” and choose Slice

Now, you need to slice the data into 3 series, each starting at the dates of major financial crises:

  • In the drop-down menu, pick Custom points in time
  • In our example the “Points in time” are:
    • 1929-09-01
    • 1987-09-01
    • 2008-08-15

Next, you need to specify the length of these 3 series:

  • Set “observations” to 3000

Finally, to make them comparable, you should rebase all of them to 100 at their respective start date:

  • Check the tick-box “rebase with base value: 100”

 

Charting

Category chart

You cannot add a “Time Chart” after the “Slice” analysis as the sliced series do not contain a notion of time. Instead the X-axis corresponds to numbers of observations. So:

  • Select “Slice” in the tree
  • Click on “Add” and choose Category chart

Legend labels

To add the labels next to the graph lines:

  • Click on the background of the chart
  • Look up for the Presentation Properties tab
  • In the “Elements” category, check the tick-box Legend labels

Axis title

To add an axis title

  • Click on the x-axis
  • Look up for the Presentation Properties tab
  • In “Axis title” click on Edit and type “number of days”

Other changes

  • The legend has been removed
  • Title: United States: S&P 500 performance after the main financial crises
  • To display the same axis on both sides: Axis synchronization: Value

 

Exporting to Excel

Exporting your chart to Excel is simple:

  • Right-click on the chart
  • Choose "Copy"
  • Paste the chart into Excel

Should you instead want to export the underlying data from the Slice analysis to Excel:

  • Right-click on "Slice" in the analysis tree
  • Choose "Copy as Excel Data set"
  • Paste into Excel

In Excel, you will get the data resulted from the slice analysis. The data is stored in the red dataset button. By right-clicking on it and selecting “Macrobond Excel data set object”, you will access various settings allowing you to edit the format of the dataset. There, “Edit Document” will open the underlying Macrobond file, if you want to edit the calculations.

This dataset can also be refreshed:

  • Go to the Macrobond add-in tab
  • Click on “Refresh”

The data and its calculations will be updated instantly.

Level 2