Apply the popular real-time monitoring strategy
proposed by Phillips, Shi and Yu (2015a,b;PSY)
psymonitor provides an accessible implementation of the popular
real-time monitoring strategy proposed by Phillips, Shi and Yu
(2015a,b;PSY), along with a new bootstrap procedure designed to mitigate
the potential impact of heteroskedasticity and to effect family-wise
size control in recursive testing algorithms (Phillips and Shi,
forthcoming). This methodology has been shown effective for bubble and
crisis detection (PSY, 2015a,b; Phillips and Shi, 2017) and is now
widely used by academic researchers, central bank economists, and fiscal
You can install the development version from GitHub
For the illustration purposes we will use data on the credit risk in the European sovereign sector, that is proxied by an index constructed as a GDP weighted 10-year government bond yield of the GIIPS (Greece, Ireland, Italy, Portugal, and Spain) countries, and comes with the ‘psymonitor’ package.
Let’s walk through some basics. First load the
psymonitor package and
get data on GIIPS spread.
Next, define a few parameters for the test and the simulation.
y <- spread$valueobs <- length(y)swindow0 <- floor(obs * (0.01 + 1.8 / sqrt(obs))) # set minimal window sizeIC <- 2 # use BIC to select the number of lagsadflag <- 6 # set the maximum nuber of lags to 6yr <- 2Tb <- 12*yr + swindow0 - 1 # Set the control sample sizenboot <- 99 # set the number of replications for the bootstrap
Next, estimate the PSY test statistic using
PSY() and its
corresponding bootstrap-based critical values using
bsadf <- PSY(y, swindow0 = swindow0, IC = IC,adflag = adflag) # estimate the PSY test statistics sequencequantilesBsadf <- cvPSYwmboot(y, swindow0 = swindow0, IC = IC,adflag = adflag, Tb = Tb, nboot = 99,nCores = 2) # simulate critical values via wild bootstrap. Note that the number of cores is arbitrarily set to 2.
Next, identify crisis periods, defined as periods where the test
statistic is above its corresponding critical value, using the
dim <- obs - swindow0 + 1monitorDates <- spread$date[swindow0:obs]quantile95 <- quantilesBsadf %*% matrix(1, nrow = 1, ncol = dim)ind95 <- (bsadf > t(quantile95[2, ])) * 1periods <- locate(ind95, monitorDates) # Locate crisis periods
Finally, print a table that holds the identified crisis periods with the
help of the
crisisDates <- disp(periods, obs) #generate table that holds crisis periodsprint(crisisDates)
NEWS.mdfile to track changes to the package.