Last data update: 2014.03.03

R: Preparation of a Repeat Sales Data Set
repsaledataR Documentation

Preparation of a Repeat Sales Data Set

Description

Identifies repeat sales from a data set with observations on sale price, time of sale, and a property id. Returns a data frame in which each observation is a repeat sales pair.

Usage

  repsaledata(price,timevar,id)

Arguments

price

Variable representing sale price

timevar

Variable representing date of sale

id

Property id

Details

The input to repsaledata is meant to be a set of variables from a standard hedonic data set – the sale price, date, and an id number for the individual property. The function identifies the subset of properties that sold at least twice and forms a new data set in which each observation is a repeat sales pair, with "0" denoting the earlier time and "1" denoting the later date in the variable names. The observations are ordered first by id, then by timevar, and then by price. A repeat sales pair is formed by matching an observation for which id(t)=id(t-1) and timevar(t)=timevar(t-1). Thus, a property that sold in times 1, 2, and 3 will produce 2 repeat sales pairs: (1) t = 1 and 2, and (2) t = 2 and 3.

The output of repsaledata is a data frame with 5 variables. If some of the original hedonic data set variables need to be included in the repeat sales data set, the original hedonic data set and the repsaledata data frame can be merged by the id variable.

Value

id

Property id

price0

Sale price at earlier date

time0

Earlier sales date

price1

Sale price at later date

time1

Later sales date

See Also

repsale

repsalefourier

repsaleqreg

Examples

id <-      c(1,1,1, 2,2,2, 3,3,3, 4,4,4, 5,5,5)
timevar <- c(1,2,3, 1,2,2, 3,1,1, 1,1,2, 2,2,3)
price <- seq(1:15)
basedata <- data.frame(id,timevar,price)
basedata

rdata <- repsaledata(price,timevar,id)
rdata

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/repsaledata.Rd_%03d_medium.png", width=480, height=480)
> ### Name: repsaledata
> ### Title: Preparation of a Repeat Sales Data Set
> ### Aliases: repsaledata
> ### Keywords: Repeat Sales
> 
> ### ** Examples
> 
> id <-      c(1,1,1, 2,2,2, 3,3,3, 4,4,4, 5,5,5)
> timevar <- c(1,2,3, 1,2,2, 3,1,1, 1,1,2, 2,2,3)
> price <- seq(1:15)
> basedata <- data.frame(id,timevar,price)
> basedata
   id timevar price
1   1       1     1
2   1       2     2
3   1       3     3
4   2       1     4
5   2       2     5
6   2       2     6
7   3       3     7
8   3       1     8
9   3       1     9
10  4       1    10
11  4       1    11
12  4       2    12
13  5       2    13
14  5       2    14
15  5       3    15
> 
> rdata <- repsaledata(price,timevar,id)
> rdata
  id time0 time1 price0 price1
1  1     1     2      1      2
2  1     2     3      2      3
3  2     1     2      4      5
4  3     1     3      9      7
5  4     1     2     11     12
6  5     2     3     14     15
> 
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>