Setting time range

With the exception of the formula editor, Data range is the last parameter the application will take into consideration in preparing your series for analysis. Prior to this point, all your series have been converted to a common calendar of observations and include the full history of each series. If your analysis requires that all series have the same start and end date you can use data range to specify these dates.

However, if you simply wish to specify the start and end dates for your chart, you can do so by dragging the x-axis to the desired points in time.

Important information

Using the Data Range will cut the history of the time series. The full history will no longer be available in the document and might affect calculations. For instance: in the picture above, US Industrial Production (usindprod) starts in 1919-01-01. If you set a Data Range from 1950-01-01 and then calculate a Year-on-Year % Change, this series will now start in 1951-01-01, as one year of the series history is needed to calculate Year-on-Year % Change. The history before 1950 will not be available anymore and thus not used in the calculations.

There are two other ways to specify a time range:

  • Frequency Conversion – useful when you want to apply it to a specific block of analyses

  • Formulas – useful when you want to apply it to specific series, see below examples
Cut(sek, Date(2010,01,01), Date(2021,01,01))
CutStart(sek, Date(2020,11,1))
CutEnd(sek, Date(2021,08,31))

Changing the frequency of a series

How does frequency conversion work?

Frequency Conversion is the last setting automatically applied in Series List, prior to any calculations.

Frequency settings are applied to the entire document so that all series are converted to the same frequency. This ensures consistent and comparable calculations and presentation of your work.

Setting the frequency is a two-step process in which you select the relevant frequency, and then the conversion settings that will be used to convert the series to common calendar dates.

Automatic frequency selection

When you have multiple series in a document their frequencies are automatically synchronized to match the series with the highest frequency. By default, the frequency conversion method is based on the type of series that are included in the document.

The difference between Same and Separate settings

You can either set the same frequency settings to all series in a document or use separate settings for each series. Both options can be found in the Conversion settings tab.

Changing frequencies manually

You’ll find the frequency settings by clicking on Series list. The settings panel will be displayed in the presentation window to the right. Manual frequency adjustments work in two steps:

  1. Choose the frequency, and then the method that will be used to convert the series.
  2. The last part is done in the Conversion settings tab.

To manually adjust the frequency of the series in a document you can adjust three parameters

  • The frequency you want to apply to the document
  • The conversion method used, and whether it is applied uniformly to all the series, or defined separately for each series
  • Through which method Macrobond should handle missing values

How to change the frequency from higher to lower?

  1. In the frequency drop-down list select a frequency. In this example, we select 'Lowest (monthly)'
  2. Click on the conversion settings tab and select a method for converting the series to a lower frequency
  3. Click on the relevant presentation in the analysis tree to see the result.

How to change the frequency from lower to higher?

There are several methods available that can be used to convert series to a higher frequency.

How to lower the frequency of a series that has partial periods?

When converting a series to a lower frequency, you might encounter a problem with incomplete periods. For instance, a daily series that do not have observations for the entire month. The setting 'Partial Periods to lower frequency method' will let you choose your preferred setting for these situations.

Go to Conversion settings tab and choose preferred method from the drop-down list.

Applying frequency conversion after applying analyses

Frequency conversions made in Series list will be applied to series regardless of any proceeding analyses applied in the tree. Any existing analyses will be recalculated based on the frequency settings applied. However, if you want to change the frequency after applying analyses, you can add or insert a Frequency conversion in the Analysis tree instead.

Adding forecast

How the forecast feature works?

When you’ve selected multiple series to use in a document, the application will make some adjustments to the series so that you can work with a common set of observations. The second parameter that is taken into consideration in this process is Forecasts tab (for more information see The order of calculations).

The forecast function allows you to add future values or change historical values of the time series you’re working with. When performed in the Series list, the forecasts will be applied on the series before any frequency, currency conversion or formula calculations have been applied. In other words, forecasts here are applied to the raw data of selected time series.

Backfilling currency data

Forecasts can also be added to the series used to calculate a currency conversion – as in this example using the Central Bank Balance Sheet for Euro Area, Japan and USA.

If you want to apply a currency conversion to a series you’ve added forecasts for, you can also add forecast values to the exchange rate series that will be used. If you don’t, the application will simply use the last value available for the exchange rate series.

Forecast analysis

We also have have an analysis which you can add in any point on the Analysis tree. For more information see Forecast.

How to add forecast values?

  1. Select and add the series you want to work with, to the Series list
  2. In the Series list select the Forecasts tab
  3. Click on the edit button to open the Edit forecast dialog box
  4. Select a Value method
    • absolute values
    • absolute differences relative other values
    • percent changes relative other values.
  5. Select a Date method
    • points in time
    • number of years since the previous forecast or value
  6. Select the scale to make it easier to enter forecasts for series expressed in millions or billions.
  7. Add new values to the relevant columns shown.
  8. All added values will be shown as forecasts in the chart, using 50% opacity.

Keep in mind

  • Forecasts are added using the original frequency of the time series
  • Changing the frequency of a document will result in a frequency conversion of all series values, including forecasts
  • Define how empty values should be treated, under Missing Value Representation in the conversion settings tab

  • If you want to apply forecasts after performing a calculation on the series, rather than adding forecast values to the raw data, select the Forecast from the list of analyses, in the analysis tree.

More questions

If you have more questions, for example How to hide forecast line in legend? see our Forecast analysis page.

If you want to know how to extend series using mechanism inside Forecast analysis see more information under In-app features - Forecast tab.

Using the Series list

In each Macrobond document that you create, the analyses and charting presentations that you apply to the data are added to a tree schema - called Analysis tree. What we are going to look at now is the first branch of the analysis tree, the Series list. Any changes you make to the series list will influence the analyses and presentations that follow.

Introduction

The Series list is the first node of the Analysis tree and opens to the right to show all the data. The purpose of the Series list is to prepare the series for further analysis and presentation by converting all series to a common calendar and filling in missing values. You can also convert series to a common currency, add forecasts, and set a data range.

Series list 

Expression and Description

Series added to a document are listed in the Series List and are comprised of two components.

  • Expression - the series name e.g., eubank0133
  • Description - e.g., Euro Area, ECB Consolidated Balance Sheet & Flows of MFI Sector, Eurosystem, Total Assets & Liabilities, All, EUR

In the Series list you’ll see the time series described relative to data attributes, such as:

  • Region
  • Category
  • Series title
  • Inflation adjustment
  • Seasonal Adjustment
  • Unit

The series descriptions are automatically used in charts, either in the heading or in the chart legend. You may want to change these descriptions manually, especially if they are too long.

How to add/remove series from expressions

Unless you know exactly which series you want to look at, building a new document is often a trial-and-error process of finding the data that works best. Learning about the different options to add and remove time series from a document will ensure that this process is as quick and effective as possible.

Adding series

From Browse/Search

In both cases panel on Actions ribbon will do the trick. Simply click on series which you want to add, either from Browse tree or Search and next go to Actions ribbon > Add to document.

From Analytics Series browser

The situation looks a little different in case of Analytics tab. Here you can choose series from Series browser and double-click on it. You can also select series and click on 'Add selected time series' button. After both actions selected series will be included in Series list.

It's worth to remember that you can select more than one series by pressing Ctrl when clicking on these series or select all available series by pressing Ctrl+A on your keyboard.

Removing series

To permanently remove the series from the document, right-click on the series in the Series list and select Delete. You can also select series you want to remove, and press Delete key. This action will delete this time series from the document, including any analyses or charts it was used in.

To remove a series only from a chart, simply right click on it in the chart and select Delete or open Graph layout (Ctrl+L) and remove it from there.

How to edit the descriptions?

There are two options for editing descriptions: a simple edit and an advanced edit.

Simple edit

  1. Double click on the description in question, in the Series list
  2. Type in the desired description
  3. Hit 'Enter'.

Advanced edit

  1. Click once on the series description to highlight it
  2. Navigate to the presentation properties in the command bar, above
  3. Select an option from the drop-down menu

  • Automatic – will use the default series description
  • Custom – select this and click on edit to modify the text manually
  • Expression – applies the Macrobond time series code
  • Reference – will use the default series description, to which you can add custom text that will be used in the chart legend

Please bear in mind that the description entered in the Series List will later be used in the document across all its functionalities and in the chart titles and legends.

Formula editor

To use the formula language to customize your calculations beyond the options available via the Analysis tree click on the 'fx' button to open formula editor. It's located to the right of the series name in the Expression field. The name of the series in that field will automatically be added to the editor.

Formula language

You'll find a selection of formulas in a list to the right of the editor. These formulas can be used separately or be combined into larger formula. For further information how these work see Introduction to Formula, and The Macrobond formula language. For the complete list of formulas with descriptions and use cases see Built-in formula functions.

Vintage series

This feature requires Macrobond Data+ license.
This feature is available in Macrobond 1.29 and later.

