This package provides a convenient way of accessing the financial and economic data published by the Reserve Bank of New Zealand (RBNZ) on their website, https://www.rbnz.govt.nz/statistics. The data is provided in .xlsx files; this package will download those files and read them into R. A summary of the available data can be found at the end of this document.
The author has no affiliation with the RBNZ. The copyright for the data can be found at https://www.rbnz.govt.nz/about-our-site/terms-of-use.
The function for downloading the data is getSeries
. This
takes as its first argument the name of the series and will return a
list containing the fields “meta” and “data” which are data frames
containing the metadata and actual data, respectively. Each column of
the “data” data frame corresponds to a row of the “meta” data frame
(except the first which is “Date”).
library(RBNZ)
## Not evaluated in this vignette.
b1 <- getSeries("B1")
plot(b1$data$Date, b1$data$UK_pound_sterling, type = "l")
Some of the datasets have different available formats. For example
the B1 series contains exchange rate data in both daily and monthly
form. The second argument of getSeries
allows the user to
specify which option they want,
e.g. getSeries('B1', 'monthly')
.
Each series has a help file so typing, for example, ?B1
,
will tell you what options, if any, are available.
To speed things up the files can be saved on disk so that they don’t
have to always be re-downloaded even when there are no available
updates. This is controlled by the destDir
argument to
getSeries
, which can also be specified in your .Rprofile
using options(RBNZ.destDir = "path/to/stored/files")
.
By default, where a series has multiple files for a given option,
only the most recent will be downloaded if destDir
is
provided and the files already exist. This is controlled by the
reloadOnlyLatest
argument to getSeries
.
For a full description of the arguments of getSeries
,
see the package manual or function header.
The RBNZ website is behind Cloudflare so there are some initial steps the user must take.
One option is to email the RBNZ and request that your (static) public IP address be whitelisted. The email to contact is listed on their terms of service page here.
The second option is to download the necessary files from the RBNZ website manually through your browser and then use this package to read and organise those files. This can be done by downloading the spreadsheets needed and saving them in a given directory without changing their file names.
For example for the B1 series a user could download through their browser the following spreadsheets:
They could then load the data as follows:
The monthly option can be used after downloading hb1-monthly.xlsx and hb1-monthly-1973-1998.xlsx.
This option is not ideal as the spreadsheets need to be manually downloaded every time you want them updated but for users who don’t have a permanent public IP address they can get whitelisted this is the best that can be done.
The majority of the datasets available are all stored in a similar format, with data organised by date and a standard set of metadata. There are a few series that do not follow this template, as indicated in the next section, and for these the spreadsheets are just downloaded and read into a list of data frames, one for each sheet, with some basic attempts at cleaning up dates, column headers, and so on.
#> Series Standard_Format Description
#> B1 Exchange rates and TWI
#> B2 Wholesale interest rates
#> B3 Retail interest rates on lending and deposits
#> B4 Foreign exchange turnover ($m daily averages)
#> B6 Yields on loans
#> B7 Costs of Deposits
#> B10 TWI weights
#> B13 Historical TWI weights
#> B20 New residential mortgage standard interest rates
#> B21 New residential mortgage special interest rates
#> B25 New interest bearing call savings account inter...
#> B26 New interest bearing term deposit interest rates
#> B27 New interest bearing term PIE deposits interest...
#> C5 Sector lending (registered banks and non-bank l...
#> C12 Credit card balances
#> C13 Credit card spending
#> C21 Key household financial statistics ($m)
#> C22 Household balance sheet ($m)
#> C30 New residential mortgage lending by loan-to-val...
#> C31 New residential mortgage lending by borrower type
#> C32 New and Existing Residential Mortgage Lending b...
#> C35 Residential mortgage loan reconciliation
#> C40 Residential mortgage lending by debt-to-income ...
#> C41 Residential mortgage borrower gross income (BGI)
#> C50 Money and credit aggregates (depository corpora...
#> C51 Other depository corporations analytical accounts
#> C52 Depository corporations analytical accounts
#> C55 Other financial corporations analytical accounts
#> C60 Credit conditions survey
#> C65 Bank Customer Lending flows
#> C66 Bank Customer Lending stocks
#> D3 X Open market operations
#> D9 Government bond turnover
#> D10 X Influences on settlement cash
#> D12 X Standing facilities
#> D30 Holdings of central government debt securities ...
#> D31 Non-resident holdings of individual bonds (nomi...
#> D35 Holdings of Kauri bonds (nominal value)
#> E1 X New Zealand's official overseas reserves
#> E2 New Zealand's position with the IMF
#> F3 X Bank notes in the hands of the public
#> F4 X Coin mintings
#> F5 X Reserve Bank foreign currency assets and liabil...
#> H1 Household Inflation Expectations
#> H2 Housing and Employment
#> H3 Cash Use
#> J10 Insurance: Income Statement
#> J20 Insurance: Balance Sheet
#> L1 Mismatch ratios
#> L2 Core funding ratio
#> L3 Face value of funding by residual maturity ($m)
#> M1 Prices
#> M2 Consumption
#> M3 Investment
#> M4 Domestic trade
#> M5 Gross Domestic Product
#> M6 National saving (year ended March)
#> M7 Balance of Payments and International Investmen...
#> M8 Overseas trade
#> M9 Labour market
#> M10 Housing
#> M12 Population and migration
#> M14 Survey of expectations
#> R1 Reserve Bank balance sheet ($m)
#> R2 Reserve Bank statistical balance sheet ($m)
#> R3 Reserve Bank analytical accounts ($m)
#> S10 Banks: Balance sheet ($m)
#> S20 Banks: Summary income statement and related ratios
#> S21 Banks: Income statement ($m)
#> S30 Banks: Assets - Loans by sector
#> S31 Banks: Assets - Loans by purpose ($m)
#> S32 Banks: Assets - Loans by product ($m)
#> S33 Banks: Assets - Loans fully secured by resident...
#> S34 Banks: Assets - Loans and Repos by Industry ($m)
#> S35 Banks: Assets - Loans by Business Size
#> S36 Banks: Assets - Loans by Product
#> S37 Banks: Assets - Agriculture Loans by Product
#> S40 Banks: Liabilities - Deposits by sector ($m)
#> S41 Banks: Liabilities - Deposits by industry ($m)
#> S50 Banks: Assets - Loans by Asset Quality
#> SDDS X NZ's international reserves and foreign currenc...
#> T1 Non banks: Balance sheet ($m)
#> T4 Non banks: Funding and claims by sector ($m)
#> T11 Savings institutions: Balance sheet ($m)
#> T21 Deposit taking finance companies: Balance sheet...
#> T31 Non-deposit taking finance companies: Balance s...
#> T40 Funds under management ($m)
#> T41 Managed fund assets ($m)
#> T42 Life insurance ($m)
#> T43 KiwiSaver ($m)
#> T44 Other registered superannuation ($m)
#> T45 Retail unit trusts ($m)
#> T46 Cash management trusts ($m)
#> T47 Wholesale trusts ($m)
#> T48 Wholesale trusts and other funds ($m)