Last data update: 2014.03.03

R: Quantile Repeat Sales Estimation
repsaleqregR Documentation

Quantile Repeat Sales Estimation

Description

Median-Based Repeat Sales Estimation

Usage

repsaleqreg(price0,time0,price1,time1,mergefirst=1,
  graph=TRUE,graph.conf=TRUE,conf=.95,print=TRUE) 

Arguments

price0

Earlier price in repeat sales pair

time0

Earlier time in repeat sales pair

price1

Later price in repeat sales pair

time1

Later time in repeat sales pair

mergefirst

Number of initial periods with coefficients constrained to zero. Default: mergefirst=1

graph

If TRUE, graph results. Default: graph=T

graph.conf

If TRUE, add confidence intervals to graph. Default: graph.conf=T

conf

Confidence level for intervals. Default: .95

print

If print=T, prints the regression results. Default: print=T.

Details

The repeat sales model is

y(t) - y(s) = δ(t) - δ(s) + u(t) - u(s)

where y is the log of sales price, s denotes the earlier sale in a repeat sales pair, and t denotes the later sale. Each entry of the data set should represent a repeat sales pair, with price0 = y(s), price1 = y(t), time0 = s, and time1 = t. The function repsaledata can help transfer a standard hedonic data set to a set of repeat sales pairs.

Repeat sales estimates are sometimes very sensitive to sales from the first few time periods, particularly when the sample size is small. The option mergefirst indicates the number of time periods for which the price index is constrained to equal zero. The default is mergefirst = 1, meaning that the price index equals zero for just the first time period.

The repsaleqreg function uses the quantreg package to estimate a quantile regression for the .50 quantile, i.e., the median. A median-based estimator is less sensitive to outliers than linear regression. McMillen and Thorsnes (2006) show that the quantile approach is less sensitive to the inclusion of properties that have undergone renovations between sales. repsaleqreg first fits a standard quantile model, including the interecpt. The coefficient vector is then rotated to have a zero intercept using the formula for transforming unrestricted linear regression estimates to the restricted (zero intercept) values:

fit <- rq(dy~x)
b <- fit$coef
fit1 <- summary(fit,covariance=TRUE)
vmat <- fit1$cov
k = length(b1)
rmat <- diag(k)
rmat[,1] <- rmat[,1] - vmat[1,]/vmat[1,1]
bmat <- rmat

Value

fit

Full quantile regression model.

pindex

The estimated price index.

lo

The lower bounds for the price index confidence intervals.

hi

The upper bounds for the price index confidence intervals.

References

Case, Karl and Robert Shiller, "Prices of Single-Family Homes since 1970: New Indexes for Four Cities," New England Economic Review (1987), 45-56.

McMillen, Daniel P. and Paul Thorsnes, "Housing Renovations and the Quantile Repeat Sales Price Index," Real Estate Economics 34 (2006), 567-587.

See Also

repsale

repsaledata

repsalefourier

Examples

set.seed(189)
n = 2000
# sale dates range from 0-10
# drawn uniformly from all possible time0, time1 combinations with time0<time1
tmat <- expand.grid(seq(0,10), seq(0,10))
tmat <- tmat[tmat[,1]<tmat[,2], ]
tobs <- sample(seq(1:nrow(tmat)),n,replace=TRUE)
time0 <- tmat[tobs,1]
time1 <- tmat[tobs,2]
timesale <- time1-time0
table(timesale)

# constant variance; index ranges from 0 at time 0 to 1 at time 10
y0 <- time0/10 + rnorm(n,0,.2)
y1 <- time1/10 + rnorm(n,0,.2)
fit <- repsaleqreg(price0=y0, price1=y1, time0=time0, time1=time1)

# variance rises with timesale
# var(u0) = .2^2; var(u1) = (.2 + timesale/10)^2
# var(u1-u0) = var(u0) + var(u1) = 2*(.2^2) + .4*timesale/10 + (timesale^2)/100
y0 <- time0/10 + rnorm(n,0,.2)
y1 <- time1/10 + rnorm(n,0,.2+timesale/10)
par(ask=TRUE)
fit <- repsaleqreg(price0=y0, price1=y1, time0=time0, time1=time1)
summary(fit$pindex)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(McSpatial)
Loading required package: lattice
Loading required package: locfit
locfit 1.5-9.1 	 2013-03-22
Loading required package: maptools
Loading required package: sp
Checking rgeos availability: TRUE
Loading required package: quantreg
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: RANN
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/McSpatial/repsaleqreg.Rd_%03d_medium.png", width=480, height=480)
> ### Name: repsaleqreg
> ### Title: Quantile Repeat Sales Estimation
> ### Aliases: repsaleqreg
> ### Keywords: Repeat Sales Quantile Regression
> 
> ### ** Examples
> 
> set.seed(189)
> n = 2000
> # sale dates range from 0-10
> # drawn uniformly from all possible time0, time1 combinations with time0<time1
> tmat <- expand.grid(seq(0,10), seq(0,10))
> tmat <- tmat[tmat[,1]<tmat[,2], ]
> tobs <- sample(seq(1:nrow(tmat)),n,replace=TRUE)
> time0 <- tmat[tobs,1]
> time1 <- tmat[tobs,2]
> timesale <- time1-time0
> table(timesale)
timesale
  1   2   3   4   5   6   7   8   9  10 
368 349 264 253 223 178 167 104  56  38 
> 
> # constant variance; index ranges from 0 at time 0 to 1 at time 10
> y0 <- time0/10 + rnorm(n,0,.2)
> y1 <- time1/10 + rnorm(n,0,.2)
> fit <- repsaleqreg(price0=y0, price1=y1, time0=time0, time1=time1)
Warning message:
In rq.fit.br(x, y, tau = tau, ...) : Solution may be nonunique
> 
> # variance rises with timesale
> # var(u0) = .2^2; var(u1) = (.2 + timesale/10)^2
> # var(u1-u0) = var(u0) + var(u1) = 2*(.2^2) + .4*timesale/10 + (timesale^2)/100
> y0 <- time0/10 + rnorm(n,0,.2)
> y1 <- time1/10 + rnorm(n,0,.2+timesale/10)
> par(ask=TRUE)
> fit <- repsaleqreg(price0=y0, price1=y1, time0=time0, time1=time1)
Warning message:
In rq.fit.br(x, y, tau = tau, ...) : Solution may be nonunique
> summary(fit$pindex)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
 0.0000  0.2670  0.5366  0.5487  0.8298  1.0270 
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>