# NOT RUN {
## Based on Figure 4 showing correlation structural breaks in Fernandez-Macho (2018).
library(wavemulcor)
options(warn = -1)
xrand1 <- wavemulcor::xrand1
xrand2 <- wavemulcor::xrand2
N <- length(xrand1)
b <- trunc(N/3)
t1 <- 1:b
t2 <- (b+1):(2*b)
t3 <- (2*b+1):N
wf <- "d4"
M <- N/2^3 #sharper with N/2^4
window <- "gaussian"
J <- trunc(log2(N))-3
# ---------------------------
cor1 <- cor(xrand1[t1],xrand2[t1])
cor2 <- cor(xrand1[t2],xrand2[t2])
cor3 <- cor(xrand1[t3],xrand2[t3])
cortext <- paste0(round(100*cor1,0),"-",round(100*cor2,0),"-",round(100*cor3,0))
ts.plot(cbind(xrand1,xrand2),col=c("red","blue"),xlab="time")
xx <- data.frame(xrand1,xrand2)
# ---------------------------
Lst <- local.multiple.regression(xx, M, window=window) #, ymax=1)
# ---------------------------
##Producing correlation plot
plot_local.multiple.correlation(Lst)
##Producing regression plot
plot_local.multiple.regression(Lst)
# }
Run the code above in your browser using DataLab