rs_z: Shiller's Z matrix

Description Usage Arguments Details References See Also Examples

View source: R/rsi.R

Description

Compute the 'Z' matrix in Shiller (1991, section I) from sales-pair data to calculate a repeat-sales price index.

Usage

1
rs_z(x, y, f, sparse = FALSE)

Arguments

x, y

Period of the second and first sale, respectively. Usually a vector of dates.

f

An optional factor the same length as x and y, or an atomic vector to be turned into a factor, that is used to group x and y.

sparse

Should sparse matrices from Matrix be used in the calculation (faster for large datasets), or regular dense matrices?

Details

The Z matrix is not well defined if either x or y have missing values, and an error is thrown if any inputs have missing values.

References

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

See Also

See rs_x for making Shiller's X matrix.

Examples

1
2
3
4
5
6
7
8
# Make some data
x <- data.frame(date = c(3, 2, 3), date_prev = c(1, 1, 2), price = 3:1, price_prev = 1)

# Calculate the GRS index
Z <- rs_z(x$date, x$date_prev)
y <- log(x$price) - log(x$price_prev)
b <- solve(crossprod(Z[, -1]), crossprod(Z[, -1], y))[, 1]
exp(b) * 100

marberts/ppd documentation built on March 27, 2020, 7:21 p.m.