The R package rtadfr (Right Tailed ADF Tests with R) facilitates the Phillips, Wu, and Yu (2011) and Phillips, Shi, and Yu (2015) right tailed unit root tests for exuberance behavior. This package is planned to be the R equivalent of the rtadf EViews add-in (Caspi, 2017).
You can install the development version from Github
# install.packages("devtools")
devtools::install_github("itamarcaspi/rtadfr")
library(rtadfr)
# SADF test
set.seed(1203) # for replicability
data(snp) # load S&P 500 data
obs <- nrow(snp) # Sample size
r0 <- round(obs*(0.01 + 1.8 / sqrt(obs))) # Minimal window size
test <- rtadf(snp[,1], r0, test = "sadf") # estimate test statistic and date-stamping sequence
cvs <- rtadfSimPar(obs, nrep = 1000, r0, test = "sadf") # simulate critical values and date-stamping threshold
testDf <- list("test statistic" = test$testStat, "critical values" = cvs$testCVs) # test results
print(testDf)
dateStampDf <- ts(cbind(testStat$testSeq, cvs$datestampCVs[,2]),
start = c(1870,1), frequency = 12) # data for datestamping procedure
ts.plot(dateStampDf, plot.type = "single", col=c("blue", "red"))