主要内容

衰退

叠加衰退乐队的时间序列情节

Description

example

衰退overlays shaded US recession bands, as reported by the National Bureau of Economic Research (NBER)[1], on a time series plot in the current axes. Abscissa data must represent dates created bydatenum或者约会时间.

example

衰退(Name,Value)使用一个或多个名称值参数指定的其他选项。例如,衰退('recessions',recessionPeriods)specifies overlaying shaded bands for the recession periods in经济衰退.

example

hBands= recessionplot(___)使用先前语法中的任何输入量词组合,将手柄向量返回衰退带。

Examples

collapse all

加载data_unemployment.mat数据集包含从1954年至1998年测得的每月美国失业率系列。

loaddata_unoployment

变量数据dates, among others, appear in the workspace. For more details on the data, enterDescription.

数据is a 45-by-12 matrix of the unemployment rates. The rows of数据对应于连续的年份及其柱子对应于连续的月份;数据(j,k)是月份的失业率kof yearj. Represent数据作为常规时间序列数据的向量,通过转移矩阵,然后垂直串联结果列。

数据= Data'; un = Data(:);

dates是连续45年的数字矢量。创建一个约会时间vector that expandsdatesby including all months within each year.

Y = repmat(dates',12,1); Y = Y(:); M = repmat((1:12)',length(dates),1); D = ones(length(un),1); t = datetime(Y,M,D);

或者,您可以使用加尔姆斯功能可以在每年内有效地包括所有月份。

tspan = datetime([dates(1); dates(end)],[1; 12],[1; 1]); t = (tspan(1):calmonths(1):tspan(2))';

Plot the unemployment rate series. Overlay bands for recession periods reported by NBER.

figure plot(t,un) recessionplot ylabel('Rate (%)') 标题("Unemployment Rate")

Figure contains an axes object. The axes object with title Unemployment Rate contains 9 objects of type line, patch.

经济衰退时期似乎是突然的,相对较大的失业率增加。

叠加衰退乐队的时间序列情节, then return the handles of the recession bands to change the color and opacity of the bands.

加载数据_CreditDefaults.matdata set, which contains a credit default rate series and several predictor series measured annually from 1984 through 2004.

load数据_CreditDefaults

变量数据dates, among others, appear in the workspace. For more details on the data, enterDescription.

数据是一个包含该系列的21 x 5个数字矩阵。提取预测器系列,其中包含前四列。

X = Data(:,1:4);

日期是包含21个采样年的数字矢量。兑换dates约会时间年份的向量。假设该系列是在年底测量的。

T = numel(dates); dates = [dates [12 31].*ones(T,2)]; dates = datetime(dates);

绘制预测器系列。覆盖衰退乐队,然后将手柄返回到乐队。将带颜色更改为红色,并将不透明度降低到0.1。

数字;情节(日期,x,'LineWidth',2);Xlabel(“年”); ylabel(“等级”); hBands = recessionplot; set(hBands,'FaceColor',“ R”,'FaceAlpha',0.1);

Figure contains an axes object. The axes object contains 6 objects of type line, patch.

Input Arguments

collapse all

Name-Value Arguments

将可选的参数对Name1=Value1,...,NameN=ValueN, whereNameis the argument name and价值是相应的值。名称值参数必须在其他参数之后出现,但是对的顺序并不重要。

Before R2021a, use commas to separate each name and value, and encloseNamein quotes.

例子:'recessions',recessionPeriodsspecifies overlaying shaded bands for the recession periods in经济衰退.

覆盖衰退带的轴,指定为object. The target axes must contain a time series plot with serial dates on the horizontal axis.

By default,衰退plots to the current axes (gca).

Recession periods, or data indicating the beginning and end of historical recessions, specified as anumRecessions-经过-2串行日期编号的矩阵或约会时间entries. Each row is a period of recession, with the first column indicating the beginning of the recession and the second column indicating the end of the recession.

The default is the US recession data in数据_Recessions.mat,由nber报道[1].

Output Arguments

collapse all

将绘制的图形对象的操作作为图形向量返回。hBandscontains unique plot identifiers, which you can use to query or modify properties of the recession bands.

提示

  • 衰退requires约会时间时间序列图的水平轴上的值或序列日期数。要在绘图之前将其他日期信息转换为此格式,请使用约会时间或者datenum.

  • 为了在某​​些监视器和投影仪上实现令人满意的显示,请通过设置衰退带的颜色和不透明性FaceColorFaceAlphaproperties of the output handles.

参考

[1]National Bureau of Economic Research (NBER),商业周期扩张和收缩,https://www.nber.org/research/data/us-business-cycle-expansions-and-cartractions.

版本历史

在R2012a中引入