hpipy.price_model.RepeatTransactionModel#

class hpipy.price_model.RepeatTransactionModel(hpi_data, **kwargs)[source]

Bases: BaseHousePriceModel, TimeMatrixMixin

Repeat transaction house price model.

Methods

__init__

Initialize base house price model.

create_time_matrix

Create a time matrix from a dataframe of repeat transactions.

fit

Fit the repeat transaction model and generate index coefficients.

Attributes

Parameters:
  • hpi_data (TransactionData)

  • kwargs (Any)

fit(estimator='base', log_dep=True, **kwargs)[source]

Fit the repeat transaction model and generate index coefficients.

Parameters:
  • estimator (str, optional) – Estimator type. One of “base”, “robust”, or “weighted”. Defaults to “base”.

  • log_dep (bool, optional) – Log transform the dependent variable. Defaults to True.

  • kwargs (Any)

Returns:

The repeat transaction house price model.

Return type:

Self

__init__(hpi_data, **kwargs)

Initialize base house price model.

Parameters:
  • hpi_data (TransactionData)

  • kwargs (Any)

Return type:

None

create_time_matrix(repeat_trans_df)

Create a time matrix from a dataframe of repeat transactions.

This function assumes the dataframe contains columns “period_1” and “period_2” that represent a pair of repeat transactions. The resulting dataframe consists of rows for each transaction pair and columns for each time period, with -1 indicating the first transaction in a pair, 1 indicating the second transaction in a pair, and 0 otherwise.

Parameters:

repeat_trans_df (pd.DataFrame) – Input DataFrame. Must contain “period_1” and “period_2” columns containing integer values representing periods (i.e., time series expressed as integer).

Returns:

DataFrame with columns ‘time_x’, where each row

represents a transaction pair and ‘x’ is a time period between the minimum and maximum periods in the input data.

Return type:

pd.DataFrame

coefficients: DataFrame
model_obj: Any
periods: DataFrame
base_price: float
params: dict[str, Any]