hpipy.price_index.RepeatTransactionIndex#

class hpipy.price_index.RepeatTransactionIndex(**kwargs)[source]

Bases: BaseHousePriceIndex

Repeat transaction house price index.

Implements the repeat transaction methodology for constructing house price indices. It uses pairs of transactions for the same property to estimate price changes over time, controlling for property-specific characteristics that remain constant between sales.

Parameters:
  • data – TransactionData. The transaction data used to construct the index.

  • model – BaseHousePriceModel. The underlying price model used to estimate the index.

  • kwargs (Any)

name

The names of the time periods in the index.

Type:

pd.Series

periods

The time periods covered by the index.

Type:

pd.Series

value

The index values.

Type:

pd.Series

index

The index values in an alternate format.

Type:

Any

imputed

Boolean array indicating which periods were imputed.

Type:

np.ndarray

smooth

Smoothed version of the index values.

Type:

Any

volatility

Volatility measures for the index.

Type:

pd.DataFrame

volatility_smooth

Smoothed volatility measures.

Type:

pd.DataFrame

revision

Revision measures for the index.

Type:

pd.DataFrame

revision_smooth

Smoothed revision measures.

Type:

pd.DataFrame

Example

>>> import pandas as pd
>>> from hpipy.price_index import RepeatTransactionIndex
>>> # Create sample transaction data.
>>> data = pd.DataFrame({
...     "property_id": [1, 1, 2],
...     "transaction_id": [1, 2, 3],
...     "price": [200000, 250000, 300000],
...     "date": pd.to_datetime(["2020-01", "2021-01", "2020-02"]),
... })
>>> # Create index.
>>> index = RepeatTransactionIndex.create_index(
...     data,
...     prop_id="property_id",
...     trans_id="transaction_id",
...     price="price",
...     date="date",
...     periodicity="Y",
...     min_date="2020-01",
...     max_date="2021-02",
...     estimator="robust",
...     log_dep=True,
... )

Methods

__init__

Initialize base house price index.

coef_to_index

Convert coefficients to an index.

create_index

Create the index.

create_series

Create a series from the index.

from_model

Create an index from a house price model.

get_data

Get repeat transaction data.

get_model

Get repeat transaction model.

smooth_index

Smooth the index.

smooth_series

Apply smoothing to all indices.

Attributes

static get_data()[source]

Get repeat transaction data.

Return type:

type[TransactionData]

static get_model()[source]

Get repeat transaction model.

Return type:

type[BaseHousePriceModel]

__init__(**kwargs)

Initialize base house price index.

Parameters:

kwargs (Any)

Return type:

None

static coef_to_index(coef_df, log_dep, base_price=1)

Convert coefficients to an index.

Parameters:
  • coef_df (pd.DataFrame) – Coefficients.

  • log_dep (bool) – Log dependent variable.

  • base_price (float, optional) – Base price. Defaults to 1.

Returns:

Index and imputed values.

Return type:

tuple[np.ndarray, np.ndarray]

classmethod create_index(trans_data, prop_id=None, trans_id=None, price=None, seq_only=True, max_period=None, smooth=False, periodicity=None, min_date=None, max_date=None, adj_type=None, **kwargs)

Create the index.

Parameters:
  • trans_data (TransactionData | PeriodTable | pd.DataFrame) – Input transaction data.

  • prop_id (str | None, optional) – Property identifier. Defaults to None.

  • trans_id (str | None, optional) – Transaction identifier. Defaults to None.

  • price (str | None, optional) – Price column name. Defaults to None.

  • seq_only (bool, optional) – Sequential only. Defaults to True.

  • max_period (int | None, optional) – Maximum index period. Defaults to None.

  • smooth (bool, optional) – Smooth the index. Defaults to False.

  • periodicity (str | None, optional) – Periodicity of the index. Defaults to None.

  • min_date (str | None, optional) – Minimum date for the index. Defaults to None.

  • max_date (str | None, optional) – Maximum date for the index. Defaults to None.

  • adj_type (str | None, optional) – Adjustment type. Defaults to None.

  • **kwargs – Additional keyword arguments.

Returns:

Index object.

Return type:

Self

create_series(train_period=12, max_period=None, **kwargs)

Create a series from the index.

Parameters:
  • train_period (int, optional) – Train period for the series. Defaults to 12.

  • max_period (int | None, optional) – Maximum period for the series. Defaults to None.

  • **kwargs – Additional keyword arguments.

Returns:

Index object.

Return type:

Self

classmethod from_model(model, trans_data=None, max_period=None, smooth=False, **kwargs)

Create an index from a house price model.

Parameters:
  • model (BaseHousePriceModel) – House price model object.

  • trans_data (TransactionData | None, optional) – Transaction data object. Defaults to None.

  • max_period (int | None, optional) – Maximum period for the index. Defaults to None.

  • smooth (bool, optional) – Smooth the index. Defaults to False.

  • **kwargs – Additional keyword arguments.

Returns:

Index object.

Return type:

Self

smooth_index(order=3, in_place=False)

Smooth the index.

Parameters:
  • order (list[int] | int, optional) – Smoothing order. Defaults to 3.

  • in_place (bool, optional) – Smooth in place or return new object. Defaults to False.

Returns:

Smoothed index or new smoothed index object.

Return type:

Self | pd.Series

smooth_series(order=3)

Apply smoothing to all indices.

Parameters:

order (int) – Defaults to 3.

Returns:

Index object.

Return type:

Self

data: TransactionData
model: BaseHousePriceModel
name: Series
periods: Series
value: Series
index: Any
imputed: ndarray
smooth: Any
accuracy: DataFrame
accuracy_smooth: DataFrame
volatility: DataFrame
volatility_smooth: DataFrame
revision: DataFrame
revision_smooth: DataFrame