{"id":26631170,"url":"https://github.com/marberts/rsmatrix","last_synced_at":"2025-10-10T11:15:38.673Z","repository":{"id":56932762,"uuid":"283389699","full_name":"marberts/rsmatrix","owner":"marberts","description":"An R package for making repeat-sales matrices","archived":false,"fork":false,"pushed_at":"2024-01-21T03:12:19.000Z","size":6142,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-25T18:41:44.753Z","etag":null,"topics":["cran","economics","housing","r","r-package","rstats","statistics"],"latest_commit_sha":null,"homepage":"https://marberts.github.io/rsmatrix/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marberts.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-29T03:36:21.000Z","updated_at":"2024-07-19T00:59:58.839Z","dependencies_parsed_at":"2023-11-19T21:32:27.828Z","dependency_job_id":"8797f172-f666-46a8-823c-b1f6b816011a","html_url":"https://github.com/marberts/rsmatrix","commit_stats":{"total_commits":69,"total_committers":2,"mean_commits":34.5,"dds":0.01449275362318836,"last_synced_commit":"e74626cad7999494e7aecb4ebf924ca1f62a5f0e"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Frsmatrix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Frsmatrix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Frsmatrix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marberts%2Frsmatrix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marberts","download_url":"https://codeload.github.com/marberts/rsmatrix/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248260660,"owners_count":21074214,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cran","economics","housing","r","r-package","rstats","statistics"],"created_at":"2025-03-24T14:49:34.288Z","updated_at":"2025-10-10T11:15:33.653Z","avatar_url":"https://github.com/marberts.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file. --\u003e\n\n```{r setup, include=FALSE}\nknitr::opts_chunk$set(echo = TRUE)\n```\n\n# Matrices for repeat-sales price indexes \u003ca href=\"https://marberts.github.io/rsmatrix/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"139\" alt=\"rsmatrix website\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![CRAN status](https://www.r-pkg.org/badges/version/rsmatrix)](https://cran.r-project.org/package=rsmatrix)\n[![rsmatrix status badge](https://marberts.r-universe.dev/badges/rsmatrix)](https://marberts.r-universe.dev)\n[![R-CMD-check](https://github.com/marberts/rsmatrix/workflows/R-CMD-check/badge.svg)](https://github.com/marberts/rsmatrix/actions)\n[![codecov](https://codecov.io/gh/marberts/rsmatrix/graph/badge.svg?token=2UBM5VYMH2)](https://app.codecov.io/gh/marberts/rsmatrix)\n[![DOI](https://zenodo.org/badge/283389699.svg)](https://zenodo.org/doi/10.5281/zenodo.10110159)\n\u003c!-- badges: start --\u003e\n\nCalculate the matrices in Shiller (1991) that serve as the foundation for many repeat-sales price indexes.\n\n## Installation\n\nGet the stable release from CRAN.\n\n```{r, eval=FALSE}\ninstall.package(\"rsmatrix\")\n```\n\nInstall the development version from R-Universe\n\n```{r, eval=FALSE}\ninstall.packages(\"rsmatrix\", repos = c(\"https://marberts.r-universe.dev\", \"https://cloud.r-project.org\"))\n```\n\nor directly from GitHub.\n\n```{r, eval=FALSE}\npak::pak(\"marberts/rsmatrix\")\n```\n\n## Usage\n\nMost repeat-sales price indexes used in practice are based on the matrices in Shiller (1991, sections I-II), e.g., S\u0026P'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.\n\n```{r}\nlibrary(rsmatrix)\n\n# Make some data for two products selling over three periods\nsales \u003c- data.frame(\n  id = c(1, 1, 1, 2, 2),\n  date = c(1, 2, 3, 1, 3),\n  price = c(1, 3, 2, 1, 1)\n)\n\nsales\n```\n\nIn most cases data need to first be structured as sales pairs, which can be done with the `rs_pairs()` function.\n\n```{r}\n# Turn into sales pairs\nsales[c(\"date_prev\", \"price_prev\")] \u003c- sales[rs_pairs(sales$date, sales$id), c(\"date\", \"price\")]\n\n(sales \u003c- subset(sales, date \u003e date_prev))\n```\n\nThe `rs_matrix()` function can now be used to produce a function that constructs these matrices. \n\n```{r}\n# Calculate matrices\nmatrix_constructor \u003c- with(sales, rs_matrix(date, date_prev, price, price_prev))\nmatrices \u003c- sapply(c(\"Z\", \"X\", \"y\", \"Y\"), matrix_constructor)\n\nmatrices$Z\n\nmatrices$X\n```\n\nStandard repeat-sales indexes are just simple matrix operations using these matrices.\n\n```{r}\n# Calculate the GRS index in Bailey, Muth, and Nourse (1963)\nb \u003c- with(matrices, solve(crossprod(Z), crossprod(Z, y))[, 1])\n(grs \u003c- exp(b) * 100)\n\n# Calculate the ARS index in Shiller (1991)\nb \u003c- with(matrices, solve(crossprod(Z, X), crossprod(Z, Y))[, 1])\n(ars \u003c- 100 / b)\n```\n\n## Prior work\n\nThe **hpiR** package has some functionality for making repeat-sales indexes, as does the **McSpatial** package (formerly on CRAN). Although easier to use, these packages lack the flexibility to compute a number of indexes found literature (e.g., any of the arithmetic repeat-sales indexes). 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.\n\n## References\n\nILO, IMF, OECD, UN, World Bank, Eurostat. (2013). *Handbook on Residential Property Prices Indices (RPPIs)*. Eurostat.\n\nKirby-McGregor, M., and Martin, S. (2019). An R package for calculating repeat-sale price indices. *Romanian Statistical Review*, 3:17-33.\n\nShiller, R. J. (1991). Arithmetic repeat sales price estimators. *Journal of Housing Economics*, 1(1):110-126.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarberts%2Frsmatrix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarberts%2Frsmatrix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarberts%2Frsmatrix/lists"}