- Purpose My tryst with structural stability came with SUNPHARMA Dr Reddy Pair I could see that the residuals have a structural break in the models. But I did not have any thing in my toolbox to test the structural stability of the model. Lets look at the spread
> setwd("C:/Cauldron/garage/R/soulcraft/Volatility/Pairs/RelativeValue/Benchmark/Tests")
> y <- security.db1[, "SUNPHARMA"]
> x <- security.db1[, "DRREDDY"]
> gamma <- 0.589857169
> intercept <- 813.90882127
> mean <- 3.085667394
> sigma <- 83.285913717
> spread <- (y - x * gamma - intercept - mean)/sigma
> ecm.model <- y ~ x
> z <- data.frame(spread = spread, dates = trade.dates)
> z$trade_date <- as.Date(z$trade_date)
> library(ggplot2)
> pair <- "SUNPHARMA-DRREDDY"
> p <- ggplot(z, aes(x = trade_date, y = spread)) + scale_x_date()
> q <- p + geom_line(colour = "blue", lwd = 1.3)
> q <- q + geom_hline(yintercept = 0)
> q <- q + scale_x_date("Date")
> q <- q + scale_y_continuous("Spread")
> q <- q + opts(title = pair)
> print(q) |
![CUSUM_All_Pairs-001.jpg](images/cusum_all_pairs-001.jpg)
- Clearly there is a structural break in the behavior of spread.. Graphs below show the empirical fluctuation process for the entire time frame and a truncated time frame.
> par(mfrow = c(1, 2))
> y <- security.db1[, "SUNPHARMA"]
> x <- security.db1[, "DRREDDY"]
> dataset <- data.frame(y = y, x = x)
> ocus <- efp(ecm.model, type = "OLS-CUSUM", data = dataset)
> plot(ocus, main = "Entire Dataset")
> y <- security.db1[120:254, "SUNPHARMA"]
> x <- security.db1[120:254, "DRREDDY"]
> dataset.trunc <- data.frame(y = y, x = x)
> ocus <- efp(ecm.model, type = "OLS-CUSUM", data = dataset.trunc)
> plot(ocus, main = "Truncated Dataset") |
![CUSUM_All_Pairs-002.jpg](images/cusum_all_pairs-002.jpg)
Using the structural change test
> ocus <- efp(ecm.model, type = "OLS-CUSUM", data = dataset)
> sctest(ocus)
OLS-based CUSUM test
data: ocus
S0 = 3.2476, p-value = 1.381e-09
> ocus <- efp(ecm.model, type = "OLS-CUSUM", data = dataset.trunc)
> sctest(ocus)
OLS-based CUSUM test
data: ocus
S0 = 2.9604, p-value = 4.883e-08 |
I cant make out anything from the above result
> par(mfrow = c(1, 2))
> fs <- Fstats(ecm.model, data = dataset, from = 0.05, to = 0.95)
> plot(fs, pval = T)
> fs <- Fstats(ecm.model, data = dataset.trunc, from = 0.05, to = 0.95)
> plot(fs, pval = T) |
How should I move forward ? How should I indentify the structural breaks ?