# Analyzing Econometric Datasets with Calculated Series

## Summary

Calculated values in **ChartLab**
are useful for creating multiple visualizations from one set data. ATSD
supports a range of in-built functions which allow end-users to manipulate a dataset.

The St. Louis branch of the Federal Reserve branch maintains Federal Reserve Economic Data (FRED), an
open-access platform for analyzing the data collected and published by the Federal Reserve. One important metric tracked
by FRED is **CPIAUCSL**: Consumer Price Index, or CPI. The Consumer Price Index tracks inflation by measuring the costs of goods.

## Problem Brief

Replicate and modify the FRED CPI visualization using **ChartLab**.

Modify the FRED visualization by clicking **EDIT GRAPH** and selecting a transformation. To learn more about how any of the metrics are calculated from the underlying data, What Formulas are Used to Calculate Growth Rates?
provides information about the underlying mathematics.

A brief tutorial on data modification in the FRED interface is shown below:

- Open the transformation interface by clicking
**EDIT GRAPH**.

- From the
**Units**drop-down list, select a transformation.

- Modify any sub-features of the transformation as needed.

## Solution

A side-by-side comparison of each feature of the Consumer Price Index transformation is shown below, as well as links to the accompanying visualizations.

Note that because ATSD supports storing historical data from the year 1970 onward while the Federal Reserve tracks data from 1947 onward, small scale differences are expected in the outputs of each graph.

## Index

- Consumer Price Index
- Monthly Change
- CPI Calculated from a Variable Baseline
- Change from a Year Ago
- Monthly Percent Change
- Monthly Percent Change from a Year Ago
- Compounded Annual Rate of Change
- Continuously Compounded Rate of Change
- Continuously Compounded Annual Rate of Change
- Natural Logarithm of CPI
- Max Index

### Consumer Price Index

**Figure 1**: Consumer Price Index for Baseline Year 1982 (1947-2017) **FRED**

**Figure 1**: Consumer Price Index (1970-2017) **ATSD**

Return to the Index

### CPI Calculated from a Variable Baseline

The index is the baseline year when performing calculations. Years showing an increase in the cost of consumer goods are therefore greater than 100.00 while years exhibiting deflation in the cost of consumer goods based on the index are less than 100.00.

**Figure 2.2**: CPI Calculated from a Variable Baseline (1990-07-01) **FRED**

**Figure 2.1**: CPI Calculated from a Variable Baseline (1990-07-01) **ATSD**

In **ChartLab**, use the drop-down list at the top of the visualization to select the year to be used as a baseline, or hardcode
a year not included in the drop-down list by modifying one of the dates in the `keyDates`

list.

Key Components of This Visualization:

Open the ChartLab visualization shown above and view the Editor window to see these features of the chart.

- The list
`keyDates`

contains the same dates as the FRED chart referenced in the Problem Brief:

```
list keyDates = 1970-11-01,
1973-11-01, 1975-03-01,
1980-01-01, 1980-07-01,
1981-07-01, 1982-11-01,
1990-07-01, 1991-03-01,
2001-03-01, 2001-11-01,
2007-12-01, 2009-06-01
endlist
```

- These dates are displayed in the drop-down list. The dates represent the official start dates of recessions throughout U.S. history.

The syntax for this drop-down list is shown below:

```
[dropdown]
on-change = widget.config.series[0].value = this.value; widget.replaceSeries(widget.config.series);
for date in keyDates
[option]
text = Index (Scale to 100 for @{date})
value = value("cpi") / value("cpi_@{date}") * 100 || null
endfor
```

For more information about the above syntax see the Charts Documentation.

By modifying any of the dates contained in the `keyDates`

list above, the user can select any date to set as the
baseline value, and the `value`

equation contained in the `[option]`

portion of the `[dropdown]`

configuration above uses
a simple formula to establish the new index.

The `on-change`

setting defines this newly calculated series, and is explained piecewise below:

`widget.config.series[0]`

selects the series to be replaced. Series are indexed beginning with`0`

and increasing by a single step for each additional series (`0`

,`1`

,`2`

,`3`

....). There is only one underlying series in this visualization.`value = this.value`

