Revision Metrics#

Revision metrics assess how index values change as new data becomes available. We will demonstrate how to calculate and visualize revision metrics.

Basic Setup#

First, we will import the necessary modules and load some sales data and create a series of indices:

>>> from hpipy.datasets import load_seattle_sales
>>> from hpipy.price_index import RepeatTransactionIndex

>>> df = load_seattle_sales()

>>> hpi = RepeatTransactionIndex.create_index(
...     trans_data=df,
...     prop_id="pinx",
...     trans_id="sale_id",
...     price="sale_price",
...     date="sale_date",
...     periodicity="M",
...     estimator="robust",
...     log_dep=True,
...     smooth=True,
... )

>>> hpi_series = hpi.create_series(train_period=24, max_period=30)

Calculating Revision#

Calculate the revision of the index using the revision function:

>>> from hpipy.utils.metrics import revision

>>> rev = revision(hpi_series)
>>> rev.round(5).head()
   period     mean   median
0       1  0.00000  0.00000
1       2 -0.16127 -0.24276
2       3 -1.10777  0.03733
3       4 -2.15903 -1.22027
4       5 -1.57049 -1.09691