Since version 1.29 when you end typing series code you will see general hints about the possibilities of vintage data (revision history). If you type a { after code you will see all the specific vintages for that series. For more information about this feature see Vintage data (Revision history).

The order of calculations

When making modifications to the data in the Series list, certain operations are necessarily prior to others. Please bear this in mind as it will affect any further changes that are made. Vintage data (revision history) and ratios (i.e., #percapita(segdp) )are treated as standard series.

Whether you perform all, or only a few of the modifications available, you should proceed in the following order:

  1. Apply the data range, to limit all the time series to a specific range of time.
  2. Add forecasts to the relevant series in the list
  3. Select the currency conversion
  4. Select how to harmonize the observations, and how to treat missing values
  5. Select the frequency, and if necessary, a method for frequency conversion.
  6. Handle missing values that were introduced by the frequency conversion
  7. Apply formulas to the various series in the list (from the inner formula to outer formula).

Drop-downs

Frequency

Here you can choose frequency of the document. By default, it will position itself at the Highest frequency available from all series included in document.

This setting is related to Conversion settings tab. For more information see: Changing the frequency of a series.

Observations

Here you can choose how inconsistencies between different calendars should be handled. For more information see: Observations settings.

Currency

Here, you can select the currency in which all series in  the Series list should be calculated. The Currency conversion feature will use an exchange rate series available in Macrobond, matching the original frequency of the series (before any changes made in the frequency of the document). If such series do not exist, Macrobond will either:

  • Use the US Dollar to calculate a cross-currency rate (in case it doesn’t find a direct exchange rate series)
  • Use an exchange rate series with a higher frequency (in case it doesn’t find an exchange rate series matching the original frequency of your series), using the first value of the period.

After activating this feature in Conversion settings tab option 'Currency conversion method' will become available. For more information about these methods see: Currency conversion.

Data range

Here you can quickly narrow time range of all series in Series list. It will be applied at the beginning of all further calculations and analyses.

Vintage

This feature requires Macrobond Data+ license. 

You can download vintage versions (revision history) of time series through Macrobond. Note that not all time series may have vintage data, or they do not have data from the period you want. For more information see Vintage data.

Missing input

Here you can easily choose how Macrobond should treat missing series in lists. For more see Lists of series.

Tabs

Conversion settings

When you change frequency of the document you can control how program will handle the process. You can select same setting for all series or separately for each of them. Note that the lowest frequency is Annual and highest is Daily. Setting 'Partial periods to lower frequency method' will tell program what to do for example with not-full-year when changing frequency to Annual.

Beside frequency conversion you can select here what to do with missing values - this is the only place for this setting and method for currency conversion. For more information see: Changing the frequency of a series and Currency conversion.

Interface is very similar as in Frequency conversion analysis but this tab can only change frequency at the beginning of all calculations.

Forecasts

Here you can add forecast at the beginning of all calculations. For more information see: Adding forecast.

Interface is same as in Forecast analysis but this tab can only add forecast at the beginning of all calculations.

Document series

You can quickly add your own data by creating document in-house here. This in-house will be visible only in that and nowhere else. For more information see: Document Series – adding external data.

Series information

You can use the Series information tab to check metadata information for series you have selected in the Series list. This is an easy way to check series metadata without having to leave the analysis tree.

For more information about customization and things available through this feature see: Series information.

Lists

Here you can organize large numbers of series into handy lists on which you can then calculate. For more information see: Lists of series.

Analysis tree

What is the Analysis tree?

The Analysis tree is the place for adding data, analyses, and charts. It consists of three different elements:

  • The Series list, which includes all the data you add to a document
  • The calculations you have applied to the data
  • The presentation styles you have selected to visualize the data

You use the analysis tree to apply, organize and access these elements in developing your document. By adding or inserting different nodes in the tree, you can apply a variety of analyses and presentations to a data set, collected in a single document.

Structure of the Analysis tree

As you can see in the picture above, you start with the Series list, which is always the root node. You then apply one or more parent nodes containing calculations, or presentation styles. The output of each node is dependent on the preceding nodes it is grouped with.

The way you structure the analysis tree affects the output of the document. For example, adding a Forecast after a Rate of change analysis implies that the forecast will be calculated based on the rate of change calculation above.

Working with the Analysis tree

Use Add/Insert buttons to add analyses, charts, or tables. Because of the tree-like construction, in chart you will have available only the outcome of analysis (or analyses) above it. Chart or table at the end of one node won't contain outcome from other nodes.

In above example if you want to create a chart with raw series add Time chart from the Series list directly.

Add/Insert differences

The 'Add' button will add new analysis directly from the node you have selected. Below we have selected Rate of change and used Add > Regression. Now outcome from Rate of change will be accessible in Regression and Correlation analyses.

These two analyses (Regression and Correlation) are on the same level and aren't linked so outcome from Regression can't be used in Correlation and vice versa.
       
'Insert' is similar - it adds an analysis before selected node. Below we have selected Time chart and inserted Lag analysis. Thus, the order of calculation is now Rate of change > Lag >Time chart. Lag, Correlation and Regression are on the same level and won't affect each other.
    ⇒     
Note that you cannot insert before Time chart/Time table analysis which produces category data. For example Scalar analysis works only with Category chart.

Working with many analyses

You can accumulate many analyses and use the results in the subsequent analysis. Sometimes it might be hard to track what comes under what so you can roll up the nodes with black triangle icon next to analysis name. See below Analysis tree with colors applied to each node (they won't be visible in application) and how it will look after folding.
   ⇒     
If analysis is in a different node your only choice is to create Calculated in-house series from the outcome, add series on Series list and use it in another node.

Re-organizing the analysis tree

Moving analyses within a branch

    ⇒     
You can move analyses that are on the same level/branch up or down in the tree. This does not affect calculations but can help you to organize your document.

How to move up, rename, duplicate, or delete analysis

Besides Add and Insert there are a few more functions available via the context menu. These will help you make changes to the structure of the analysis tree.

Move up

Click on the branch you want to move to open the context menu and select 'Move up'.

Note that you can do this only if the lower analysis isn't accompanied by other analyses.

Rename

Right click on the branch you would like to rename or press F2. Type in the new name and click OK.

Renaming is a useful for quickly being able to identify the correct branch, when building documents with a large analysis tree.

Duplicate

  1. Right click on the branch containing the segments you would like to duplicate
  2. Select 'Duplicate' from the context menu, or use the keyboard shortcut Ctrl+2


By duplicating an entire block of calculations, you can quickly generate a new chart from the same data set and calculations, in order to compare different aspects of the data.

Delete

  1. Right click on the branch you want to delete
  2. Select delete from the context menu. (Since version 1.28 there is 'Delete with children' option available).
  3. Use the keyboard shortcut Ctrl+Z if you want to undo this. See here pre-1.28 version view

 

To avoid accidentally deleting an entire block of calculations the command is only executed on the highlighted branch. That is, each branch must be selected and deleted separately.

Analyzing data

The Analytics activity is the powerhouse of the application. In Analytics, you can find and add time series to a document, create and apply calculations and analyses, and generate different charts and tables. In the following materials you will find more information about the options available here. For useful shortcuts see: Keyboard shortcuts.

Built-in formula functions

Here you can find the details regarding the Macrobond formula language.

In the function descriptions below, the following convention has been used when naming parameters:

value The parameter can be either a number or a series. The type of the result is typically the same as this parameter. For instance, Log(20) returns a number, but Log(sek) returns a series.
series The parameter can only be a series. (See discussion earlier in this document for how the automatic conversion of numbers to series works)
other Other parameter names, such as number, window, observation, length, must be numbers unless other information is provided. For instance, you can write Lag(sek, 10), but not Lag(sek, nok).

 

Mathematical functions

Abs(value)

Returns the absolute value.

Example: Abs(usflof_002090)

Acos(value)

Returns the angle whose cosine is the specified value. The angle is expressed in radians.

Example: Acos(0.5)

AggregateProduct(series)

Returns the aggregated product of all previous numbers. Null numbers are treated as one.

yt =  i=0txi

Example: Russia's GDP is presented as 'CPPY=100' (Change Y/Y + 100). To turn it into index series you need to modify formula: AggregateProduct(1+(runaac0033-100)/100)

Example: AggregateProduct(1+0.05/100)*100 continuous growth rate of 5%

AggregateSum(series)

Returns the aggregated sum of all previous numbers. Null numbers are treated as zero.

𝑦 𝑡 = i= 0 t 𝑥 𝑖

Example: AggregateSum(secons0162)

AggregateSumAnnual(series)

Returns the aggregated sum of previous numbers from the start of each year. Null numbers are treated as zero.

Example: AggregateSumAnnual(secons0162)

This is implemented in the Macrobond formula language as:

AggregateSumAnnual(series) = 

let

.a = AggregateSum(series) 

in 

.a - Null0(At(.a, EndOfYearAhead(-1)))

end

Asin(value)

Returns the angle whose sine is the specified value. The angle is expressed in radians.

Example: Asin(0.866)

Atan(value)

Returns the angle whose tangent is the specified value. The angle is expressed in radians.

Example: Atan(1.7321)

Atan2(x, y)

Returns the angle whose tangent is the quotient of two specified values. The angle is expressed in radians.

Example: Atan2(1.7321, 1)

BKFilter(series, shortPeriod, longPeriod, leadLags)

Returns the Baxter-King bandpass filtered series with the specified properties.

Example: BKFilter(usgdp, 6, 32, 32)

CFRandomWalkFilter(series, shortPeriod, longPeriod)

Returns the series filtered with asymmetric Christiano-Fitzgerald bandpass filter for non-stationary series with the specified properties.

Example: CFRandomWalkFilter(usgdp, 6, 32)

CFStationaryFilter(series, shortPeriod, longPeriod)

Returns the series filtered with asymmetric Christiano-Fitzgerald bandpass filter for stationary series with the specified properties.

Example: CFStationaryFilter(usgdp, 6, 32)

Ceiling(value)

Returns the smallest integer greater than or equal to the specified value.

Example: Ceiling(sek)

Cos(value)

Returns the cosine of the specified angle. The angle should be expressed in radians and must be in the range -9223372036854775295 to 9223372036854775295.

Example: Cos(1.0472)

Cot(value)

Returns the cotangent of the specified angle. The angle should be expressed in radians.

Example: Cot(1.0472)

CountValid(series)

Returns the number of values that are not null.

Example: CountValid(fi10ygov)

CountValid(series, window)

Returns the number of values that are not null in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: CountValid(fi10ygov, WeeksLength(1))

CoVariance(series1, series2)

Returns the covariance of series1 and series2.

Example: Covariance(sek, segdp)

CoVariance(series1, series2, window)

Returns the covariance of series1 and series2 within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Covariance(sek, segdp, YearsLength(1))

E()

The number e.

EMean(series, factor)

Returns the exponential moving average with the specified factor. The factor, α, must be a number between 0 and 1.

Example: EMean(sek, 0)

y0 = x0

For

t > 0

yt =αxi+1-a yi-1

Exp(value)

Returns e raised to the power of the specified value, where e is the base of the natural logarithm.

Example: Exp(sek)

FillNullWithLinear(series)

Fills null values with a linear combination of the previous and next values.

Example: Set Conversion settings > Missing value method to 'Do not fill in': FillNullWithLinear(sp600_20201080tr)

FillNullWithNext(series)

Fills null values with the next value.

Example: Set Conversion settings > Missing value method to 'Do not fill in': FillNullWithNext(sp600_20201080tr)

FillNullWithPrevious(series)

Fills null values with the previous value.

Example: Set Conversion settings > Missing value method to 'Do not fill in': FillNullWithPrevious(sp600_20201080tr)

FillNullWithPreviousAsForecast(series)

Fills null values with the previous value and flag as forecast.

Example: Set Conversion settings > Missing value method to 'Do not fill in': FillNullWithPreviousAsForecast(sp600_20201080tr)

First(series)

Returns the first number of a series.

Example: First(sek)

FirstGreaterOrEqual(series, value)

Returns the observation number of the first observation greater or equal than the specified value.

Example: if(Counter()=FirstGreaterOrEqual(sp500_500, 4200), sp500_500, Null())

FirstLessOrEqual(series, value)

Returns the observation number of the first observation less or equal than the specified value.

Example: if(Counter()=FirstLessOrEqual(sp500_500, 4200), sp500_500, Null())

FirstValid(series)

Returns the first number of a series that is not null.

Example: First(sek)

Floor(value)

Returns the largest integer less than or equal to the specified value.

Example: Floor(sek)

GeometricMean(series)

Returns the geometric mean.

Example: GeometricMean(plgdp)

This is implemented in the Macrobond formula language as:

GeometricMean(series) = Exp(Mean(Ln(series)))

GeometricMean(series, window)

Returns the geometric moving average of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: GeometricMean(plgdp, YearsLength(2))

This is implemented in the Macrobond formula language as:

GeometricMean(series, window) = Exp(Mean(Ln(series), window))

High(series)

Returns the highest number.

Example: High(usgdp)

High(series, window)

Returns the highest number in a window of the specified length. You can specify a vector as the length parameter in the High and Low formula functions.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: you can get the highest value in a series using an expanding window: High(usgdp, Counter(eur)-Start(eur)+1)

or without expanding window: High(usgdp, Yearslength(2))

HighObs(series)

Returns the observation number of the last highest value.

Example: HighObs(usgdp)

HighObs(series, window)

Returns the observation number of the last highest value within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: HighObs(usgdp, Yearslength(2))

HPFilter(series, lambda)

Returns a series smoothed by using the Hodrick-Prescott method with the specified lambda factor, which must be a number greater than zero. We calculate the HP filter according to Hodrick–Prescott filter - Wikipedia, which is the same method as can be found in MATLAB and EViews.

The rule of thumb is to use

𝜆=1600

for quarterly data;

𝜆=14400

for monthly data; and

𝜆=100

for yearly data.

Example: HPFilter(brnaac0016, 1600)

HPFilterOneSided (series, lambda)

Returns a series smoothed by using a one-sided Hodrick-Prescott method with the specified lambda factor, which must be a number greater than zero.

The one-sided filter uses only past information when calculated each smoothed value. The calculation is the same as using the ordinary HP filter on all values up to the current value at each point in time.

The rule of thumb is to use

𝜆=1600

for quarterly data;

𝜆=14400

for monthly data; and

𝜆=100

for yearly data.

Example: HPFilterOneSided(brnaac0016, 1600)

Intercept(series1, series2)

Returns the intercept after regression correlation of series1 and series2 with series1 as the dependent.

Example: Intercept(usgdp, uspric2373)

Intercept(series1, series2, window)

Returns the intercept after regression correlation of series1 and series2 with series1 within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Intercept(usgdp, uspric2373, MonthsLength(20))

Last(series)

Returns the last value of a series.

Example: Last(eur)

LastGreaterOrEqual(series, value)

Returns the observation number of the last observation greater or equal than the specified value.

Example: if(Counter()=LastGreaterOrEqual(sp500_500, 4200), sp500_500, Null())

LastLessOrEqual(series, value)

Returns the observation number of the last observation less or equal than the specified value.

Example: if(Counter()=LastLessOrEqual(sp500_500, 4200), sp500_500, Null())

LastValid(series)

Returns the last valid value of a series.

Example: LastValid(eur)

LastNonForecast(series)

Returns the last value of the series that is not a forecast. 

Example: LastNonForecast(bp_oecdoilprodt)

Linear(series)

Returns a line fitted using the least square method.

Example: Linear(sek)

This is implemented in the Macrobond formula language as:

Linear(series) = LinSlope(series)*(Counter(series) - Start(series)) + LinIntercept(series)

Linear(series, observationStart, observationEnd)

Returns a line fitted using the least square method by using data from observationStart to, but not including, observationEnd.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Linear(sek, Date(2017, 01, 01), Now())

This is implemented in the Macrobond formula language as:

Linear(series, observationStart, observationEnd) =
let
   .slice = Cut(series, observationStart, observationEnd)
in
   LinSlope(.slice)*(Counter(series) - observationStart) + LinIntercept(.slice)
end

LinearExtended(series, observationExtended)

Returns a line fitted using the least square method. The line is extended until observationExtended.

Example: LinearExtended(plgdp, Endvalid(plgdp)+YearsLength(4))

This is implemented in the Macrobond formula language as:

LinearExtended(series, observationExtended) =
let
   .slope = LinSlope(series)
   .intercept = LinIntercept(series)
   .observationStart = StartValid(series)
   .line = .slope*(Counter(series) - .observationStart) + .intercept
   .extendedValue = .slope*(observationExtended - .observationStart) + .intercept
in
   ExtendLinear(.line, observationExtended, .extendedValue)
end

For more information see: All about extending series

LinearExtended(series, observationStart, observationEnd, observationExtended)

Returns a line fitted using the least square method by using data from observationStart (start of trend calculation) to, but not including, observationEnd (end of trend calculation). The line is extended until observationExtended.

Example: LinearExtended(plgdp, Date(2010, 1, 1), Date(2015, 1, 1), Endvalid(plgdp)+YearsLength(4))

This is implemented in the Macrobond formula language as:

LinearExtended(series, observationStart, observationEnd, observationExtended) =
let
   .slice = Cut(series, observationStart, observationEnd)
   .slope = LinSlope(.slice)
   .intercept = LinIntercept(.slice)
   .line = .slope*(Counter(series) - observationStart) + .intercept
   .extendedValue = .slope*(observationExtended - observationStart) + .intercept
in
   ExtendLinear(.line, observationExtended, .extendedValue)
end

For more information see: All about extending series

LinIntercept(series)

Returns the intercept of a line fitted with the least square method .

Example: LinIntercept(dxy)

LinIntercept(series, window)

Returns the intercept of a line fitted with the least square method within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: LinIntercept(dxy, YearsLength(1))

LinSlope(series)

Returns the slope of a line fitted with the least square method.

Example: LinSlope(dxy)

LinSlope(series, window)

Returns the slope of a line fitted with the least square method within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: LinSlope(dxy, YearsLength(1))

Ln(value)

Returns the natural logarithm.

Example: Ln(100)

Example: Ln(sek)

Log(value)

Returns the logarithm with base 10.

Example: Log(100)

Example: Log(sek)

Low(series)

Returns the lowest number of the series.

Example: Low(sek)

Low(series, window)

Returns the lowest number in a window of the specified length. You can specify a vector as the length parameter in the High and Low formula functions.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Low(sek, Yearslength(1))

Example: You can get the lowest value so far in a series using an expanding window like this: Low(eur, Counter(eur)-Start(eur)+1).

LowObs(series)

Returns the observation value of the last lowest number.

Example: LowObs(sek)

LowObs(series, window)

Returns the observation value of the last lowest number within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: LowObs(sek, Yearslength(1))

Max(value1, value2)

Returns the largest value of a pair of values.

Example: Max(sek)

Mean(series)

Returns the mean value as a number.

Example: Mean(segdp)

Mean(series, window)

Returns the moving average of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Mean(segdp, Yearslength(1))

Median(series)

Returns the median as a number.

Example: Median(segdp)

Median(series, window)

Returns the median value in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Median(segdp, Yearslength(1))

Min(value1, value2)

Returns the smallest value of a pair of values.

Example: Min(swedsegdpfcst, sefcst0076)

Example: Min(swedsegdpfcst, 2)

Mod(value1, value2)

Returns the reminder of an integer division.

Example: Mod(swedsegdpfcst, 2)

The calculation uses a floored division and is equal to: value1 – value2*Floor(value1/value2)

Momentum(series, length)

Returns the difference between the series and a lagged series.

Example: Momentum(plgdp, yearslength(1))

Example: When you want to disaggregate series, you can combine Momentum() with if(): if(Month()=1, dedemo0013, momentum(dedemo0013, 1))

NextGreaterOrEqual(series, value, observation)

Returns the observation number of the next observation greater or equal than the specified value.

Example: Counter()-NextGreaterOrEqual(sp500_500, sp500_500, Counter()-1) It calculates the number of days before the value was as high

NextLessOrEqual(series, value, observation)

Returns the observation number of the next observation less or equal than the specified value.

Example: Counter()-NextLessOrEqual(sp500_500, sp500_500, Counter()-1) It calculates the number of days before the value was as low

Null()

Returns the null number.

Example: You can use it inside if() condition formula: if(swedsegdpfcst>3.5, 1, Null())

Null0(value)

Returns 0 if the value is null and otherwise the value.

Example: Set Conversion settings > Missing value method to 'Do not fill in': Null0(sp600_20201080tr)

Null1(value)

Returns 1 if the value is null and otherwise the value.

Example: Set Conversion settings > Missing value method to 'Do not fill in': Null1(sp600_20201080tr)

Pi()

The number π.

Example: 2*pi()

Pow(value, power)

Returns a value raised to a power.

Example: Pow(sek, 2)

PreviousGreaterOrEqual(series, value, observation)

Returns the observation number of the previous observation greater or equal than the specified value.

Example: Counter()-PreviousGreaterOrEqual(sp500_500, sp500_500, Counter()-1) It calculates the number of days since the value was as high

PreviousLessOrEqual(series, value, observation)

Returns the observation number of the previous observation less or equal than the specified value.

Example: Counter()-PreviousLessOrEqual(sp500_500, sp500_500, Counter()-1) It calculates the number of days before the value was as low

Product(series)

Returns the product of all numbers in the series.

Example: product(Cut(uscpi, Date(2019, 1, 1), Date(2020, 1, 1)))

y = i=t-w+1l  xi

Product(series, window)

Returns the product of all values in a window of the specified length.

Example: product(Cut(uscpi, Date(2019, 1, 1), Date(2020, 1, 1)), Quarterslength(1))

yt = i=t-w+1t xi

Round(value, decimals)

Returns the value rounded to the specified number of decimals.

The number of decimals can be from 0 to 15

The value is rounded to the closest value with the specified number of decimals. If the value is exactly in between two values, it is rounded to the value that ends with an even digit. This follows the IEEE Standard 754 as specified in section 4 and is sometimes called 'banker’s rounding'. Other midpoint strategies can be obtained by using the Floor and Ceiling functions.

Example: Round(sek, 2)

Sign(value)

Returns -1 for negative values, 0 for 0 and 1 for positive values.

Example: You can wrap it around change over period (cop()) formula and check the growth: Sign(Cop(usgdp, Yearslength(1)))

Sin(value)

Returns the sine of the specified angle.

The angle should be expressed in radians and must be in the range -9223372036854775295 to 9223372036854775295.

Example: Sin(1.0472)

Slope(series1, series2)

Returns the coefficient of the regression, a.k.a. the beta, between series1 and series2 with series1 as the dependent.

Example: Slope(usgdp, uspric2373)

Slope(series1, series2, window)

Returns the coefficient of the regression, a.k.a. the beta, between series1 and series2 with series1 as the dependent within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Slope(usgdp, uspric2373, Yearslength(1))

Sqrt(value)

Returns the square root.

Example: Sqrt(usgdp)

Sum(series)

Returns the sum of all numbers in the series.

Example: Sum(opecsecrudeoilimp)

Sum(series, window)

Returns the sum of all numbers in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Sum(opecsecrudeoilimp, Yearslength(1))

Tan(value)

Returns the tangent of the specified angle. The angle should be expressed in radians.

Example: Tan(1.0472)

 

Statistical functions

ChiDist(value, degFree)

Returns the probability for a value based on the chi distribution with the specified degrees of freedom. The parameters can be either a number or series.

Example: ChiDist(sek, 2)

ChiDistInv(probability, degFree)

Returns the value for a probability based on the chi distribution with the specified degrees of freedom. The parameters can be either a number or series.

Example: ChiDistInv(0.5, 20)

Correlation(series1, series2)

Returns the correlation coefficient of series1 and series2.

Example: Correlation(uscpi, btc)

Correlation(series1, series2, window)

Returns the correlation coefficient of series1 and series2 in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Correlation(uscpi, btc, YearsLength(1))

CorrelationBestLag(series1, series2, startLag, endLag)

Returns lag with the highest correlation coefficient in absolute terms of series1 and series2.

Example: CorrelationBestLag(uscpi, btc, -Yearslength(1), Yearslength(1))

FDist(value, degFreeNum, degFreeDenom)

Returns the cumulative probability for a value based on the F distribution with the specified degrees of freedom for the numerator and denominator. The parameters can be either a number or series.

Example: FDist(sek, 2, 1)

FDistInv(probability, degFreeNum, degFreeDenom)

Returns the value for a probability based on the F distribution with the specified degrees of freedom for the numerator and denominator. The parameters can be either a number or series.

Example: FDist(0.5, 2, 1)

Kurtosis(series)

Returns the excess kurtosis of a series.

Example: Kurtosis(sek)

Kurtosis(series, length)

Returns the excess kurtosis of a series in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Kurtosis(sek, Yearslength(1))

LogNormDist(value, mean, stdDev)

Returns the probability for a value based on the log-normal distribution with the specified mean and standard deviation. The parameters can be either a number or series.

Example: LogNormDist(sek, 2, 1)

LogNormDistInv(probability, mean, stdDev)

Returns the value for a probability based on the log-normal distribution with the specified mean and standard deviation. The parameters can be either a number or series.

Example: LogNormDistInv(0.5, 2, 1)

LowerTailMean(series, p)

Returns the mean of the number of lowest values as specified by the percentage, p. The parameter p should be in the range 0 < p < 100. This is sometimes known as the tail expectation.

Example: LowerTailMean(sek, 20)

LowerTailMean(series, p, window)

Returns the mean of the number of lowest values as specified by the percentage, p, in a window of the specified length. The parameter p should be in the range 0 < p < 100. This is sometimes known as the tail expectation.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: LowerTailMean(sek, 20, Yearslength(1))

MedAbsDev(series)

Returns the median absolute deviation.

Example: MedAbsDev(usgdp)

NormDist(value)

Returns the probability for a value based on the standard normal distribution. The parameters can be either a number or series.

Example: NormDist(sek)

NormDist(value, mean, stdDev)

Returns the probability for a value based on the normal distribution with the specified mean and standard deviation.

Example: NormDist(sek, 2, 1)

This is implemented in the Macrobond formula language as:

NormDist(value, mean, stdDev) = NormDist((value - mean) / stdDev)

NormDistInv(probability)

Returns the value for a probability based on the standard normal distribution. The parameters can be either a number or series.

Example: NormDistInv(0.5)

NormDistInv(probability, mean, stdDev)

Returns the value for a probability based on the normal distribution with the specified mean and standard deviation. The parameters can be either a number or series.

Example: NormDistInv(0.5, 2, 1)

This is implemented in the Macrobond formula language as:

NormDistInv(probability, mean, stdDev) = NormDistInv(probability)*stdDev+mean

Percentile(series, p)

Returns the number of the p:th percentile from series, where p is in the range 0-100.

Is inclusive and uses linear interpolation.

Example: Percentile(sek, 1) will give you lower tail 1%

Example: Percentile(sek, 99) will give you upper tail 1%

Percentile(series, p, window)

Returns the value of the p:th percentile within a window of the specified length, where p is in the
range 0-100.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Is inclusive and uses linear interpolation.

Example: Percentile(sek, 1, YearsLength(1)) will give you lower tail 1% in a rolling yearly time frame

Example: Percentile(sek, 99, YearsLength(1)) will give you upper tail 1% in a rolling yearly time frame

ExpandingPercentile(series, p)

Returns the value of the p:th percentile within an expanding window (0 < p < 100).

Example:  Percentile(sek, 1) will give you lower tail 1% in an expanding time frame

PercentRank(series, value)

Returns the rank of a value in a series as a percentage (0..100) of the values in the series.

A missing value will be returned if the value is outside the range of values in the series.

If the value is in between values in the series, a linear interpolation will be made using the ranks of the surrounding values. The last parameter can be either a number or series.

Example:  PercentRank(sek, sek) this calculates the percentile value of the series 'sek' for each observation.

PercentRank(series, value, length)

Returns the rank of a value in a series as a percentage (0..100) of the values within a window of the specified length.

A missing value will be returned if the value is outside the range of values in the series.

If the value is in between values in the series, a linear interpolation will be made using the ranks of the surrounding values. The second parameter can be either a number or series.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example:  PercentRank(sek, sek, YearsLength(1))

ExpandingPercentRank(series, value)

Returns the rank of a value in a series as a percentage (0..100) of the values in an expanding window.
It calculates in the order from smallest to largest. This corresponds to passing 1 as the third parameter to RANK.EQ in Excel. It also uses 0 as the index of the first value.

Example:  ExpandingPercentRank(sek, Lastvalid(sek))

NormDistCdf(series)

Returns standard normal cumulative distribution function.

Example:  NormDistCdf(standardize(uscpi))

NormDistPdf(series)

Returns standard normal probability mass function.

Example:  NormDistPdf(standardize(uscpi))

Qn(series)

Returns Rousseeuw's Q dispersion.

Example:  Qn(segdp)

RankCorrelation(series1, series2)

Returns the rank correlation coefficient of series1 and series2.

Example:  RankCorrelation(usgdp,uscpi)

SeasonalAdjustmentAdditive(series, years)

Returns a seasonally adjusted series calculated by using an additive method with weights in a window of the specified number of years.

Example:  SeasonalAdjustmentAdditive(setrad0804, 10)

Skewness(series)

Returns the skewness of a series.

Example: Skewness(sek)

Skewness(series, length)

Returns the skewness of a series in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Skewness(sek, Yearslength(1))

Sn(series)

Returns Tukey's S dispersion.

Example: Sn(segdp)

Standardize(series)

This is also known as a Z-Score. It returns a normalized series which counts (in standard deviations) how far a value is from the mean value of the time series. The mean is represented by '0' and one standard deviation is '1'.

Example:  Standardize(ussurv1055)

This is implemented in the Macrobond formula language as:

Standardize(series) = FlagForecast(Trim((series - Mean(series)) / StdDev(series)), IsForecast(series))

This formula won't give same outcome as calculation from Cross sampling/Scalar. In formula we standardize the series (value - mean)/stddev for each value while in analyses we calculate a standardized value for the whole series (or a specified interval) according to mean/stddev.

 

Standardize(series, window)

Z-Score with window parameter. It returns a normalized series which counts (in standard deviations) how far a value is from the mean value within a window of the specified length. The mean is represented by '0' and one standard deviation is '1'.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example:  Standardize(ussurv1055, MonthsLength(6))

This is implemented in the Macrobond formula language as:

Standardize(series, window) = FlagForecast((series - Mean(series, window)) / StdDev(series, window), IsForecast(series))

This formula won't give same outcome as calculation from Cross sampling/Scalar. In formula we standardize the series (value - mean)/stddev for each value while in analyses we calculate a standardized value for the whole series (or a specified interval) according to mean/stddev.

StdDev(series)

Calculates 'Sample standard deviation'. Returns the standard deviation of the numbers in a series relative its mean value. You can calculate volatility with it.

Example:  StdDev(ussurv1055)

StdDev(series, window)

Calculates 'Sample standard deviation'. Returns the standard deviation compared to the mean value within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example:  StdDev(ussurv1055, MonthsLength(6))

TDist(value, degFree)

Returns the probability for a value based on the Student-T distribution with the specified degrees of freedom.

The parameters can be either a number or series.

Example:  TDist(sek, 2)

This is implemented in the Macrobond formula language as:

TDist(value, degFree) =
  let
    .dist = (1-FDist(value*value, 1.0, degFree))/2
  in
    if (value > 0.0, 1-.dist, .dist)
  end

TDistInv(probability, degFree)

Returns the value for a probability based on the Student-T distribution with the specified degrees of freedom. The parameters can be either a number or series.

Example:  TDist(0.5, 2)

This is implemented in the Macrobond formula language as:

TDistInv(probability, degFree) =
let
  .f = Sqrt(FDistInv(1-if (probability < 0.5, probability, 1-probability)*2, 1, degFree))
in
  if (probability < 0.5, -.f, .f)
end

Trimean(series)

It returns the Tukey’s trimean.

Example:  Trimean(sek)

TrimMean(series, p)

Returns the mean of the interior values of a series by excluding a number of values from the top and bottom tails as specified by the percentage (0 < p < 100). An equal number of values are removed from the top and bottom tails.

Example:  TrimMean(sek, 20)

TrimMean(series, p, window)

Returns the mean of the interior values of a series of moving windows of size length, by excluding a number of values from the top and bottom tails as specified by the percentage (0 < p < 100). An equal number of values are removed from the top and bottom tails.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example:  TrimMean(sek, 20, Yearslength(4))

TwoPieceNormDist(probability, mode, stdDev1, stdDev2)

Returns the probability for a value based on the 2-piece normal distribution with the specified mode, mean and standard deviations. The parameters can be either a number or series.

Example:  TwoPieceNormDist(0.5, 1, 4, 8)

This is implemented in the Macrobond formula language as:

TwoPieceNormDist(value, mode, stdDev1, stdDev2) =
let
  .norm = NormDistCdf((value-mode) / if (value > mode, stdDev2, stdDev1))
in
  if(value > mode,
    (stdDev1-stdDev2)/(stdDev1+stdDev2)+2*stdDev2/(stddev1+stdDev2)*.norm,
    2*stdDev1/(stdDev1+stdDev2)*.norm)
end

TwoPieceNormDistInv(probability, mode, stdDev1, stdDev2)

Returns the value for a probability based on the 2-piece normal distribution with the specified mode, mean and standard deviation.

Example:  TwoPieceNormDistInv(0.5, 1, 4, 8)

This is implemented in the Macrobond formula language as:

TwoPieceNormDistInv(probability, mode, stdDev1, stdDev2) =
let
  .m = stdDev1/(stdDev1+stdDev2)
  .stdsum = stdDev1+stdDev2
  .norm = NormDistInv(if (probability > .m, (probability-(stdDev1-stdDev2)/.stdsum)*.stdsum/(2*stddev2), probability*.stdsum/(2*stdDev1)))
in
  if (probability > .m, .norm*stdDev2, .norm*stdDev1)+mode
end

UpperTailMean(series, p)

Returns the mean of the number of highest values as specified by the percentage, p. The parameter p should be in the range 0 < p < 100. This is sometimes known as the tail expectation.

Example:  UpperTailMean(sek, 99)

UpperTailMean(series, p, window)

Returns the mean of the number of highest values as specified by the percentage, p, in a window of the specified length. The parameter p should be in the range 0 < p < 100. This is sometimes known as the tail expectation.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example:  UpperTailMean(sek, 99, MonthsLength(6))

Variance(series)

Returns the variance of the series.

Example:  Variance(sek)

Variance(series, window)

Returns the variance for a series within a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example:  Variance(sek, Yearslength(1))

 

Date and observation number functions

AddMonths(months)

Returns a series of all observation numbers offset by a number of months

Example:  AddMonths(12)

AddMonths(observation, months)

Returns the observation number for the specified observation number plus a number of months.

Example:  AddMonths(Counter(sek), 12)

AddYears(years)

Returns a series of all observation numbers offset by a number of years.

Example:  AddYears(12)

AddYears(observation, years)

Returns the observation number for the specified observation number plus a number of years.

Example:  AddYears(Counter(sek), 12)

At(series, observation)

Returns the value in the series at the specified observation number.

Example:  At(sek, Date(2020, 12, 11))

Counter()

Returns a series of all observation numbers.

Example: It can be used as a 'pointer' in other formulas: if(Counter()=Date(2021, 6, 1), flagforecast(sek/2), sek)

Counter(series)

Returns a series of all observation number for the specified series. It starts from '0' so to get exact number of observations you have to add +1

Example: Counter(sek)+1

Date(year, month, day)

Returns the observation number of the specified date, where month is 1-12 and day is 1-31.

If there is no observation at the specified date, the observation number of the closest previous observation is returned.

You shouldn't use this function to find the start of a year or month. Use the StartOfYear(year) and StartOfMonth(year, month) for this purpose.

Example: It can be used in other formulas At(sek, Date(2021, 6, 1))

DateAtOrAfter(year, month, day)

Returns the observation number of the specified date, where month is 1-12 and day is 1-31.

If there is no observation at the specified date, the observation number of the next observation is returned.

Example: DateAtOrAfter(2021, 4, 1)

Day()

Returns a series of the day (1-31) for each observation.

Example: Day()

Day(observation)

Returns the day (1-31) of the specified observation number.

Example: Day(Counter(sek))

DayOfWeek()

Returns a series of day of the week for each observation.

0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday

Example: DayofWeek()=3

DayOfWeek(observation)

Returns the day of the week of the specified observation number

0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday

Example: DayofWeek(Counter(sek))

Days(observation1, observation2)

Returns the number of calendar days passed from the first observation number to the second one.

Example: Days(StartOfMonth(), EndOfMonth())+1

Days30E(observation1, observation2)

Returns the number of days passed from the first observation number to the second using the 30E convention.

Example: Days30E(StartOfMonth(), EndOfMonth())+1

End()

Returns the last observation number for calculations.

Example: if(Counter()=End(), 1, 0)

End(series)

Returns the last observation number of the series.

Example: if(Counter()=End(sek), 1, 0)

EndOfMonth()

Returns a series with the last observation number during each month.

Example: if(Counter()=EndOfMonth(), 1, 0)

EndOfMonthAhead(monthsAhead)

Returns a series with the last observation number during each month.

Example: Extend(sek, Last(EndOfMonthAhead(2)), LastValid(sek))

EndOfQuarter()

Returns a series with the last observation number during each quarter.

Example: if(Counter()=EndOfQuarter(), 1, 0)

EndOfQuarterAhead(quartersAhead)

Returns a series with the last observation number during each quarter.

Example: Extend(sek, Last(EndOfQuarterAhead(2)), LastValid(sek))

EndOfWeek(firstDayOfWeek)

Returns a series with the last observation number during each week.

0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday

Example: Extend(sek, Last(EndOfWeek(3)), LastValid(sek))

EndOfWeekAhead(firstDayOfWeek, weeksAhead)

Returns a series with the last observation number during each week.

0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday

Example: Extend(sek, Last(EndOfWeekAhead(3, 2)), LastValid(sek))

EndOfYear()

Returns a series with the last observation number during each year.

Example: if(Counter()=EndOfYear(), 1, 0)

EndOfYearAhead(yearsAhead)

Returns a series with the last observation number during each year.

Example: Extend(sek, Last(EndOfYearAhead(2)), LastValid(sek))

EndValid(series)

Returns the observation number of the last valid value of the series.

Example: if(Counter()=EndValid(sek), 1, 0)

FlagForecast(value)

Returns a value as a forecast value.

Example: FlagForecast(sek)

FlagForecast(value, condition)

Returns a value as a forecast value if the condition is True and as a non-forecast value if it is False.

Example: FlagForecast(sek, sek>9) all values higher than 9

Example: FlagForecast(sek, Counter()>Date(2020, 3, 1)) all values after 1st Mar 2020

Example: You can also turn off any forecast highlight: FlagForecast(unpoppr276constant, 0)

ImmAhead(dayOffset, position)

Returns a series with the observation numbers of IMM dates where an offset is added to each input date.

Example: ImmAhead(2, 1)

ImmAhead(observation, dayOffset, position)

Returns the observation number of the IMM date where an offset is added to the input date that corresponds to the input observation number.

Example: ImmAhead(end(sek), 2, 1)

Length(series)

Returns the number of observations in a time series.

Example: Length(sek)

Month()

Returns a series of the month (1-12) for each observation.

Example: Month()

Example: if(Month()=2|Month()=6, 1, 0)

Month(observation)

Returns the month (1-12) of the specified observation number.

Example: Month(Counter(sek))

MonthLength()
Returns the number of observations per typical month based on the frequency. The value is a constant.
See also MonthsLength(months), YearLength(), QuarterLength() and WeekLength()

MonthLength() = ObservationCountPerYear()/12

Example: cop(sek, MonthLength()*3)

MonthsLength(months)
Returns the number of observations for a number of months based on the frequency (it uses typical constant length of a month).
MonthsLength(1) is the same as MonthLength()
See also YearsLength(years), QuartersLength(quarters) and WeeksLength(weeks)

Example: cop(sek, MonthsLength(3))

MonthOffset()

Returns a series with the offset of each observation within the month.

Example: At(Monthoffset(), EndofMonth())+1

MonthOffset(observation)

Returns the offset within the month of the specified observation number.

Example: MonthOffset(Counter(sek)+1)

NextValidObservationNumber(series)

Returns a series that contains the observation number of the current observation if it is valid and otherwise the number of the next observation that is valid

Example: High(sek, NextValidObservationNumber(sek))

NextValidObservationNumber(series, observation)

Returns the observation number of the specified observation if it is valid and otherwise the number of the next observation that is valid.

Now()

Returns the observation number of today's date.

Example: if(Counter()=Now()-1, flagforecast(sek), 0) will highlight yesterday's observation

ObservationCountPerYear()

Returns the number of observations per year based on the frequency.
This is a synonym for YearLength().

Example: cop(sek, ObservationCountPerYear())

PreviousValidObservationNumber(series)

Returns a series that contains the observation number of the current observation if it is valid (not null) and otherwise the number of the previous observation that is valid.

Example: High(sek, PreviousValidObservationNumber(sek)+1)

PreviousValidObservationNumber(series, observation)

Returns the observation number of the specified observation if it is valid and otherwise the number of the previous observation that is valid.

Quarter()

Returns a series of the quarter (1-4) for each observation.

Example: Quarter()

Example: if(Quarter()=2|Quarter()=3, 1, 0)

Quarter(observation)

Returns the quarter (1-4) of the specified observation number.

Example: Quarter(Counter(sek))

QuarterLength()
Returns the number of observations per typical quarter based on the frequency. The value is a constant.
See also QuartersLength(quarters), YearLength(), MonthLength() and WeekLength()

QuarterLength() = ObservationCountPerYear()/4

Example: cop(sek, QuarterLength()*2)

QuartersLength(quarters)
Returns the number of observations for a number of quarters based on the frequency (it uses typical constant length of a quarter).
QuartersLength(1) is the same as QuarterLength()
See also YearsLength(years), MonthsLength(months) and WeeksLength(weeks)

Example: cop(sek, QuartersLength(2))

QuarterOffset()

Returns a series with the offset of each observation within the quarter.

Example: At(Quarteroffset(), EndofQuarter())+1

QuarterOffset(observation)

Returns the offset within the quarter of the specified observation number.

Example: QuarterOffset(Counter(sek)+1)

Start()

Returns the first observation number for calculations.

Example: if(Counter()=Start(), 1, 0)

Start(series)

Returns the first observation number of the series.

Example: if(Counter()=Start(sek), 1, 0)

StartValid(series)

Returns the observation number of the first valid value of the series.

Example: if(Counter()=StartValid(sek), 1, 0)

StartOfYear()

Returns a series with the first observation number during each year.

Example: if(Counter()=StartofYear(), 1, 0)

Example: StartofYear()

Example: At(sek, StartofYear()) to get a value

StartOfYear(year)

Returns the observation number of the first observation of the specified year.

Example: StartofYear(2020)

Example: At(sek, StartofYear(2020)) to get a value

StartOfQuarter()

Returns a series with the first observation number during each quarter.

Example: if(Counter()=StartofQuarter(), 1, 0)

StartOfMonth()

Returns a series with the first observation number during each month.

Example: if(Counter()=StartofMonth(), 1, 0)

StartOfMonth(year, month)

Returns the observation number of the first observation of the specified month, where the month is in the range 1-12.

Example: if(Counter()=StartofMonth(2021, 1), 1, 0)

StartOfWeek(firstDayOfWeek)

Returns a series with the first observation number during each week.

0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday

Example: At(sek, StartOfWeek(3))

WeekLength()
Returns the number of observations per typical week based on the frequency. The value is a constant.
See also WeeksLength(weeks), MonthLength(), YearLength() and QuarterLength()

Example: cop(sek, WeekLength()*2)

WeeksLength(weeks)
Returns the number of observations for a number of weeks based on the frequency (it uses typical constant length of a week).
WeeksLength(1) is the same as WeekLength()
See also YearsLength(years), QuartersLength(quarters) and MonthsLength(months)

Example: cop(sek, WeekLength(2))

Year()

Returns a series of the year for each observation.

Example: if(Year()=2020, series/2, series)

Year(observation)

Returns the year of the specified observation number.

Example: Year()

Example: Year(Counter(sek))

YearLength()
Returns the number of observations per typical year based on the frequency. The value is a constant.
See also YearsLength(years), QuarterLength(), MonthLength() and WeekLength()

YearLength() = ObservationCountPerYear()

Example: cop(sek, YearLength()*5)

YearsLength(years)
Returns the number of observations for a number of years based on the frequency (it uses typical constant length of a year).
YearsLength(1) is the same as YearLength().
See also QuartersLength(quarters), MonthsLength(months) and WeeksLength(weeks)

Example: cop(sek, YearLength(5))

YearOffset()

Returns a series with the offset of each observation within the year.

Example: ceiling((YearOffset()+1)/WeekLength())-1 it counts weeks since the start of year

Example: At(Yearoffset(), EndofYear())+1

YearOffset(observation)

Returns the offset within the year of the specified observation number.

Example: YearOffset(Counter(sek)+1)

Years(observation1, observation2)

Returns the number of years between the first observation number to the second. The calculation is made using the Actual/Actual method defined by ISDA.

Example: Years(Start(), End())

Example: Years(Start(sek), End(sek))

 

Series operations

Cut(series, observationStart, observationEnd)

Returns a series excluding observations before the specified start observation number and all observations starting with the specified end observation number.

Example: Cut(sek, Date(2010, 01, 01), Date(2021, 01, 01))

CutEnd(series, observation)

Returns a series of all observations before the specified observation number.

Example: CutEnd(sek, Date(2021, 03, 12))

CutStart(series, observation)

Returns a series without any observations before the specified observation number.

Example: CutStart(sek, Date(2020, 01, 01))

Extend(series, observation, number)

Returns a series with the specified number at the specified observation number if it is past the end.
Any values between the last value of the series and the specified future point of extension are filled in with the last value.

Example: To extend series two months after its original end (second parameter), with a 0.75 value at the end (third parameter): Extend(usrate0001, Endvalid(usrate0001)+Monthslength(2), 0.75)

For more information see: All about extending series

ExtendLastAsForecast(series)

Extends the series with the last valid value until the end of the calendar.

Example: add some other series, i.e., usrate0001 and below ExtendLastAsForecast(nolama0138)

This is implemented in the Macrobond formula language as:

ExtendLastAsForecast(series) = Join(series, FlagForecast(LastValid(series)), EndValid(series) + 1)

For more information see: All about extending series

ExtendLastYoYForecast(series) / ExtendLastYoYForecast(series, observation)

Extends the series using the % YoY change to calculate a forecast for the whole calendar range.

Example: ExtendLastYoYForecast(CutEnd(usgdp, Date(2020, 1, 1)))

Example: ExtendLastYoYForecast(usgdp, Endvalid(usgdp)+Quarterslength(3))

For more information see: All about extending series

ExtendLinear(series, observation, number)

Returns a series extended with the specified number using a linear interpolation from the end until the specified observation number.

Example: When you want to put at the end of the current year (second parameter) last value higher by 5% (third parameter): ExtendLinear(sp500_500, LastValid(EndOfYearAhead(0)), LastValid(sp500_500)*1.05) 

For more information see: All about extending series

ExtendToEndOfMonth(series)

Extends the series with the last value until the end of the month.

Example: ExtendToEndOfMonth(sek)

This is implemented in the Macrobond formula language as:

ExtendToEndOfMonth(series) = Extend(Trim(series), At(EndOfMonth(), EndValid(series)), LastValid(series)

For more information see: All about extending series

ExtendToEndOfQuarter(series)

Extends the series with the last value until the end of the quarter.

Example: ExtendToEndOfQuarter(sek)

This is implemented in the Macrobond formula language as:

ExtendToEndOfQuarter(series) = Extend(Trim(series), At(EndOfQuarter(), EndValid(series)), LastValid(series))

For more information see: All about extending series

ExtendToEndOfWeek(firstDayOfWeek, series)

Extends the series with the last value until the end of the week.

0 = Sunday, 1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday

Example: ExtendToEndOfWeek(4, sek)

This is implemented in the Macrobond formula language as:

ExtendToEndOfWeek(firstDayOfWeek, series) = Extend(Trim(series), At(EndOfWeek(firstDayOfWeek), EndValid(series)), LastValid(series))

For more information see: All about extending series

ExtendToEndOfYear(series)

Extends the series with the last value until the end of the year.

Example: ExtendToEndOfYear(sek)

This is implemented in the Macrobond formula language as:

ExtendToEndOfYear(series) = Extend(Trim(series), At(EndOfYear(), EndValid(series)), LastValid(series))

For more information see: All about extending series

Join(series1, series2)

Returns a series that joins two series at the end of series1.

Example:  join(cncons5420_old2015, cncons5420)

This is implemented in the Macrobond formula language as:

Join(series1, series2) = Join(series1, series2, EndValid(series1)+1)

Join(series1, series2, observation)

Returns a series that joins two series at the specified observation number.

Example:  join(cncons5420_old2015, cncons5420, Date(2020, 1, 1))

JoinScaled(series1, series2)

Returns a series that joins two series at the end of the series1 and scales the first series. Series need to overlap.

Example:  JoinScaled(fisurv0005, fisurv0716)

This is implemented in the Macrobond formula language as:

JoinScaled(series1, series2) = JoinScaled(series1, series2, EndValid(series1))

JoinScaled(series1, series2, observation)

Returns a series that joins two series at the specified observation number and scales the first series. Series need to overlap.

Example:  JoinScaled(fisurv0005, fisurv0716, Date(2019, 1, 1))

JoinScaledAppend(series 1, series 2) / JoinScaledAppend(series1, series2, observation)

Returns a series that joins two series at the end of the series1 and scales the second series.

Example:  JoinScaledAppend(fisurv0005, fisurv0716)

Example:  JoinScaledAppend(fisurv0005, fisurv0716, Date(2019, 1, 1))

JoinMoreHistory(series1, series2)

Returns a series of all observations of series1 complemented with all values of series2 that are before the start of series1.

Example:  JoinMoreHistory(ngprod0001, imf_q69466___zf)

This is implemented in the Macrobond formula language as:

JoinMoreHistory(series1, series2) = Join(series2, series1, StartValid(series1))

JoinMoreHistoryScaled(series1, series2)

Returns a series of all observations of series1 complemented with all values of series2 that are before the start of series1. The values of series2 are scaled so that they are equal at the beginning of series1. Series need to overlap.

Example:  JoinMoreHistoryScaled(ngprod0001, imf_q69466___zf)

This is implemented in the Macrobond formula language as:

JoinMoreHistoryScaled(series1, series2) = JoinScaled(series2, series1, StartValid(series1))

Lag(series, length)

Returns the series lagged by the specified length. The length is rounded to an integer.

Example: Lag(plgdp, -5) data moved 5 observations into the past

Example: Lag(plgdp, Quarterslength(5)) data moved 5 quarters into the future

Trim(series)

Returns a series where any null values at the start or end have been excluded.

Example: Trim(sek)

 

Logical functions

Count(series)

Returns the number of values that are True.

Example: Count(sp500_500)

Count(series, window)

Returns the number of values that are True in a window of the specified length.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: Count(sp500_500, Monthslength(6))

If(condition, value1, value2)

Returns the first value if condition is True and the second value if it is False.

Example: If value is higher than 8, draw 1, otherwise don't draw anything: If(sek > 8,1, Null())

IsForecast(value)

Returns True if a value is a forecast and otherwise False.

Example: IsForecast(unpoppr276constant)

Example: Erase values from points in time which are forecasted in first series: if(isForecast(gbfcst6701), Null(), gbpric24651)

IsNull(value)

Returns True if a value is null and otherwise False.

Example: isNull(sp600_20201080tr)

Example: !isNull(sp600_20201080tr) ! sign is a logical 'not'

RunLength(series)

Counts how many observations in a row that have been True.

Example: runlength(sp500_500)

Example: RunLength(Counter()>EndValid(sek)-34) it assigns the number 34 to the last observation, 33 to the second last, etc.

This is implemented in the Macrobond formula language as:

RunLength(series) =
let
 .a = AggregateSum(if (series, 1, 0))
 .s = Null0(series)
 .c = FillNullWithPrevious(if (!.s & lag(.s, 1), .a, null()))
in
 if (IsNull(series), Null(), .a - Null0(.c))
end

 

Financial

BollingerLower(series, nStdDev, window)

Returns the lower Bollinger band using a window of the specified length and number of standard deviations.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: BollingerLower(sek, 2, MonthsLength(12))

This is implemented in the Macrobond formula language as:

BollingerLower(series, nStdDev, window) = Mean(series, window)-nStdDev*Sqrt(Variance(series, window))

BollingerUpper(series, nStdDev, window)

Returns the upper Bollinger band using a window of the specified length and number of standard deviations.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: BollingerUpper(sek, 2, MonthsLength(12))

This is implemented in the Macrobond formula language as:

BollingerUpper(series, nStdDev, window) = Mean(series, window)+nStdDev*Sqrt(Variance(series, window))

COP(series, length)

Returns the percentage change over the number of specified observations.
This is the same calculation as is done in the method 'Change over period %' in the Rate of change analysis.

Example:  Cop(usnaac0673, YearsLenght(1))

cop(series, length) always works on the number of observations - the input must be a constant value. yearlength(), quarterlength(), monthlength() which can be used here as 'length' tells you how many numbers of observations there are in a typical year, month etc. They are constant values.
If you want something that gives you the number of observation per each year, use for example:
EndOfYear()-StartOfYear()
but please note that you cannot pass this directly into the 'cop' function since it takes a constant number and not a time series as the length. You can calculate it earlier in anther Formula analysis.

This is implemented in the Macrobond formula language as:

COP(series, length) = 
let
   .lagged = lag(series, length)
in
    CutEnd((series-.lagged)/Abs(.lagged)*100, End(series)+1)
end

Drawdown(series)

This calculates the peak-to-trough decline [as 100*(peak - value)/peak] since the last peak or since the first value. The output is expressed as 'positive' percentage: 50 should be interpreted as a 50% decline since the last peak.

This formula calculates maximum drawdown (from all-time high).

Example:  Drawdown(sp500_500)

FMACD(series, short, long)

Returns the fast-moving average convergence divergence.

Examples:  FMACD(standardize(sek), 13, 21); FMACD(euronext_eco2024n_cl, 12, 26)

InvestmentStrategy(marketValue, conditionWhenInMarket)

Calculate the value of an investment by compounding the returns of the marketValue series during the periods when the conditionWhenInMarket is True. When out of the market, the value is not changed.

Example: Invest in S&P 500 only during the first six months each year: InvestmentStrategy(sp500_500tr, Month() <= 6)

This is implemented in the Macrobond formula language as:

InvestmentStrategy(marketValue, conditionWhenInMarket) =
let
  .ReturnWhenInMarket = if (Lag(conditionWhenInMarket, 1), COP(marketValue, 1)/100+1, 1)
in
  AggregateProduct(.ReturnWhenInMarket)
end

InvestmentStrategy(marketValue, buyCondition, sellCondition)

Calculate the value of an investment by compounding the returns of the marketValue series during the periods between when the buyCondition becomes True until the sellCondition becomes True. When out of the market, the value is not changed.

Example: Invest in S&P when it is 10% over the mean of the last 200 observations and sell when it is 10% below the mean: InvestmentStrategy(sp500_500tr, sp500_500tr > Mean(sp500_500tr, 200)*1.1, sp500_500tr < Mean(sp500_500tr, 200)*0.9)

This is implemented in the Macrobond formula language as:

InvestmentStrategy(marketValue, buyCondition, sellCondition) =
let
  .InMarketPeriods = Signal(buyCondition, sellCondition)              // 1 = invested, 0 = not invested
  .ReturnWhenInMarket = if (Lag(.InMarketPeriods, 1), COP(marketValue, 1)/100+1, 1)
in
  AggregateProduct(.ReturnWhenInMarket)
end

InvestmentStrategy(inMarketValue, outOfMarketValue, buyCondition, sellCondition)

Calculate the value of an investment by compounding the returns of the marketValue series during the periods between when the buyCondition becomes True until the sellCondition becomes True

Example: Invest in S&P when it is 10% over the mean of the last 200 observations, sell when it is 10% below the mean and invest in a bond index when out of the market: InvestmentStrategy(sp500_500tr, djcfin30tr, sp500_500tr > Mean(sp500_500tr, 200)*1.1, sp500_500tr < Mean(sp500_500tr, 200)*0.9)

This is implemented in the Macrobond formula language as:

InvestmentStrategy(inMarketValue, outOfMarketValue, buyCondition, sellCondition) =
let
  .InMarketPeriods = Signal(buyCondition, sellCondition)              // 1 = invested, 0 = not invested
  .ReturnWhenInMarket = if (Lag(.InMarketPeriods, 1), COP(inMarketValue, 1), COP(outOfMarketValue, 1))/100+1
in
  AggregateProduct(.ReturnWhenInMarket)
end

Note the condition is thus lagged by 1.

Rsi(series, window)

Returns the relative strength index of the series using a window of the specified length.
The relative strength is calculated by the method described by J. Welles Wilder 1978 and uses an exponential smoothing.

For more information how parameter window works, what happens at the start of series and what can you do with it see Window parameter (length).

Example: rsi(sp500_500, 25)

Signal(onCondition, offCondition)

Calculate a signal based on conditions when the signal is turned on (1) and when it is turned off (0). If both conditions are 'true' the expected result is 0. The method works best when the off and on conditions are mutually exclusive.

Example:  Signal(sek>8, sek<8)

This is implemented in the Macrobond formula language as:

Signal(onCondition, offCondition) =
let
  .OnAndOff = if (offCondition, 0, if (onCondition, 1, null())) // 1 = signal, 0 = no signal
in
  FillNullWithPrevious(.OnAndOff) // 1 = signal, 0 = no signal
end

SMACD(series, short, long, signal)

Returns the exponential average of the fast-moving average convergence divergence.

Examples: SMACD(standardize(sek), 13, 14, 2); SMACD(euronext_eco2024n_cl, 12, 26, 9)

This is implemented in the Macrobond formula language as:

SMACD(series, short, long, signal) = EMean(FMACD(series, short, long),2/(signal+1))

TotalReturnFromShortYield(yieldSeries, maturityInYears)

Estimates the total return from yield when there are no coupons using Actual/360 day count convention.

Example:  TotalReturnFromShortYield(us3mgov, 0.25)

This is implemented in the Macrobond formula language as:

TotalReturnFromShortYield(yieldSeries, maturityInYears) = AggregateProduct((yieldSeries*Days(Counter()-1, Counter())/360 - Momentum(yieldSeries, 1)*maturityInYears)/100 + 1)

TotalReturnFromYield(yieldSeries, duration)

Estimates the total return from yield given the duration.

Example:  TotalReturnFromYield(us10ygov, 10)

This is implemented in the Macrobond formula language as:

TotalReturnFromYield(yieldSeries, duration) = AggregateProduct((yieldSeries/ObservationCountPerYear()-Momentum(yieldSeries, 1) * duration ) / 100 + 1)

 

Smoothing

Overview

The Smoothing analysis is used for minimizing the fluctuations of a time series. You can choose from several smoothing methods which are described below.

Settings

Method

None

This method is used to include a series without any calculation applied.

Moving average

The value at each point is calculated as the average of the series over a specified window length. If there are any missing values within the window, the average will use fewer values.


y t = i = 0 w - 1 x t - i i = 0 w - 1 IsValid ( x t - i )

where w is the window length and IsValid is a function that is 1 for valid values and 0 for missing values.

Moving average, cenetred

The centered moving average is calculated symmetrically around each point, except towards the ends, where it becomes increasingly asymmetric. The calculation is different depending on whether the window length is odd or even. When the window length, w, is an odd number, the calculation is similar to a lagged ordinary moving average:


h = w - 1 2

 


y t = i = 0 w - 1 x t - 1 - h i = 0 w - 1 IsValid x t - i - h

When the window length, w, is an even number, the calculation is a second order moving average. It is calculated in the same way as when w is odd, but with a weight of ½ for the outer observations of the window and h = w 2  .

Moving average, exponential

This calculates an exponential moving average. The exponential factor, α, is calculated from the specified number of observations, f, as follows:


α = 2 f + 1

The smoothed series is calculated using a recursive formula:


y 0 = x 0

   


y t = α y t - 1 + 1 - α x t

HP filter

This method uses the Hodrick-Prescott symmetric filter as described by Hodrick and Prescott (1997). The factor, λ, can be specified either directly or by using the frequency adjusted power rule described by Ravn and Uhlig (2002). When the frequency adjusted rule is used, the λ is calculated from f as follows:


λ = 1 6 0 0 p 4 f

where p is the number of observations per year for the frequency at hand.

A factor of 4 is recommended by Ravn and Uhlig. A factor of 2 will give you the original Hodrick and Prescott values.

We calculate the HP filter according to Hodrick–Prescott filter - Wikipedia, which is the same method as can be found in MATLAB and EViews.

The rule of thumb is to use 𝜆=1600 for quarterly data; 𝜆=14400 for monthly data; and 𝜆=100 for yearly data.

HP filter, one-sided

The one-sided Hodrick-Prescott filter is calculated by using only the historical data available at each point in time. Thus, the last value is the same as for the full HP filter.

The rule of thumb is to use 𝜆=1600 for quarterly data; 𝜆=14400 for monthly data; and 𝜆=100 for yearly data.

CF filter, stationary

This uses the Christiano-Fitzgerald full sample asymmetric band-pass filter as described by Christiano and Fitzgerald (1999). Use this version of the CF filter when the series is stationary and there is no drift. If there is a trend in the series, you may want to remove it using the detrend analysis to before applying this filter.

BK filter

This method uses the Baxter-King symmetric band-pass filter as described by Baxter and King (1995). The specified length determines the lead/lag length of the filter and is equal to number of observations lost at each end of the filtered series. You should specify the minimum and maximum periods of oscillation.

Length

The window and period length can be expressed as many observations or as many units of the specified time unit (Year, Quarter, Month etc.), which is then converted to a number of observations based on the frequency of the data.

Standard deviation

When selected, the application will calculate a pair of series that forms a confidence band around the mean so that the specified percentage of the values are within the band if the data is normally distributed. The corrected sample standard deviation, s, is calculated as the deviation from the smoothed line.

The empirical rule, states that for normally distributed data  ~68.3% of the values are within the a band of 1 standard deviation on each side, ~95.4% are within 2 standard deviations and ~99.7% are within 3 standard deviations.

Formally, the band is μ±f∙s, where μ is the smoothed series, c is the confidence coefficient, 


f = Φ - 1 1 0 0 - c 2 + c 1 0 0

 and Φ is the cumulative normal distribution function.

Coefficient

The confidence coefficient used for the standard deviation confidence band.

Examples

Smoothing with HP filter

The Smoothing analysis is used here to remove the cyclical component of the BIS Residential Price Index. To do so, we calculated the HP Filter of the BIS index, and included the original series as output.

Moving average

Here, we calculated 3 months moving average on the Retail Trade series, to smooth it and make it easier to read.

Questions

How do I calculate a moving average / rolling mean?

There are two main possibilities to calculate rolling mean:

  • In Smoothing analysis:

Add 'Moving average' as a calculation and set the length.

  • With formula:

You can use the formula:

Mean(series, window)

Example:

Mean(spx, Monthslength(3))

This will calculate a three month rolling mean for the S&P 500.

For more information about Formula language see Formula analysis.