You can import data directly from IMF (International Monetary Fund) using getIMFData.m function I created. A basic example using the BOP dataset shows how to download a single data series and walking you through understanding what is downloaded and three further simple examples show how to phrase the extra details required to request to CPIS database example the DOT database example and the GFS database example. There is also one advanced example showing how to download data for all countries: IFS database example. The project github with the examples on how to use getIMFData (and plotly) is included in this download.
- Download getIMFData.m (you can either put it in your active folder, or better yet add it to the Matlab path). [Github]
- Now just import the series you want (here Nominal GDP in domestic currency, ‘NGDP_XDC’, for New Zealand, ‘NZ’, for period 2000 to 2015 at an annual frequency, ‘A’, from the IFS (International Financial Statistics dataset)):
NGDP = getIMFData(‘IFS’, ‘NGDP_XDC’, ‘NZ’, ‘A’, ‘2000’, ‘2015’) - This will give you a structure NGDP, the data series itself is in NGDP.Data(:,2).
- The NGDP structure also contains other info, eg. NGDP.description, or the dates in NGDP.Data(:,1).
- This command works with thirteen IMF databases: the International Financial Statistics (IFS), Financial Soundness Indicators (FSI), Balance of Payments (BOP), Consumer Price Index (CPI), Coordinated Portfolio Investment Survey (CPIS), Direction of Trade Statistics (DOT), and all seven Government Financial Statistics (GFS).
[If you want me to add functionality for other IMF databases send me an email and I will.] - If you call getIMFData and include only the database_id, e.g., getIMFData(‘IFS’) it returns a dictionary that contains all of the codes, such the variable names which can be searched to find the code for the variable you want. See the example in this m-file (or mlx; download them). CPIS is slightly different to use, see example in this m-file. DOT is slightly different to use, see example in this m-file. GFS are slightly different to use, see example in this m-file.
- You can access vintage data by including one more input. This will be the year, possibly with quarter or month; e.g., ‘2017’, ‘2017Q2’, or ‘2017M07’. So to get the same NGDP data as above, but this time from the 2017M05 (May, 2017) data release,
NGDP = getIMFData(‘IFS’, ‘NGDP_XDC’, ‘NZ’, ‘A’, ‘2000’, ‘2015’, ‘2017M05’)
[Different datasets are available at yearly, quarterly, or monthly frequencies.]