MyNixOS website logo
Description

Matrices for Repeat-Sales Price Indexes.

Calculate the matrices in Shiller (1991, <doi:10.1016/S1051-1377(05)80028-2>) that serve as the foundation for many repeat-sales price indexes.

Matrices for repeat-sales price indexes rsmatrix website

CRANstatus rsmatrix statusbadge R-CMD-check codecov DOI

Calculate the matrices in Shiller (1991) that serve as the foundation for 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 the matrices in Shiller (1991, sections I-II), e.g., S&P’s Case-Shiller index, Teranet-National Bank’s HPI, and formerly Statistics Canada’s RPPI. Let’s consider the simplest non-trivial example to see how to make and use these matrices.

library(rsmatrix)

# Make some data for two products selling over three periods
sales <- 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 can be done with the rs_pairs() function.

# Turn into sales pairs
sales[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

The rs_matrix() function can now be used to produce a function that constructs these matrices.

# Calculate matrices
matrix_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 using these 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

The McSpatial package (formerly on CRAN) has some functionality for making repeat-sales indices. The functions in this package build off of those in the rsi package in Kirby-McGregor and Martin (2019), which also gives a good background on the theory of repeat-sales indexes.

References

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

Kirby-McGregor, M., and Martin, S. (2019). An R package for calculating repeat-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.

Metadata

Version

0.2.8

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows