Reputation: 185
I have yearly data on several economic variables (GDP, interest rates, inflation etc.) that are imported from Excel. I want to show the years were the economy was officially in a recession. So I have tried using the recessionplot function but I can't get it to work.
I think my problem is that my time variable is not properly defined. As of now, I have a variable called 'Year' and it is an array (113x1) consisting of years (1900-2012). If I understood correctly I need to transform this using datenum. So my first question is: how do I use datenum on an array of years?
Also, it is my understanding that recessionplot uses data from NBER (i.e specific to the US), is there any way I can specify my time periods at which there was a recession in the UK?
If there is an easier way of doing this, please let me know.
Upvotes: 0
Views: 1291
Reputation: 2652
how do I use datenum on an array of years?
From the datenum
documentation:
Y = 1900:2012;
M = 1;
D = 1;
DateNumber = datenum(Y,M,D);
is there any way I can specify my time periods at which there was a recession in the UK?
From the recessionplot
documentation:
'recessions'
-- Recession dataRecession data indicating the beginning and end of historical recessions, specified as the comma-separated pair consisting of
'recessions'
and anumRecessions
-by-2
matrix of serial date numbers. The first column indicates the beginning of the recession, and the second column indicates the end of the recession. The default recession data is the U.S. recession data inData_Recessions.mat
, reported by the National Bureau of Economic Research.
So you need something like this:
my_recessions = [1920, 1930; 1980, 1990];
recessionplot('recessions', my_recessions);
The recessionplot
documentation also includes a full example (with usage of datenum
too!). You should run this example and experiment with it to better understand how to use these functions.
Upvotes: 1