Learn R Programming

 

hpiR

This package intends to simplify and standardize the creation of house price indexes in R. It also provides a framework for judging the quality of a given index by testing for predictive accuracy, volatility and revision. By providing these metrics various index methods (and estimators) can be accurately compared against each other.

While there are a (ever-increasing) variety of methods and models to use in house price index creation, this initial version (0.3.0) focuses on the two most common: repeat sales (transactions) and hedonic price. Base, robust and weighted estimators are provided when appropriate. Additionally, a new method using random forests and a post model interpretability method – partial dependence plots – is also used.

The package also includes a dataset of single family and townhome sales from the City of Seattle during January 2010 to December 2016 time period.

Please see the vignette for more information on using the package.

Also, please log issues or pull requests on this github page.

Installation

You can install hpiR from github with:

Install the released version from CRAN

  install.packages("hpiR")

Development version from GitHub:

  #install.packages("devtools")
  devtools::install_github("andykrause/hpiR")

Example

This is a basic example which shows you how to solve a common problem:


  library(hpiR)

  # Load prepared data
  data(ex_rtdata)

  # Create an index
  hpi <- rtIndex(trans_df = ex_rtdata,
                 estimator = 'robust',
                 log_dep = TRUE,
                 trim_model = TRUE,
                 smooth = TRUE)

Copy Link

Version

Install

install.packages('hpiR')

Monthly Downloads

225

Version

0.3.2

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Andy Krause

Last Published

April 1st, 2020

Functions in hpiR (0.3.2)

buildForecastIDs

Create the row IDs for forecast accuracy
calcAccuracy

Calculate the accuracy of an index
buildForecastIDs.rtdata

Create the row IDs for forecast accuracy (rt approach)
calcInSampleError

Calculate index errors in sample
calcInSampleError.heddata

Calculate index errors in sample (hed approach)
buildForecastIDs.heddata

Create the row IDs for forecast accuracy (hed approach)
calcInSampleError.rtdata

Calculate index errors in sample (rt approach)
calcForecastError

Calculate the forecast accuracy of series of indexes
calcRevision

Calculate revision values of an index
hedModel

Estimate hedonic model for index creation
hedCreateTrans

Create data for `hed` approach
hedIndex

Create a full index object by hedonic approach
ex_sales

Subset of Seattle Home Sales
plot.seriesaccuracy

Plot method for `seriesaccuracy` object
plot.serieshpi

Plot method for `serieshpi` object
rtModel.robust

Repeat transaction model approach with robust estimator
createSeries

Create a series of indexes
calcSeriesVolatility

Calculate volatility of a series of indexes
seattle_sales

Seattle Home Sales
dateToPeriod

Convert dates to a relative period
rtModel.base

Repeat transaction model approach with base estimator
createKFoldData.rtdata

Create data for KFold error test (rt approach)
calcSeriesAccuracy

Calculate the accuracy of a series of indexes
smoothIndex

Smooth an index
createKFoldData

Create data for KFold error test
hedModel.base

Hedonic model approach with base estimator
matchKFold.heddata

Helper function to make KFold data
matchKFold

Helper function to make KFold data
hedModel.robust

Hedonic model approach with robust estimator
hpiModel.hed

Specific method for hpi modeling (hed) approach)
hedModel.weighted

Hedonic model approach with weighted estimator
calcVolatility

Calculate index volatility
hpiModel.rf

Specific method for hpi modeling (hed) approach)
plot.hpiindex

Plot method for `hpiindex` object
rtTimeMatrix

Create model matrix for repeat transaction approach
rfModel.pdp

Random forest model approach with pdp estimator
rtModel.weighted

Repeat transaction model approach with weighted estimator
rfModel

Estimate random forest model for index creation
plot.indexvolatility

Plot method for `indexvolatility` object
plot.seriesrevision

Plot method for `seriesrevision` object
hpiModel

Wrapper to estimate model approaches (generic method)
rfIndex

Create a full index object by random forest approach
checkDate

Validate the date argument
smoothSeries

Smooth all indexes in a series
modelToIndex

Convert model results into a house price index
hpiR

hpiR: A package for house price indexes
matchKFold.rtdata

Helper function to make KFold data
rtCreateTrans

Create transaction data for rt approach
plot.hpi

Plot method for `hpi` object
plot.hpiaccuracy

Plot method for `hpiaccuracy` object
hpiModel.rt

Specific method for hpi modeling (rt approach)
rfSimDf

Create simulation data for Random forest approach
rtIndex

Create a full index object by repeat transaction approach
rtModel

Estimate repeat transaction model for index creation
calcKFoldError

Calculate index error with FKold (out of sample)