Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

An R package for making repeat-sales matrices

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

marberts/rsmatrix

Repository files navigation

CRAN statusrsmatrix status badgeR-CMD-checkcodecovDOI

Calculate the matrices in Shiller (1991) that serve as the foundationfor many repeat-sales price indexes.

Installation

Get the stable release from CRAN.

install.package("rsmatrix")

Install the development version from R-Universe

install.packages("rsmatrix",repos= c("https://marberts.r-universe.dev","https://cloud.r-project.org"))

or directly from GitHub.

pak::pak("marberts/rsmatrix")

Usage

Most repeat-sales price indexes used in practice are based on thematrices in Shiller (1991, sections I-II), e.g., S&P’s Case-Shillerindex, Teranet-National Bank’s HPI, and formerly Statistics Canada’sRPPI. Let’s consider the simplest non-trivial example to see how to makeand use these matrices.

library(rsmatrix)# Make some data for two products selling over three periodssales<-data.frame(id= c(1,1,1,2,2),date= c(1,2,3,1,3),price= c(1,3,2,1,1))sales
##   id date price## 1  1    1     1## 2  1    2     3## 3  1    3     2## 4  2    1     1## 5  2    3     1

In most cases data need to first be structured as sales pairs, which canbe done with thers_pairs() function.

# Turn into sales pairssales[c("date_prev","price_prev")]<-sales[  rs_pairs(sales$date,sales$id),  c("date","price")](sales<- subset(sales,date>date_prev))
##   id date price date_prev price_prev## 2  1    2     3         1          1## 3  1    3     2         2          3## 5  2    3     1         1          1

Thers_matrix() function can now be used to produce a function thatconstructs these matrices.

# Calculate matricesmatrix_constructor<- with(sales, rs_matrix(date,date_prev,price,price_prev))matrices<- sapply(c("Z","X","y","Y"),matrix_constructor)matrices$Z
##    2 3## 1  1 0## 2 -1 1## 3  0 1
matrices$X
##    2 3## 1  3 0## 2 -3 2## 3  0 1

Standard repeat-sales indexes are just simple matrix operations usingthese matrices.

# Calculate the GRS index in Bailey, Muth, and Nourse (1963)b<- with(matrices, solve(crossprod(Z), crossprod(Z,y))[,1])(grs<- exp(b)*100)
##        2        3 ## 238.1102 125.9921
# Calculate the ARS index in Shiller (1991)b<- with(matrices, solve(crossprod(Z,X), crossprod(Z,Y))[,1])(ars<-100/b)
##        2        3 ## 240.0000 133.3333

Prior work

ThehpiR package has some functionality for making repeat-salesindexes, as does theMcSpatial package (formerly on CRAN). Althougheasier to use, these packages lack the flexibility to compute a numberof indexes found literature (e.g., any of the arithmetic repeat-salesindexes). The functions in this package build off of those in thersi package in Kirby-McGregor and Martin (2019), which also gives agood background on the theory of repeat-sales indexes.

Contributing

All contributions are welcome. Please start by opening an issue onGitHub to report any bugs or suggest improvements and new features. Seethe contribution guidelines for this project for more information.

References

ILO, IMF, OECD, UN, World Bank, Eurostat. (2013).Handbook onResidential Property Prices Indices (RPPIs). Eurostat.

Kirby-McGregor, M., and Martin, S. (2019). An R package for calculatingrepeat-sale price indices.Romanian Statistical Review, 3:17-33.

Shiller, R. J. (1991). Arithmetic repeat sales price estimators.Journal of Housing Economics, 1(1):110-126.

About

An R package for making repeat-sales matrices

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Contributing

Stars

Watchers

Forks

Languages


[8]ページ先頭

©2009-2025 Movatter.jp