Category: E-learning Step by Step
Exercise #1
Counting occurrences of events
Intro
If you want to calculate, and highlight on your chart, like this blue line below, the number of occurrences a certain event took place, you can do so by using a formula language.
In our example we will calculate how many times the S&P 500 Volatility Index (VIX) has been lower than 10 in history.
To the see exact construction of the document, you can download the file here.
To learn more about Formulas in Macrobond have a look at these articles: Formula.
Count how many times VIX has been lower than 10
In other words, we need to sum the 1 and 0 of the previous logical expression, over time.
In the formula expression we can do this by using the function AggregateSum. It returns a result where the value at each observation is the sum of the values of all observations preceding it.
AggregateSum(vix<10)
Using the vix<10 as the operator of AggregateSum, we can determine the number of occurrences, when VIX value has been lower than 10.
The blue line in the chart below is the final result.
Determine when the VIX has been lower than 10
The first step is to determine when the VIX has been lower than 10. In order to do so, we need to create a logical expression:
Vix<10
This creates a binary time series, returning 1 when the Vix is lower than 10, and 0 otherwise. This way we have created a time series that identifies when the VIX is lower than 10.
Video – Case #10 – Calculating Moving Average and Adding Recession Bands
Video – Case #9 – Using Correlation to determine the best lag
Video – Case #8 – Using Cross Section to analyze a group of series
Video – Case #7 – Create a Scatter Chart
Video – Case #4 – Working with series that have different frequencies
Case #10
Creating a regression model with a fitted line
Objective
Limiting the data sample
Performing a simple regression analysis
Adding a regression line in a scatter chart
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.
Learning resources for this case