require(fracdiff) require(tseries) #Correlated noise Noise_rho<-function(n,rho){ e1<-rnorm(n) e<-rnorm(n) e2<-rho*e1+sqrt(1-rho^2)*e return(matrix(c(e1,e2),ncol=2)) } #Two ARFIMA processes with correlated innovations ARFIMA_rho<-function(n,d1,d2,rho){ e1<-rnorm(n) e<-rnorm(n) e2<-rho*e1+sqrt(1-rho^2)*e x<-fracdiff.sim(n,d=d1,innov=e1)$series y<-fracdiff.sim(n,d=d2,innov=e2)$series return(matrix(c(x,y),ncol=2)) } #ARFIMA and AR(1) processes with correlated innovations ARFIMA_AR<-function(n,d1,theta,rho){ e1<-rnorm(n) e<-rnorm(n) e2<-rho*e1+sqrt(1-rho^2)*e x<-fracdiff.sim(n,d=d1,innov=e1)$series y<-arima.sim(list(order=c(1,0,0),ar=theta),n,innov=e2) return(matrix(c(x,y),ncol=2)) } #Two AR(1) processes with correlated innovations AR_rho<-function(n,theta1,theta2,rho){ e1<-rnorm(n) e<-rnorm(n) e2<-rho*e1+sqrt(1-rho^2)*e x<-arima.sim(list(order=c(1,0,0),ar=theta1),n,innov=e1) y<-arima.sim(list(order=c(1,0,0),ar=theta2),n,innov=e2) return(matrix(c(x,y),ncol=2)) } #MC-ARFIMA process with LRC and LRCC (Model 1) Mixed_ARFIMA_ARFIMA<-function(alpha,beta,gamma,delta,n,d1,d2,d3,d4,rho){ e<-ARFIMA_rho(n,d2,d3,rho) e2<-e[,1] e3<-e[,2] x<-alpha*fracdiff.sim(n,d=d1)$series+beta*e2 y<-gamma*e3+delta*fracdiff.sim(n,d=d4)$series return(matrix(c(x,y),ncol=2)) } #MC-ARFIMA process with LRC and SRCC (Model 2) Mixed_ARFIMA_AR<-function(alpha,beta,gamma,delta,n,d1,d2,theta,rho){ e<-AR_rho(n,theta,theta,rho) e2<-e[,1] e3<-e[,2] x<-alpha*fracdiff.sim(n,d=d1)$series+beta*e2 y<-gamma*e3+delta*fracdiff.sim(n,d=d2)$series return(matrix(c(x,y),ncol=2)) } #MC-ARFIMA process with LRC and simple correlation (Model 3) Mixed_ARFIMA_noise<-function(alpha,beta,gamma,delta,n,d1,d2,rho){ e<-Noise_rho(n,rho) e2<-e[,1] e3<-e[,2] x<-alpha*fracdiff.sim(n,d=d1)$series+beta*e2 y<-gamma*e3+delta*fracdiff.sim(n,d=d2)$series return(matrix(c(x,y),ncol=2)) }