**free range statistics - R**, and kindly contributed to R-bloggers)

## Motivation

So, I’m in the process of moving to Melbourne and have a personal interest in the rental market there. But I’m also more generally interested in the economics of housing. Purchase costs get most of the attention, but rental costs are generally recognised as the better indication of the real “price” of housing in supply and demand terms. Variance from speculative booms and busts is smoothed out, but even more fundamentally, it is rent that reflects the cost of living in a home. Perhaps an analogy helps – when we are interested in the price of going to the movies we look at what it costs to receive the service of sitting in the cinema for two hours, not of purchasing the cinema.

My interest was also piqued by a tweet (perhaps in May or June 2018, that I can no longer locate) indicating that housing price growth in Sydney and Melbourne (but not Perth) is being led by lower-cost suburbs; I think the punch line was something like “first home owners are the ones driving the housing boom”. There are a lot of implicit assumptions in that conclusion but without being able to track down the tweet and the article it was referring to I can’t address them here.

I did wonder though whether the trend was actually a regression to the mean of sorts. If there is an element of randomness in suburbs’ house prices (as surely there is), some suburbs would be higher-priced than their fundamentals support at one point in time due to chance. We would expect their growth from that point in time to be less than average, precisely because the starting point is an artifical and unsustainable high. And vice versa for suburbs that happen to be lower than average at a particular point in time.

Anyway, I was interested in seeing if there was a pattern like this in rent prices in Melbourne. To cut to the chase, here’s what I found:

For flats/apartments in Melbourne and perhaps for smaller houses, the higher priced suburbs in 2000 have had weaker rental growth in the intervening period.

Notably, other than flats in Port Melbourne (which started out the period as the most expensive by far), *all* the suburbs’ median rental rates have grown faster than inflation as measured by the consumer price index, which has grown at around 2.6% over this time period. Over this time period (which is long compared to the breathless up-and-down commentary we often get with housing markets), rents have generally grown pretty steadily, without some of the fluctuations seen in purchase prices. This growth in the real price of rent isn’t surprising, but it is also definitely less than the growth in the cost of purchasing houses and flats.

## Data from DHHS

Luckily there is a great data source available, to a high degree of granularity, from the Victorian Department of Housing and Human Services who produce a report at least annually on key statistics on the private rental market in Victoria. The most recent report has re-usable data to the March 2018 quarter. The data are in an Excel workbook that covers all of Victoria. There is a separate worksheet for each housing type: “1 bedroom flat”, “2 bedroom flat”, “3 bedroom flat”, “2 bedroom house”, “3 bedroom house”,

“4 bedroom house” and “All properties”. Each actual value is either a median annual rent at the time of moving, or a count of how many dwellings had a change in tenant in the given quarter.

The data aren’t “tidy”, because there are two columns for each year, rather than a longer thin format with a single column for year, one for variable type (median rent or count) and one for value. Also, there is a bug – column Z in each sheet has the heading “Dec 2003” when it clearly should be “Dec 2002”. However, it’s pretty straightforward to read in all the data, fix the bug and tidy it up (including by adding a “Year Ending March” column which I’ll be using as the latest data is finishes in March 2018 and I want to use a full year’s worth for growth comparisons down the track):

The lowest number of counts for any suburb – quarter – dwelling combination is 10:

```
> rents %>% filter(variable == "Count") %>% summarise(min(value, na.rm = TRUE))
# A tibble: 1 x 1
`min(value, na.rm = TRUE)`
```
1 10

I’m presuming that combinations with less than 10 changes of tenant have been suppressed.

## Melbourne rental for 2 or 3 bedrooms

If we restrict ourselves to the most common types of rental – 2 or 3 bedroom flats or houses – and to locations in Melbourne, we can use a “spaghetti plot” (time series plot for longitudinal panel data) to get an overview of the range and growth of rentals simultaneously:

Graphics like this are a good starting point but limited as analytical or presentation tools.

Here’s the code for that graphic:

I had an idea of turning all the lines into indexes to highlight the average growth, and colouring each line in the spaghetti according to the average rent at the start of the data in 2000:

This is an improvement, but not by very much. We can see some tentative support for the idea here, with some dark coloured lines conspicuously in the lower part of the charts indicating lower growth, but we need something more analytical to decide if anything’s going on here.

Code for the indexed spaghetti chart:

## Triumph of the scatter plot

Of course, we can see where we’re heading – a scatter plot is the right tool here, if we can just work out which statistically transformed variables to put on the two axes. Described in this interesting blog by Dan Kopf as “data visualization’s greatest invention”, scatterplots rule supreme for this sort of task.

Here’s my first go – a straight comparison of the median rent in year ending March 2000 with median rent in year ending March 2018:

…and finally, the best graphic I think for my question of interest, comparing median rent in year ending March 2000 with average annual growth in the 17 years since then:

Of course, this last graphic has the merits of reflecting how we’d use a linear regression model for statistical inference on this data. It’s hardly necessary to do the formal modelling, because clearly the effect we’re seeing is statistically significant.

For what it’s worth and to encourage diagnostic checks being reported as a matter of course, here’s the diagnostic charts from that model, which we see fits the assumptions (eg normality of residuals) very nicely.

## Price and volume

In thinking about some of that variation in growth in pricing, I wondered about the supply side. Are volumes going up at different rates in these different suburbs? In the data to hand I don’t have a great measure of volume of flats on the market, only the number of “moves” which is a proxy at best (because the velocity of moves might itself be an important factor). For what it’s worth, here’s a comparison of growth in rental price to growth in number of moves:

That graphic feels a bit squashed compared to the others, because I’ve forced both axes to use the same scale (with `+ coord_equal()`

), which is usually good practice in this situation. It highlights that each facet is wider than it is tall, because of the greater variation in growth of volume of moves than in pricing.

OK, that’s it for today. There’s a lot more that could be done here by bringing in other datasets – particularly with a spatial element, and comparison to other prices – but that can wait for another day.

**leave a comment**for the author, please follow the link and comment on their blog:

**free range statistics - R**.

R-bloggers.com offers

**daily e-mail updates**about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...