Skip to content

Instantly share code, notes, and snippets.

@tslumley
Created May 2, 2019 23:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tslumley/b58a95dffe06b2e0c53fd7b4eac10572 to your computer and use it in GitHub Desktop.
Save tslumley/b58a95dffe06b2e0c53fd7b4eac10572 to your computer and use it in GitHub Desktop.
Gross and net transfers of NZ real estate.
## from: https://www.stats.govt.nz/information-releases/property-transfer-statistics-march-2019-quarter
re<-read.table(text=
"year quarter citbuy citsell resbuy ressell fornbuy fornsell corpbuy corpsell knowbuy knowsell unkbuy unksell total
2017 Mar 23592 23490 2130 1101 621 375 3060 4407 29406 29370 4287 4320 33690
2017 Jun 30414 30678 3063 1512 930 486 4188 5946 38595 38625 450 426 39048
2017 Sep 27123 27021 2703 1458 783 441 3618 5316 34230 34239 126 117 34356
2017 Dec 28632 28125 2862 1491 1038 468 3663 6111 36195 36192 84 87 36279
2018 Mar 25881 25947 2625 1401 1083 501 3255 4998 32841 32847 39 36 32880
2018 Jun 31044 31173 3171 1656 1116 492 4281 6285 39606 39606 21 21 39627
2018 Sep 28284 27684 2982 1557 717 378 3630 5997 35613 35613 21 21 35634
2018 Dec 30162 29520 3045 1671 885 414 3819 6303 37914 37908 15 18 37929
2019 Mar 25986 25275 2367 1290 204 327 3165 4830 31719 31719 9 9 31728
", header=TRUE)
## compute date
re$month<-rep(c(3,6,9,12),length.out=9)
re$Date<-ISOdate(re$year,re$month,day=30)
re$Date<-as.Date(re$Date)
## plot
png("re-%d.png",width=800,height=500)
plot(citbuy~Date,type="h",data=re,ylim=c(-40000,40000),col="orange",lwd=3,ylab="Citizens")
title(main="Property acquired by citizens")
points(I(-citsell)~Date,data=re,type="h",col="blue",lwd=3)
abline(h=0,lty=3)
points(I(citbuy-citsell)~I(Date+7),data=re,type="h",col="black",lwd=5)
legend("bottomleft",col=c("orange","blue","black"),lty=1, legend=c("Buy","Sell","Net"),bty="n")
plot(I(citbuy+resbuy)~Date,type="h",data=re,ylim=c(-40000,40000),col="orange",lwd=3,ylab="Citizens/Residents")
title(main="Property acquired by citizens or residents")
points(I(-ressell-citsell)~Date,data=re,type="h",col="blue",lwd=3)
abline(h=0,lty=3)
points(I(citbuy-citsell+resbuy-ressell)~I(Date+7),data=re,type="h",col="black",lwd=5)
legend("bottomleft",col=c("orange","blue","black"),lty=1, legend=c("Buy","Sell","Net"),bty="n")
plot(I(fornbuy)~Date,type="h",data=re,ylim=c(-40000,40000),col="orange",lwd=3,ylab="Non-residents")
title(main="Property acquired by non-residents")
points(I(-fornsell)~Date,data=re,type="h",col="blue",lwd=3)
abline(h=0,lty=3)
points(I(fornbuy-fornsell)~I(Date+7),data=re,type="h",col="black",lwd=5)
legend("bottomleft",col=c("orange","blue","black"),lty=1, legend=c("Buy","Sell","Net"),bty="n")
plot(I(fornbuy)~Date,type="h",data=re,ylim=c(-4000,4000),col="orange",lwd=3,ylab="Non-residents")
title(main="Property acquired by non-residents")
points(I(-fornsell)~Date,data=re,type="h",col="blue",lwd=3)
abline(h=0,lty=3)
points(I(fornbuy-fornsell)~I(Date+7),data=re,type="h",col="black",lwd=5)
legend("bottomleft",col=c("orange","blue","black"),lty=1, legend=c("Buy","Sell","Net"),bty="n")
plot(I(fornbuy+unkbuy)~Date,type="h",data=re,ylim=c(-4000,4000),col="orange",lwd=3,ylab="Non-residents+Unknown")
title(main="Property acquired by non-residents and unknown status")
points(I(-fornsell-unksell)~Date,data=re,type="h",col="blue",lwd=3)
abline(h=0,lty=3)
points(I(fornbuy+unkbuy-fornsell-unksell)~I(Date+7),data=re,type="h",col="black",lwd=5)
legend("bottomleft",col=c("orange","blue","black"),lty=1, legend=c("Buy","Sell","Net"),bty="n")
plot(I(fornbuy+unkbuy+corpbuy)~Date,type="h",data=re,ylim=c(-40000,40000),col="orange",lwd=3,ylab="Non-residents+Unknown+Corporate")
title(main="Property acquired by non-residents, unknown status, corporate")
points(I(-fornsell-unksell-corpsell)~Date,data=re,type="h",col="blue",lwd=3)
abline(h=0,lty=3)
points(I(fornbuy+unkbuy+corpbuy-fornsell-unksell-corpsell)~I(Date+7),data=re,type="h",col="black",lwd=5)
legend("bottomleft",col=c("orange","blue","black"),lty=1, legend=c("Buy","Sell","Net"),bty="n")
dev.off()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment