Nam_Hoang_Waw

Copula Calibration + Simulation

Jan 10th, 2021 (edited)
1,028
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
R 27.84 KB | None | 0 0
  1. library("copula")
  2. library("VineCopula")
  3. library("lubridate")
  4. library("xts")
  5. library("stringr")
  6. library("dplyr")
  7. library("zoo")
  8. library("lmtest")
  9. library("vars")
  10. library("car")
  11. library("ggpubr")
  12. library("tseries")
  13. library("fitdistrplus")
  14. library("distr")
  15. library("MonteCarlo")
  16. library("car")
  17. library("MASS")
  18. library("caret")
  19. source("Copula_Class.R")
  20. #install.packages("caret")
  21.  
  22. #Initializing Copula classes:
  23. Gaussian_Copula <- Copula_Class$new(Copula_Family = 1)
  24. t_Copula <- Copula_Class$new(Copula_Family = 2)
  25. Frank_Copula <- Copula_Class$new(Copula_Family = 5)
  26.  
  27. # Setting:
  28. setwd("C:/Users/Nam_Hoang/Desktop/Copula Forecasting/")
  29. options(scipen = 30)
  30.  
  31. # Function that editing input data:
  32. data_edit <- function(index_input, headers_input, headers_kept){
  33.        
  34.         colnames(index_input) <- headers_input
  35.         index_input$Date <- as.Date(index_input$Date, "%b %d, %Y")
  36.         index_input$Change <- str_replace(index_input$Change , '\\%', '')
  37.         index_input$Change <- as.numeric(index_input$Change)
  38.         index_input$Price <- str_replace(index_input$Price , '\\,', '')
  39.         index_input$Price <- as.numeric(index_input$Price)
  40.         index_input$Change <- index_input$Change/100
  41.         index_input <- subset(index_input, select = headers_kept)
  42.         return (index_input)
  43.        
  44. }
  45.  
  46. # Function that generates random values from selected Parametric Bivariate Copula:
  47.  
  48. BiCop_Simulation <- function(n, family, par, par2){
  49.        
  50.         result = BiCopSim(n, family, par, par2)
  51.         return(list('result1' = result[1], 'result2' = result[2]))
  52.        
  53. }
  54.  
  55. # Monte Carlos Simulation:
  56.  
  57. Monte_Carlo_Simulation <- function(cop_family, nreps, forecast_intervals, series){
  58.         if (cop_family == 1){
  59.                 Copula_Calibration = Gaussian_Copula$Copula_Calibration(series,1,2)      
  60.         } else if (cop_family == 2){
  61.                 Copula_Calibration = t_Copula$Copula_Calibration(series,1,2)
  62.         } else {
  63.                 Copula_Calibration = Frank_Copula$Copula_Calibration(series,1,2)
  64.         }
  65.        
  66.         Copula_Object = BiCop(Copula_Calibration$family, Copula_Calibration$par, Copula_Calibration$par2,
  67.                               Copula_Calibration$tau)
  68.         parameters_list = list('n' = forecast_intervals, 'family' = Copula_Object$family, 'par' = Copula_Object$par,
  69.                                'par2' = Copula_Object$par2)
  70.        
  71.         Copula_Generator = MonteCarlo(func = BiCop_Simulation, nrep = nreps,
  72.                                       param_list = parameters_list, ncpus = 4, raw = TRUE)
  73.        
  74.         Marginal_Dist_Calibration_1 = fitdist(unclass(series)[,1], distr = "logis")
  75.         Marginal_Dist_Calibration_2 = fitdist(unclass(series)[,2], distr = "logis")
  76.        
  77.         Simulated_Values_1 = qlogis(Copula_Generator$result$result1[1:forecast_intervals], location =       Marginal_Dist_Calibration_1$estimate['location'],
  78.                                    scale = Marginal_Dist_Calibration_1$estimate['scale'])
  79.        
  80.         Simulated_Values_2 = qlogis(Copula_Generator$result$result2[1:forecast_intervals], location = Marginal_Dist_Calibration_2$estimate['location'],
  81.                                     scale = Marginal_Dist_Calibration_2$estimate['scale'])
  82.        
  83.         return (list('Simulated_Value_1' = Simulated_Values_1, 'Simulated_Value_2' = Simulated_Values_2))
  84. }
  85.  
  86. # Load indexes' historical data
  87. SP500 <- read.csv(file = 'SP500.csv')
  88. VIX <- read.csv(file = 'VIX.csv')
  89. STOXX <- read.csv(file = 'STOXX50.csv')
  90. VSTOXX <- read.csv(file = 'VSTOXX50.csv')
  91. HSI <- read.csv(file = 'HSI.csv')
  92. VHSI <- read.csv(file = 'VHSI.csv')
  93.  
  94. #Setting headers' names
  95. index <- list(
  96.         "SP500" = SP500,
  97.         "VIX" = VIX,
  98.         "STOXX" = STOXX,
  99.         "VSTOXX" = VSTOXX,
  100.         "HSI" = HSI,
  101.         "VHSI" = VHSI)
  102.  
  103. headers <- c("Date", "Price", "Open", "High", "Low", "Vol", "Change")
  104. headers_select <- c("Date", "Price", "Change")
  105.  
  106. SP500 <- data_edit(SP500,headers,headers_select)
  107. VIX <- data_edit(VIX,headers,headers_select)
  108. STOXX <- data_edit(STOXX,headers,headers_select)
  109. VSTOXX <- data_edit(VSTOXX,headers,headers_select)
  110. HSI <- data_edit(HSI,headers,headers_select)
  111. VHSI <- data_edit(VHSI,headers,headers_select)
  112.  
  113. SP500_VIX <- merge(SP500,VIX,by="Date",all=T)
  114. STOXX_VSTOXX <- merge(STOXX,VSTOXX,by="Date",all=T)
  115. HSI_VHSI <- merge(HSI,VHSI,by="Date",all=T)
  116.  
  117. SP_VIX_headers <- c("Date", "Price_SP500", "Change_SP500", "Price_VIX", "Change_VIX")
  118. STOXX_VSTOXX_headers <- c("Date", "Price_STOXX", "Change_STOXX", "Price_VSTOXX", "Change_VSTOXX")
  119. HSI_VHSI_headers <- c("Date", "Price_HSI", "Change_HSI", "Price_VHSI", "Change_VHSI")
  120.  
  121. colnames(SP500_VIX) <- SP_VIX_headers
  122. colnames(STOXX_VSTOXX) <- STOXX_VSTOXX_headers
  123. colnames(HSI_VHSI) <- HSI_VHSI_headers
  124.  
  125. # training/testing periods - SP500_VIX
  126. SP500_VIX_training <- SP500_VIX[1775:3556,]
  127. SP500_VIX_testing <- SP500_VIX[3557:3856,]
  128. # max 2396
  129. # training period - STOXX_VSTOXX
  130. STOXX_VSTOXX_training <- STOXX_VSTOXX[357:2096,]
  131. STOXX_VSTOXX_testing <- STOXX_VSTOXX[2097:2396,]
  132.  
  133. # max 4964
  134. # training period - HSI_VHSI
  135. HSI_VHSI_training <- HSI_VHSI[3006:4664,]
  136. HSI_VHSI_testing <- HSI_VHSI[4665:4964,]
  137.  
  138. SP500_VIX_training$Price_SP500 <- na.locf(SP500_VIX_training$Price_SP500)
  139. SP500_VIX_training$Change_SP500 <- na.fill(SP500_VIX_training$Change_SP500, fill = 0)
  140. SP500_VIX_training$Price_VIX <- na.locf(SP500_VIX_training$Price_VIX)
  141. SP500_VIX_training$Change_VIX <- na.fill(SP500_VIX_training$Change_VIX, fill = 0)
  142.  
  143. SP500_VIX_testing$Price_SP500 <- na.locf(SP500_VIX_testing$Price_SP500)
  144. SP500_VIX_testing$Change_SP500 <- na.fill(SP500_VIX_testing$Change_SP500, fill = 0)
  145. SP500_VIX_testing$Price_VIX <- na.locf(SP500_VIX_testing$Price_VIX)
  146. SP500_VIX_testing$Change_VIX <- na.fill(SP500_VIX_testing$Change_VIX, fill = 0)
  147.  
  148. STOXX_VSTOXX_training$Price_STOXX <- na.locf(STOXX_VSTOXX_training$Price_STOXX)
  149. STOXX_VSTOXX_training$Change_STOXX <- na.fill(STOXX_VSTOXX_training$Change_STOXX, fill = 0)
  150. STOXX_VSTOXX_training$Price_VSTOXX <- na.locf(STOXX_VSTOXX_training$Price_VSTOXX)
  151. STOXX_VSTOXX_training$Change_VSTOXX <- na.fill(STOXX_VSTOXX_training$Change_VSTOXX, fill = 0)
  152.  
  153. STOXX_VSTOXX_testing$Price_STOXX <- na.locf(STOXX_VSTOXX_testing$Price_STOXX)
  154. STOXX_VSTOXX_testing$Change_STOXX <- na.fill(STOXX_VSTOXX_testing$Change_STOXX, fill = 0)
  155. STOXX_VSTOXX_testing$Price_VSTOXX <- na.locf(STOXX_VSTOXX_testing$Price_VSTOXX)
  156. STOXX_VSTOXX_testing$Change_VSTOXX <- na.fill(STOXX_VSTOXX_testing$Change_VSTOXX, fill = 0)
  157.  
  158. HSI_VHSI_training$Price_HSI <- na.locf(HSI_VHSI_training$Price_HSI)
  159. HSI_VHSI_training$Change_HSI <- na.fill(HSI_VHSI_training$Change_HSI, fill = 0)
  160. HSI_VHSI_training$Price_VHSI <- na.locf(HSI_VHSI_training$Price_VHSI)
  161. HSI_VHSI_training$Change_VHSI <- na.fill(HSI_VHSI_training$Change_VHSI, fill = 0)
  162.  
  163. HSI_VHSI_testing$Price_HSI <- na.locf(HSI_VHSI_testing$Price_HSI)
  164. HSI_VHSI_testing$Change_HSI <- na.fill(HSI_VHSI_testing$Change_HSI, fill = 0)
  165. HSI_VHSI_testing$Price_VHSI <- na.locf(HSI_VHSI_testing$Price_VHSI)
  166. HSI_VHSI_testing$Change_VHSI <- na.fill(HSI_VHSI_testing$Change_VHSI, fill = 0)
  167.  
  168. SP500_VIX_Price <- subset(SP500_VIX_training, select = c("Date", "Price_SP500",  "Price_VIX"))
  169. SP500_VIX_Price <- xts(SP500_VIX_Price[,-1], SP500_VIX_Price$Date)
  170.  
  171. SP500_VIX_Change <- subset(SP500_VIX_training, select = c("Date", "Change_SP500",  "Change_VIX"))
  172. SP500_VIX_Change <- xts(SP500_VIX_Change[,-1], SP500_VIX_Change$Date)
  173.  
  174. STOXX_VSTOXX_Price <- subset(STOXX_VSTOXX_training, select = c("Date", "Price_STOXX",  "Price_VSTOXX"))
  175. STOXX_VSTOXX_Price <- xts(STOXX_VSTOXX_Price[,-1], STOXX_VSTOXX_Price$Date)
  176.  
  177. STOXX_VSTOXX_Change <- subset(STOXX_VSTOXX_training, select = c("Date", "Change_STOXX",  "Change_VSTOXX"))
  178. STOXX_VSTOXX_Change <- xts(STOXX_VSTOXX_Change[,-1], STOXX_VSTOXX_Change$Date)
  179.  
  180. HSI_VHSI_Price <- subset(HSI_VHSI_training, select = c("Date", "Price_HSI",  "Price_VHSI"))
  181. HSI_VHSI_Price <- xts(HSI_VHSI_Price[,-1], HSI_VHSI_Price$Date)
  182.  
  183. HSI_VHSI_Change <- subset(HSI_VHSI_training, select = c("Date", "Change_HSI",  "Change_VHSI"))
  184. HSI_VHSI_Change <- xts(HSI_VHSI_Change[,-1], HSI_VHSI_Change$Date)
  185.  
  186. # Pre-scanning for potential marginal distribution:
  187. descdist(SP500_VIX_training$Change_SP500, discrete = FALSE)
  188. descdist(SP500_VIX_training$Change_VIX, discrete = FALSE)
  189. descdist(STOXX_VSTOXX_training$Change_STOXX, discrete = FALSE)
  190. descdist(STOXX_VSTOXX_training$Change_VSTOXX, discrete = FALSE)
  191. descdist(HSI_VHSI_training$Change_HSI, discrete = FALSE)
  192. descdist(HSI_VHSI_training$Change_VHSI, discrete = FALSE)
  193.  
  194. # fitting distribution:
  195. SP500_logistic = fitdist(SP500_VIX_training$Change_SP500, distr = "logis")
  196. SP500_norm = fitdist(SP500_VIX_training$Change_SP500, distr = "norm")
  197.  
  198.  
  199. VIX_logistic = fitdist(SP500_VIX_training$Change_VIX, distr = "logis")
  200. VIX_norm = fitdist(SP500_VIX_training$Change_VIX, distr = "norm")
  201.  
  202.  
  203. STOXX_logistic = fitdist(STOXX_VSTOXX_training$Change_STOXX, distr = "logis")
  204. STOXX_norm = fitdist(STOXX_VSTOXX_training$Change_STOXX, distr = "norm")
  205.  
  206.  
  207. VSTOXX_logistic = fitdist(STOXX_VSTOXX_training$Change_VSTOXX, distr = "logis")
  208. VSTOXX_norm = fitdist(STOXX_VSTOXX_training$Change_VSTOXX, distr = "norm")
  209.  
  210.  
  211. HSI_logistic = fitdist(HSI_VHSI_training$Change_HSI, distr = "logis")
  212. HSI_norm = fitdist(HSI_VHSI_training$Change_HSI, distr = "norm")
  213.  
  214.  
  215. VHSI_logistic = fitdist(HSI_VHSI_training$Change_VHSI, distr = "logis")
  216. VHSI_norm = fitdist(HSI_VHSI_training$Change_VHSI, distr = "norm")
  217.  
  218. # checking fitness via parametric CDF vs. empirical CDF:
  219. cdfcomp(list(STOXX_logistic, STOXX_norm), legendtext = c("logistic", "norm"), main = "STOXX's return fits")
  220. cdfcomp(list(VSTOXX_logistic, VSTOXX_norm), legendtext = c("logistic", "norm"), main = "VSTOXX's return fits")
  221. cdfcomp(list(SP500_logistic, SP500_norm), legendtext = c("logistic", "norm"), main = "SP500's return fits")
  222. cdfcomp(list(VIX_logistic, VIX_norm), legendtext = c("logistic", "norm"), main = "VIX's return fits")
  223. cdfcomp(list(HSI_logistic, HSI_norm), legendtext = c("logistic", "norm"), main = "HSI's return fits")
  224. cdfcomp(list(VHSI_logistic, VHSI_norm), legendtext = c("logistic", "norm"), main = "VHSI's return fits")
  225.  
  226. # Goodness of fit statistics:
  227. SP500_GoF = gofstat(list(SP500_logistic, SP500_norm),
  228.                     fitnames = c("logistic", "normal"))
  229.  
  230. VIX_GoF = gofstat(list(VIX_logistic, VIX_norm),
  231.                     fitnames = c("logistic", "normal"))
  232.  
  233. VSTOXX_GoF = gofstat(list(VSTOXX_logistic, VSTOXX_norm),
  234.                   fitnames = c("logistic", "normal"))
  235.  
  236. STOXX_GoF = gofstat(list(STOXX_logistic, STOXX_norm),
  237.                      fitnames = c("logistic", "normal"))
  238.  
  239. VHSI_GoF = gofstat(list(VHSI_logistic, VHSI_norm),
  240.                      fitnames = c("logistic", "normal"))
  241.  
  242. HSI_GoF = gofstat(list(HSI_logistic, HSI_norm),
  243.                      fitnames = c("logistic", "normal"))
  244.  
  245. # Simulating forecast values:
  246. # Gaussian Copula:
  247. SP500_VIX_Simulation_Gaussian_50 = Monte_Carlo_Simulation(1,10000,50,SP500_VIX_Change)
  248. HSI_VHSI_Simulation_Gaussian_50 = Monte_Carlo_Simulation(1,10000,50,HSI_VHSI_Change)
  249. STOXX_VSTOXX_Simulation_Gaussian_50 = Monte_Carlo_Simulation(1,10000,50,STOXX_VSTOXX_Change)
  250.  
  251. SP500_VIX_Simulation_Gaussian_100 = Monte_Carlo_Simulation(1,10000,100,SP500_VIX_Change)
  252. HSI_VHSI_Simulation_Gaussian_100 = Monte_Carlo_Simulation(1,10000,100,HSI_VHSI_Change)
  253. STOXX_VSTOXX_Simulation_Gaussian_100 = Monte_Carlo_Simulation(1,10000,100,STOXX_VSTOXX_Change)
  254.  
  255. SP500_VIX_Simulation_Gaussian_200 = Monte_Carlo_Simulation(1,10000,200,SP500_VIX_Change)
  256. HSI_VHSI_Simulation_Gaussian_200 = Monte_Carlo_Simulation(1,10000,200,HSI_VHSI_Change)
  257. STOXX_VSTOXX_Simulation_Gaussian_200 = Monte_Carlo_Simulation(1,10000,200,STOXX_VSTOXX_Change)
  258.  
  259. SP500_VIX_Simulation_Gaussian_300 = Monte_Carlo_Simulation(1,10000,300,SP500_VIX_Change)
  260. HSI_VHSI_Simulation_Gaussian_300 = Monte_Carlo_Simulation(1,10000,300,HSI_VHSI_Change)
  261. STOXX_VSTOXX_Simulation_Gaussian_300 = Monte_Carlo_Simulation(1,10000,300,STOXX_VSTOXX_Change)
  262.  
  263. # t Copula:
  264. SP500_VIX_Simulation_t_50 = Monte_Carlo_Simulation(2,10000,50,SP500_VIX_Change)
  265. HSI_VHSI_Simulation_t_50 = Monte_Carlo_Simulation(2,10000,50,HSI_VHSI_Change)
  266. STOXX_VSTOXX_Simulation_t_50 = Monte_Carlo_Simulation(2,10000,50,STOXX_VSTOXX_Change)
  267.  
  268. SP500_VIX_Simulation_t_100 = Monte_Carlo_Simulation(2,10000,100,SP500_VIX_Change)
  269. HSI_VHSI_Simulation_t_100 = Monte_Carlo_Simulation(2,10000,100,HSI_VHSI_Change)
  270. STOXX_VSTOXX_Simulation_t_100 = Monte_Carlo_Simulation(2,10000,100,STOXX_VSTOXX_Change)
  271.  
  272. SP500_VIX_Simulation_t_200 = Monte_Carlo_Simulation(2,10000,200,SP500_VIX_Change)
  273. HSI_VHSI_Simulation_t_200 = Monte_Carlo_Simulation(2,10000,200,HSI_VHSI_Change)
  274. STOXX_VSTOXX_Simulation_t_200 = Monte_Carlo_Simulation(2,10000,200,STOXX_VSTOXX_Change)
  275.  
  276. SP500_VIX_Simulation_t_300 = Monte_Carlo_Simulation(2,10000,300,SP500_VIX_Change)
  277. HSI_VHSI_Simulation_t_300 = Monte_Carlo_Simulation(2,10000,300,HSI_VHSI_Change)
  278. STOXX_VSTOXX_Simulation_t_300 = Monte_Carlo_Simulation(2,10000,300,STOXX_VSTOXX_Change)
  279.  
  280. # Frank Copula:
  281. SP500_VIX_Simulation_Frank_50 = Monte_Carlo_Simulation(5,10000,50,SP500_VIX_Change)
  282. HSI_VHSI_Simulation_Frank_50 = Monte_Carlo_Simulation(5,10000,50,HSI_VHSI_Change)
  283. STOXX_VSTOXX_Simulation_Frank_50 = Monte_Carlo_Simulation(5,10000,50,STOXX_VSTOXX_Change)
  284.  
  285. SP500_VIX_Simulation_Frank_100 = Monte_Carlo_Simulation(5,10000,100,SP500_VIX_Change)
  286. HSI_VHSI_Simulation_Frank_100 = Monte_Carlo_Simulation(5,10000,100,HSI_VHSI_Change)
  287. STOXX_VSTOXX_Simulation_Frank_100 = Monte_Carlo_Simulation(5,10000,100,STOXX_VSTOXX_Change)
  288.  
  289. SP500_VIX_Simulation_Frank_200 = Monte_Carlo_Simulation(5,10000,200,SP500_VIX_Change)
  290. HSI_VHSI_Simulation_Frank_200 = Monte_Carlo_Simulation(5,10000,200,HSI_VHSI_Change)
  291. STOXX_VSTOXX_Simulation_Frank_200 = Monte_Carlo_Simulation(5,10000,200,STOXX_VSTOXX_Change)
  292.  
  293. SP500_VIX_Simulation_Frank_300 = Monte_Carlo_Simulation(5,10000,300,SP500_VIX_Change)
  294. HSI_VHSI_Simulation_Frank_300 = Monte_Carlo_Simulation(5,10000,300,HSI_VHSI_Change)
  295. STOXX_VSTOXX_Simulation_Frank_300 = Monte_Carlo_Simulation(5,10000,300,STOXX_VSTOXX_Change)
  296.  
  297. #Note: 1 = Gaussian Copula, 2 = t Copula, 5 = Frank Copula
  298.  
  299. # Testing samples:
  300.  
  301. SP500_testing_50 = SP500_VIX_testing$Change_SP500[1:50]
  302. SP500_testing_100 = SP500_VIX_testing$Change_SP500[1:100]
  303. SP500_testing_200 = SP500_VIX_testing$Change_SP500[1:200]
  304. SP500_testing_300 = SP500_VIX_testing$Change_SP500[1:300]
  305.  
  306. VIX_testing_50 = SP500_VIX_testing$Change_VIX[1:50]
  307. VIX_testing_100 = SP500_VIX_testing$Change_VIX[1:100]
  308. VIX_testing_200 = SP500_VIX_testing$Change_VIX[1:200]
  309. VIX_testing_300 = SP500_VIX_testing$Change_VIX[1:300]
  310.  
  311. STOXX_testing_50 = STOXX_VSTOXX_testing$Change_STOXX[1:50]
  312. STOXX_testing_100 = STOXX_VSTOXX_testing$Change_STOXX[1:100]
  313. STOXX_testing_200 = STOXX_VSTOXX_testing$Change_STOXX[1:200]
  314. STOXX_testing_300 = STOXX_VSTOXX_testing$Change_STOXX[1:300]
  315.  
  316. VSTOXX_testing_50 = STOXX_VSTOXX_testing$Change_VSTOXX[1:50]
  317. VSTOXX_testing_100 = STOXX_VSTOXX_testing$Change_VSTOXX[1:100]
  318. VSTOXX_testing_200 = STOXX_VSTOXX_testing$Change_VSTOXX[1:200]
  319. VSTOXX_testing_300 = STOXX_VSTOXX_testing$Change_VSTOXX[1:300]
  320.  
  321. HSI_testing_50 = HSI_VHSI_testing$Change_HSI[1:50]
  322. HSI_testing_100 = HSI_VHSI_testing$Change_HSI[1:100]
  323. HSI_testing_200 = HSI_VHSI_testing$Change_HSI[1:200]
  324. HSI_testing_300 = HSI_VHSI_testing$Change_HSI[1:300]
  325.  
  326. VHSI_testing_50 = HSI_VHSI_testing$Change_VHSI[1:50]
  327. VHSI_testing_100 = HSI_VHSI_testing$Change_VHSI[1:100]
  328. VHSI_testing_200 = HSI_VHSI_testing$Change_VHSI[1:200]
  329. VHSI_testing_300 = HSI_VHSI_testing$Change_VHSI[1:300]
  330.  
  331. # Forecast KPIs:
  332.  
  333. # SP500_VIX:
  334. Gaussian_MAE_SP500_50 = MAE(unlist(SP500_VIX_Simulation_Gaussian_50[1]),SP500_testing_50)
  335. Gaussian_MAE_SP500_100 = MAE(unlist(SP500_VIX_Simulation_Gaussian_100[1]),SP500_testing_100)
  336. Gaussian_MAE_SP500_200 = MAE(unlist(SP500_VIX_Simulation_Gaussian_200[1]),SP500_testing_200)
  337. Gaussian_MAE_SP500_300 = MAE(unlist(SP500_VIX_Simulation_Gaussian_300[1]),SP500_testing_300)
  338.  
  339. plot(unlist(SP500_VIX_Simulation_Gaussian_300[1]),  type="l", col="green", lwd=2)
  340. lines(SP500_testing_300, col="red", lwd=2)
  341.  
  342. Gaussian_MAE_VIX_50 = MAE(unlist(SP500_VIX_Simulation_Gaussian_50[2]),VIX_testing_50)
  343. Gaussian_MAE_VIX_100 = MAE(unlist(SP500_VIX_Simulation_Gaussian_100[2]),VIX_testing_100)
  344. Gaussian_MAE_VIX_200 = MAE(unlist(SP500_VIX_Simulation_Gaussian_200[2]),VIX_testing_200)
  345. Gaussian_MAE_VIX_300 = MAE(unlist(SP500_VIX_Simulation_Gaussian_300[2]),VIX_testing_300)
  346.  
  347. Gaussian_RMSE_SP500_50 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_50[1]),SP500_testing_50)
  348. Gaussian_RMSE_SP500_100 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_100[1]),SP500_testing_100)
  349. Gaussian_RMSE_SP500_200 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_200[1]),SP500_testing_200)
  350. Gaussian_RMSE_SP500_300 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_300[1]),SP500_testing_300)
  351.  
  352. Gaussian_RMSE_VIX_50 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_50[2]),VIX_testing_50)
  353. Gaussian_RMSE_VIX_100 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_100[2]),VIX_testing_100)
  354. Gaussian_RMSE_VIX_200 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_200[2]),VIX_testing_200)
  355. Gaussian_RMSE_VIX_300 = RMSE(unlist(SP500_VIX_Simulation_Gaussian_300[2]),VIX_testing_300)
  356.  
  357. t_MAE_SP500_50 = MAE(unlist(SP500_VIX_Simulation_t_50[1]),SP500_testing_50)
  358. t_MAE_SP500_100 = MAE(unlist(SP500_VIX_Simulation_t_100[1]),SP500_testing_100)
  359. t_MAE_SP500_200 = MAE(unlist(SP500_VIX_Simulation_t_200[1]),SP500_testing_200)
  360. t_MAE_SP500_300 = MAE(unlist(SP500_VIX_Simulation_t_300[1]),SP500_testing_300)
  361.  
  362. t_MAE_VIX_50 = MAE(unlist(SP500_VIX_Simulation_t_50[2]),VIX_testing_50)
  363. t_MAE_VIX_100 = MAE(unlist(SP500_VIX_Simulation_t_100[2]),VIX_testing_100)
  364. t_MAE_VIX_200 = MAE(unlist(SP500_VIX_Simulation_t_200[2]),VIX_testing_200)
  365. t_MAE_VIX_300 = MAE(unlist(SP500_VIX_Simulation_t_300[2]),VIX_testing_300)
  366.  
  367. t_RMSE_SP500_50 = RMSE(unlist(SP500_VIX_Simulation_t_50[1]),SP500_testing_50)
  368. t_RMSE_SP500_100 = RMSE(unlist(SP500_VIX_Simulation_t_100[1]),SP500_testing_100)
  369. t_RMSE_SP500_200 = RMSE(unlist(SP500_VIX_Simulation_t_200[1]),SP500_testing_200)
  370. t_RMSE_SP500_300 = RMSE(unlist(SP500_VIX_Simulation_t_300[1]),SP500_testing_300)
  371.  
  372. t_RMSE_VIX_50 = RMSE(unlist(SP500_VIX_Simulation_t_50[2]),VIX_testing_50)
  373. t_RMSE_VIX_100 = RMSE(unlist(SP500_VIX_Simulation_t_100[2]),VIX_testing_100)
  374. t_RMSE_VIX_200 = RMSE(unlist(SP500_VIX_Simulation_t_200[2]),VIX_testing_200)
  375. t_RMSE_VIX_300 = RMSE(unlist(SP500_VIX_Simulation_t_300[2]),VIX_testing_300)
  376.  
  377. Frank_MAE_SP500_50 = MAE(unlist(SP500_VIX_Simulation_Frank_50[1]),SP500_testing_50)
  378. Frank_MAE_SP500_100 = MAE(unlist(SP500_VIX_Simulation_Frank_100[1]),SP500_testing_100)
  379. Frank_MAE_SP500_200 = MAE(unlist(SP500_VIX_Simulation_Frank_200[1]),SP500_testing_200)
  380. Frank_MAE_SP500_300 = MAE(unlist(SP500_VIX_Simulation_Frank_300[1]),SP500_testing_300)
  381.  
  382. Frank_MAE_VIX_50 = MAE(unlist(SP500_VIX_Simulation_Frank_50[2]),VIX_testing_50)
  383. Frank_MAE_VIX_100 = MAE(unlist(SP500_VIX_Simulation_Frank_100[2]),VIX_testing_100)
  384. Frank_MAE_VIX_200 = MAE(unlist(SP500_VIX_Simulation_Frank_200[2]),VIX_testing_200)
  385. Frank_MAE_VIX_300 = MAE(unlist(SP500_VIX_Simulation_Frank_300[2]),VIX_testing_300)
  386.  
  387. Frank_RMSE_SP500_50 = RMSE(unlist(SP500_VIX_Simulation_Frank_50[1]),SP500_testing_50)
  388. Frank_RMSE_SP500_100 = RMSE(unlist(SP500_VIX_Simulation_Frank_100[1]),SP500_testing_100)
  389. Frank_RMSE_SP500_200 = RMSE(unlist(SP500_VIX_Simulation_Frank_200[1]),SP500_testing_200)
  390. Frank_RMSE_SP500_300 = RMSE(unlist(SP500_VIX_Simulation_Frank_300[1]),SP500_testing_300)
  391.  
  392. Frank_RMSE_VIX_50 = RMSE(unlist(SP500_VIX_Simulation_Frank_50[2]),VIX_testing_50)
  393. Frank_RMSE_VIX_100 = RMSE(unlist(SP500_VIX_Simulation_Frank_100[2]),VIX_testing_100)
  394. Frank_RMSE_VIX_200 = RMSE(unlist(SP500_VIX_Simulation_Frank_200[2]),VIX_testing_200)
  395. Frank_RMSE_VIX_300 = RMSE(unlist(SP500_VIX_Simulation_Frank_300[2]),VIX_testing_300)
  396.  
  397. # HSI_VHSI:
  398. Gaussian_MAE_HSI_50 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_50[1]),HSI_testing_50)
  399. Gaussian_MAE_HSI_100 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_100[1]),HSI_testing_100)
  400. Gaussian_MAE_HSI_200 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_200[1]),HSI_testing_200)
  401. Gaussian_MAE_HSI_300 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_300[1]),HSI_testing_300)
  402.  
  403. Gaussian_MAE_VHSI_50 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_50[2]),VHSI_testing_50)
  404. Gaussian_MAE_VHSI_100 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_100[2]),VHSI_testing_100)
  405. Gaussian_MAE_VHSI_200 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_200[2]),VHSI_testing_200)
  406. Gaussian_MAE_VHSI_300 = MAE(unlist(HSI_VHSI_Simulation_Gaussian_300[2]),VHSI_testing_300)
  407.  
  408. Gaussian_RMSE_HSI_50 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_50[1]),HSI_testing_50)
  409. Gaussian_RMSE_HSI_100 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_100[1]),HSI_testing_100)
  410. Gaussian_RMSE_HSI_200 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_200[1]),HSI_testing_200)
  411. Gaussian_RMSE_HSI_300 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_300[1]),HSI_testing_300)
  412.  
  413. Gaussian_RMSE_VHSI_50 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_50[2]),VHSI_testing_50)
  414. Gaussian_RMSE_VHSI_100 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_100[2]),VHSI_testing_100)
  415. Gaussian_RMSE_VHSI_200 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_200[2]),VHSI_testing_200)
  416. Gaussian_RMSE_VHSI_300 = RMSE(unlist(HSI_VHSI_Simulation_Gaussian_300[2]),VHSI_testing_300)
  417.  
  418. t_MAE_HSI_50 = MAE(unlist(HSI_VHSI_Simulation_t_50[1]),HSI_testing_50)
  419. t_MAE_HSI_100 = MAE(unlist(HSI_VHSI_Simulation_t_100[1]),HSI_testing_100)
  420. t_MAE_HSI_200 = MAE(unlist(HSI_VHSI_Simulation_t_200[1]),HSI_testing_200)
  421. t_MAE_HSI_300 = MAE(unlist(HSI_VHSI_Simulation_t_300[1]),HSI_testing_300)
  422.  
  423. t_MAE_VHSI_50 = MAE(unlist(HSI_VHSI_Simulation_t_50[2]),VHSI_testing_50)
  424. t_MAE_VHSI_100 = MAE(unlist(HSI_VHSI_Simulation_t_100[2]),VHSI_testing_100)
  425. t_MAE_VHSI_200 = MAE(unlist(HSI_VHSI_Simulation_t_200[2]),VHSI_testing_200)
  426. t_MAE_VHSI_300 = MAE(unlist(HSI_VHSI_Simulation_t_300[2]),VHSI_testing_300)
  427.  
  428. t_RMSE_HSI_50 = RMSE(unlist(HSI_VHSI_Simulation_t_50[1]),HSI_testing_50)
  429. t_RMSE_HSI_100 = RMSE(unlist(HSI_VHSI_Simulation_t_100[1]),HSI_testing_100)
  430. t_RMSE_HSI_200 = RMSE(unlist(HSI_VHSI_Simulation_t_200[1]),HSI_testing_200)
  431. t_RMSE_HSI_300 = RMSE(unlist(HSI_VHSI_Simulation_t_300[1]),HSI_testing_300)
  432.  
  433. t_RMSE_VHSI_50 = RMSE(unlist(HSI_VHSI_Simulation_t_50[2]),VHSI_testing_50)
  434. t_RMSE_VHSI_100 = RMSE(unlist(HSI_VHSI_Simulation_t_100[2]),VHSI_testing_100)
  435. t_RMSE_VHSI_200 = RMSE(unlist(HSI_VHSI_Simulation_t_200[2]),VHSI_testing_200)
  436. t_RMSE_VHSI_300 = RMSE(unlist(HSI_VHSI_Simulation_t_300[2]),VHSI_testing_300)
  437.  
  438. Frank_MAE_HSI_50 = MAE(unlist(HSI_VHSI_Simulation_Frank_50[1]),HSI_testing_50)
  439. Frank_MAE_HSI_100 = MAE(unlist(HSI_VHSI_Simulation_Frank_100[1]),HSI_testing_100)
  440. Frank_MAE_HSI_200 = MAE(unlist(HSI_VHSI_Simulation_Frank_200[1]),HSI_testing_200)
  441. Frank_MAE_HSI_300 = MAE(unlist(HSI_VHSI_Simulation_Frank_300[1]),HSI_testing_300)
  442.  
  443. Frank_MAE_VHSI_50 = MAE(unlist(HSI_VHSI_Simulation_Frank_50[2]),VHSI_testing_50)
  444. Frank_MAE_VHSI_100 = MAE(unlist(HSI_VHSI_Simulation_Frank_100[2]),VHSI_testing_100)
  445. Frank_MAE_VHSI_200 = MAE(unlist(HSI_VHSI_Simulation_Frank_200[2]),VHSI_testing_200)
  446. Frank_MAE_VHSI_300 = MAE(unlist(HSI_VHSI_Simulation_Frank_300[2]),VHSI_testing_300)
  447.  
  448. Frank_RMSE_HSI_50 = RMSE(unlist(HSI_VHSI_Simulation_Frank_50[1]),HSI_testing_50)
  449. Frank_RMSE_HSI_100 = RMSE(unlist(HSI_VHSI_Simulation_Frank_100[1]),HSI_testing_100)
  450. Frank_RMSE_HSI_200 = RMSE(unlist(HSI_VHSI_Simulation_Frank_200[1]),HSI_testing_200)
  451. Frank_RMSE_HSI_300 = RMSE(unlist(HSI_VHSI_Simulation_Frank_300[1]),HSI_testing_300)
  452.  
  453. Frank_RMSE_VHSI_50 = RMSE(unlist(HSI_VHSI_Simulation_Frank_50[2]),VHSI_testing_50)
  454. Frank_RMSE_VHSI_100 = RMSE(unlist(HSI_VHSI_Simulation_Frank_100[2]),VHSI_testing_100)
  455. Frank_RMSE_VHSI_200 = RMSE(unlist(HSI_VHSI_Simulation_Frank_200[2]),VHSI_testing_200)
  456. Frank_RMSE_VHSI_300 = RMSE(unlist(HSI_VHSI_Simulation_Frank_300[2]),VHSI_testing_300)
  457.  
  458. # STOXX_VSTOXX:
  459. Gaussian_MAE_STOXX_50 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_50[1]),STOXX_testing_50)
  460. Gaussian_MAE_STOXX_100 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_100[1]),STOXX_testing_100)
  461. Gaussian_MAE_STOXX_200 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_200[1]),STOXX_testing_200)
  462. Gaussian_MAE_STOXX_300 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_300[1]),STOXX_testing_300)
  463.  
  464. Gaussian_MAE_VSTOXX_50 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_50[2]),VSTOXX_testing_50)
  465. Gaussian_MAE_VSTOXX_100 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_100[2]),VSTOXX_testing_100)
  466. Gaussian_MAE_VSTOXX_200 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_200[2]),VSTOXX_testing_200)
  467. Gaussian_MAE_VSTOXX_300 = MAE(unlist(STOXX_VSTOXX_Simulation_Gaussian_300[2]),VSTOXX_testing_300)
  468.  
  469. Gaussian_RMSE_STOXX_50 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_50[1]),STOXX_testing_50)
  470. Gaussian_RMSE_STOXX_100 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_100[1]),STOXX_testing_100)
  471. Gaussian_RMSE_STOXX_200 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_200[1]),STOXX_testing_200)
  472. Gaussian_RMSE_STOXX_300 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_300[1]),STOXX_testing_300)
  473.  
  474. Gaussian_RMSE_VSTOXX_50 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_50[2]),VSTOXX_testing_50)
  475. Gaussian_RMSE_VSTOXX_100 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_100[2]),VSTOXX_testing_100)
  476. Gaussian_RMSE_VSTOXX_200 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_200[2]),VSTOXX_testing_200)
  477. Gaussian_RMSE_VSTOXX_300 = RMSE(unlist(STOXX_VSTOXX_Simulation_Gaussian_300[2]),VSTOXX_testing_300)
  478.  
  479. t_MAE_STOXX_50 = MAE(unlist(STOXX_VSTOXX_Simulation_t_50[1]),STOXX_testing_50)
  480. t_MAE_STOXX_100 = MAE(unlist(STOXX_VSTOXX_Simulation_t_100[1]),STOXX_testing_100)
  481. t_MAE_STOXX_200 = MAE(unlist(STOXX_VSTOXX_Simulation_t_200[1]),STOXX_testing_200)
  482. t_MAE_STOXX_300 = MAE(unlist(STOXX_VSTOXX_Simulation_t_300[1]),STOXX_testing_300)
  483.  
  484. t_MAE_VSTOXX_50 = MAE(unlist(STOXX_VSTOXX_Simulation_t_50[2]),VSTOXX_testing_50)
  485. t_MAE_VSTOXX_100 = MAE(unlist(STOXX_VSTOXX_Simulation_t_100[2]),VSTOXX_testing_100)
  486. t_MAE_VSTOXX_200 = MAE(unlist(STOXX_VSTOXX_Simulation_t_200[2]),VSTOXX_testing_200)
  487. t_MAE_VSTOXX_300 = MAE(unlist(STOXX_VSTOXX_Simulation_t_300[2]),VSTOXX_testing_300)
  488.  
  489. t_RMSE_STOXX_50 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_50[1]),STOXX_testing_50)
  490. t_RMSE_STOXX_100 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_100[1]),STOXX_testing_100)
  491. t_RMSE_STOXX_200 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_200[1]),STOXX_testing_200)
  492. t_RMSE_STOXX_300 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_300[1]),STOXX_testing_300)
  493.  
  494. t_RMSE_VSTOXX_50 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_50[2]),VSTOXX_testing_50)
  495. t_RMSE_VSTOXX_100 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_100[2]),VSTOXX_testing_100)
  496. t_RMSE_VSTOXX_200 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_200[2]),VSTOXX_testing_200)
  497. t_RMSE_VSTOXX_300 = RMSE(unlist(STOXX_VSTOXX_Simulation_t_300[2]),VSTOXX_testing_300)
  498.  
  499. Frank_MAE_STOXX_50 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_50[1]),STOXX_testing_50)
  500. Frank_MAE_STOXX_100 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_100[1]),STOXX_testing_100)
  501. Frank_MAE_STOXX_200 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_200[1]),STOXX_testing_200)
  502. Frank_MAE_STOXX_300 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_300[1]),STOXX_testing_300)
  503.  
  504. Frank_MAE_VSTOXX_50 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_50[2]),VSTOXX_testing_50)
  505. Frank_MAE_VSTOXX_100 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_100[2]),VSTOXX_testing_100)
  506. Frank_MAE_VSTOXX_200 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_200[2]),VSTOXX_testing_200)
  507. Frank_MAE_VSTOXX_300 = MAE(unlist(STOXX_VSTOXX_Simulation_Frank_300[2]),VSTOXX_testing_300)
  508.  
  509. Frank_RMSE_STOXX_50 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_50[1]),STOXX_testing_50)
  510. Frank_RMSE_STOXX_100 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_100[1]),STOXX_testing_100)
  511. Frank_RMSE_STOXX_200 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_200[1]),STOXX_testing_200)
  512. Frank_RMSE_STOXX_300 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_300[1]),STOXX_testing_300)
  513.  
  514. Frank_RMSE_VSTOXX_50 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_50[2]),VSTOXX_testing_50)
  515. Frank_RMSE_VSTOXX_100 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_100[2]),VSTOXX_testing_100)
  516. Frank_RMSE_VSTOXX_200 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_200[2]),VSTOXX_testing_200)
  517. Frank_RMSE_VSTOXX_300 = RMSE(unlist(STOXX_VSTOXX_Simulation_Frank_300[2]),VSTOXX_testing_300)
  518.  
Add Comment
Please, Sign In to add comment