Learn R Programming

tis (version 1.23)

nberShade: Plotting NBER Recesssions

Description

nberDates returns a matrix with two columns of yyyymmdd dates giving the Start and End dates of recessions fixed by the NBER. nber.xy returns a list of x and y coordinates that can be fed to polygon to draw NBER shadings on the current plot. It executes get("nberDates", pos = 1)() to do so. This means that if you have defined a local version of nberDates, it will be used rather than the one supplied by the tis package. If the last row from nberDates() has a Start entry but an "NA" End entry and openShade is FALSE, the returned list will not have coordinates for the last row, but will instead include a vLine element that gives the x coordinate of the last Start. If openShade is TRUE (the default), the list includes x and y coordinates for the most recent recession, using the second element of the horizontal range determined by the xrange parameter as its end time. nberShade is a generic method for shading recession areas on the current plot. The default version calls nber.xy to get x and y coordinates for the areas to be shaded and then passes those coordinates along with its own arguments to polygon to do the shading. It also draws a vertical line at the appropriate location if the list returned by nber.xy has a vLine element.

romerLines draws vertical lines on the current plot at the "Romer and Romer" dates when monetary policy is said to have become contractionary.

Usage

## S3 method for class 'default':
nberShade(col = grey(0.8), border = FALSE, xpd = FALSE,
          xrange = NULL, openShade = TRUE, ...)
nberDates()
nber.xy(xrange = NULL, openShade = TRUE)
romerLines()

Arguments

col
color to shade recessionary periods
border
the default (FALSE) omits borders on the shaded regions. TRUE draws borders in the foreground color. Alternatively, specify a border color.
xpd
should clipping take place?
...
other args passed to polygon
xrange
horizontal range over which recession shading should be drawn. The default value NULL uses the entire range of the plot. Note however the tisPlot uses the range of the data, which will generally differ the plot range unless t
openShade
governs how nber.xy and consequently nberShade handle the case where the last row of the matrix returned by nberDates has an NA in the "End" column, indicating that the end date of the most recent re

Value

  • As described above, nber.xy returns a list. The other functions described do not return anything useful.

References

Christina D. Romer and David H. Romer. 1989. "Does Monetary Policy Matter? A New Test in the Spirit of Friedman and Schwartz." NBER Macroeconomics Annual 4: 121-170. Christina D. Romer and David H. Romer. 1994. "Monetary Policy Matters." Journal ofMonetary Economics 34 (August): 75-88.

National Bureau of Economic Research. http://www.nber.org.

See Also

polygon, nberShade.ggplot

Examples

Run this code
require("datasets")
    plot(presidents, type='n', ylab="Presidents approval rating")
    nberShade()
    lines(presidents)

Run the code above in your browser using DataLab