assigns a user-defined value, the option selected in the drop-down list, as the value for the series defined in the the`widget.config`

portion of the script.`this`

defines the specific object to be modified, in this case the drop-down list.`widget.replaceSeries(widget.config.series)`

replaces the underlying values of the original series defined as a parameter of the function, with the newly calculated values defined in the`[option]`

setting.

Return to the Index

### Monthly Change

The monthly numerical change in CPI value over the observed period.

**Figure 3.1**: Monthly Change (1947-2017) **FRED**

**Figure 3.2**: Monthly Change (1970-2017) **ATSD**

Underlying Formula:

```
value = delta("cpi", "1 month")
```

- This setting uses the
`delta`

function.

Return to the Index

### Change From a Year Ago

The numerical change in CPI value from the same month of the previous year.

**Figure 4.1**: Change From Previous Year (1947-2017) **FRED**

**Figure 4.2**: Change From Previous Year (1970-2017) **ATSD**

Underlying Formula:

```
value = var v = value('cpi'); var p = value('prev_cpi'); if(p != null && v != null) return v - p;
```

- This setting uses a second underlying series to select values of the Consumer Price Index from one year ago using a
`time-offset`

setting and comparing the data to the current year values.

Return to the Index

### Monthly Percent Change

The monthly percentile change in CPI value over the entire observed period.

**Figure 5.1**: Monthly Percent Change (1947-2017) **FRED**

**Figure 5.2**: Monthly Percent Change (1970-2017) **ATSD**

Underlying Formula:

```
value = (value("cpi") / previous("cpi") - 1) * 100
```

- This setting uses the
`previous()`

function.

Return to the Index

### Monthly Percent Change From a Year Ago

The percentile change in CPI from the same month of the previous year.

**Figure 6.1**: Monthly Percent Change From Previous Year (1947-2017) **FRED**

**Figure 6.2**: Monthly Percent Change From Previous Year (1970-2017) **ATSD**

Underlying Formula:

```
value = var v = value('cpi'); var p = value('prev_cpi'); if(p!=null && v!=null) return (v / p - 1) * 100
```

Return to the Index

### Compounded Annual Rate of Change

The mean annual rate of change for the Consumer Price Index.

**Figure 7.1**: Compounded Annual Rate of Change (1947-2017) **FRED**

**Figure 7.2**: Compounded Annual Rate of Change (1970-2017) **ATSD**

Underlying Formula:

```
value = (Math.pow(( value("cpi") / previous("cpi") ), 12) - 1) * 100
```

- This setting uses the built-in
`Math`

javascript object.

Return to the Index

### Continuously Compounded Rate of Change

The mean rate of change for the Consumer Price Index compounded continuously.

**Figure 8.1**: Continuously Compounded Rate of Change (1947-2017) **FRED**

**Figure 8.2**: Continuously Compounded Rate of Change (1970-2017) **ATSD**

Underlying Formula:

```
value = ( Math.log(value("cpi")) - Math.log(previous("cpi")) ) * 100
```

Return to the Index

### Continuously Compounded Annual Rate of Change

The annual rate of change compounded continuously for the observed period.

**Figure 9.1**: Continuously Compounded Annual Rate of Change (1947-2017) **FRED**

**Figure 9.2**: Continuously Compounded Annual Rate of Change (1970-2017) **ATSD**

Underlying Formula:

```
value = ( Math.log(value("cpi")) - Math.log(previous("cpi")) ) * 100 * 12
```

Return to the Index

### Natural Logarithm of CPI

The logarithm of each value set to base of the mathematical constant *e*

**Figure 10.1**: Natural Logarithm of CPI (1947-2017) **FRED**

**Figure 10.2**: Natural Logarithm of CPI (1970-2017) **ATSD**

Underlying Formula:

```
value = Math.log(value("cpi"))
```

Return to the Index

### Max Index

Indexes the Consumer Price Index by maximum and most recent value.

**Figure 11.1**: CPI with Most Recent Data as Index (1947-2017) **FRED**

**Figure 11.2**: CPI with Most Recent Data as Index (1970-2017) **ATSD**

Underlying Formula:

```
value = value("cpi") / value("cpi_max") * 100 || null
```

Return to the Index