## Introduction

The purpose of the Scalar analysis is to do calculations across some time series at specific points or ranges in time and produce category series.

As an example, assume that we have three time series called S1, S2 and S3. We want to look at the values in 1994 and 1999. This can be done by specifying two “Value at” calculations in the Scalar analysis:

With the setting “One series per calculation,” this will take the values for 1994 and 1999 and produce two category series:

The order of the series in the Input series section defines the order of the values in the produced category series. You can adjust the order by dragging the handle to the left of the list or sort them alphabetically by pressing the Sort button.

These category series can then be used in a number of ways such as in charts, tables and exporting to Excel. For example, here is a Category table, Bar chart, Category chart and Category scatter chart:

## Groups

Sometimes you do not want just one series for each calculation across all input series. The input series might, for instance, describe two aspects of something. In that case you probably want to divide the series into groups in the Scalar analysis. This can be done in two ways:

• New group after every n series.
• Partition into n series.

Which way you select depends on what is the most convenient order of the series.

Here is an example where the setting “New group after every 3 series” has been used. You can see which group each series will belong to by looking at the number of the Group column in the Input series table.

This will produce four series like this:

By using the same input data, but selecting “Partition into 2 series” instead, like this:

There will be four series:

There is a good example in the chart library of how groups can be used: Macrobond chart library : Examples/Comparing values/Scatter chart comparing two parameters for a number of countries

## One series per input

With the “One series per input” option, there will be one category series per each input series and the values in each series will correspond to the specified list of calculations.

This can, for example, be useful when you want to compare a number of series at some points in time. With settings like this:

There will be three category series calculated as follows:

Here is what the result looks like in a column chart:

## Calculations

### Included time series

You can select what time series to include in the calculations. All series are included by default, but you can un-check series in the the "Include" column.

New series will be included automatically unless you un-check "Include new series automatically". This setting was added in version 1.18.

### Points in time and ranges

For many calculations you can specify a point in time or a time range.

If a relative point in time is specified, this will refer to the end of the calendar, which is based on the range of valid values of all input series. If no point in time is specified, the time of the last valid value will be used. If you want to reference the last point of the calendar, you can use a relative reference like “+0”.

When a range is specified, relative points in time are also relative to the end of the calendar, but there is one exception: when only a relative starting point is specified and no end point, the end point will be the last valid value and the starting point will be relative to that point in time instead of the end of the calendar. If you still want to reference the calendar for your starting point in that case, you can use an end point like “+0”.

### Measures of change

Many of the calculation methods offer the option to calculate a rate of change as Value, Percentage or Logarithmic. These calculations are done in this way:

$\mathrm{value}=y\left[t\right]-y\left[t-n\right]$
$\mathrm{percentage}=100\frac{y\left[t\right]-y\left[t-n\right]}{|y\left[t-n\right]|}$
$\mathrm{logarithmic}=100\text{ln}\frac{y\left[t\right]}{y\left[t-n\right]}$
$\mathrm{annualRateValue}=\frac{c}{h}\sum _{i=1}^{h}\text{z}\left(t+1-i\right)$
$\mathrm{annualRatePercent}=\text{100}\left({\left(\frac{\text{z}\left(t\right)}{\text{z}\left(t-h\right)}\right)}^{\frac{c}{h}}-1\right)$

where c is the typical number of observations during one year.

### Calculation methods

#### Open, High, Low, Close

The first, highest, lowest or last value of the specified range.

#### Mean, Median, Standard deviation

The mean, median or standard deviation value of the range.

#### Last

The last valid value of the series.

#### Last common

The value of the last point where there is a value in all of the series used in the calculation.

This method is available in version 1.18 and later.

#### Value at

The value at a specific point in time. If a date that does not exist in the calendar, the first valid previous date will be used.

#### Percentile

The specified percentile of the range.

#### Lower, Upper tail mean

The mean of the values in the upper or lower percentile as specified by the percentage.

#### Year, Quarter, Month, Week to date

Performance from the start of the period to the specified date. The performance is measured as the change compared to the last value of the previous period.
You can select to express the performance as the change in value, percentage change or logarithmic change.

#### Performance since

Performance from a specified date to another date. The performance is measured as the change compared to the last value of the previous period.

You can select to express the performance as the change in value, percentage change or logarithmic change.

#### Years, Quarters, Months, Weeks back

The change from a number of periods back to the specified date.

You can select to express the change as the change in value, percentage change or logarithmic change.

For years and quarters, this is the same as using the “Rate of change since” method and specifying the start of the range as “-1y” or “-1q”.

#### Rate of change since

The rate of change between two points in time.

You can select to express the change as the change in value, percentage change or logarithmic change.

#### Percentage proportion

The proportion, as a percentage, of each series compared to the sum at a specified point in time.

## Examples in the Macrobond chart library

You can find some examples where the Scalar analysis is used in the Macrobond chart library: