Project

Author

Shannon

Importing Data

library(tidyverse)
── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
✔ dplyr     1.1.3     ✔ readr     2.1.4
✔ forcats   1.0.0     ✔ stringr   1.5.0
✔ ggplot2   3.4.3     ✔ tibble    3.2.1
✔ lubridate 1.9.3     ✔ tidyr     1.3.0
✔ purrr     1.0.2     
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(mfGARCH)

Take note:

This is for Bitcoin results ONLY.

Paper in-sample estimation results:

mu = 0.0973 (0.0022)

alpha = 0.2611 (0.0377)

beta = 0.6769 (0.0423)

theta = 0.1396 (0.0105)

Guessing Date - By Log_Returns

1. Aug-2013 till July-2022 (Reason: 9 years)

df <- read.csv('/Users/shannon423/Documents/QF 604 Econometric/Project/df_august.csv')
#df$date <- as.Date(strptime(df$date, format="%d-%m-%Y"))#, format="%Y-%m-%d")
df$date <- as.Date(df$date, format = "%Y-%m-%d")
df$month <- as.Date(df$month, format = "%Y-%m-%d")
tail(df)
           date    Price Log_Returns    Returns2      month cpu_index
3282 2022-07-26 21330.30  -5.8428383 34.13875929 2022-07-01  336.7758
3283 2022-07-27 21235.61  -0.4448785  0.19791690 2022-07-01  336.7758
3284 2022-07-28 22908.88   7.5845196 57.52493713 2022-07-01  336.7758
3285 2022-07-29 23822.07   3.9087567 15.27837877 2022-07-01  336.7758
3286 2022-07-30 23847.58   0.1070523  0.01146019 2022-07-01  336.7758
3287 2022-07-31 23653.46  -0.8173498  0.66806077 2022-07-01  336.7758
fit_mfgarch(data = df, y = "Log_Returns", x = "cpu_index", low.freq = "month", K = 6, weighting = "beta.restricted")
[1] "For ensuring numerical stability of the parameter optimization and inversion of the Hessian, it is best to multiply log returns by 100."
[1] "No frequency specified for calculating the variance ratio - default: low.freq = month"
       term   estimate rob.std.err      p.value opg.std.err  opg.p.value
mu       mu 0.11148790 0.053475373 3.708330e-02 0.149570415 4.560376e-01
alpha alpha 0.09386269 0.026229330 3.455201e-04 0.015894292 3.517202e-09
beta   beta 0.83786880 0.045780219 0.000000e+00 0.018008125 0.000000e+00
gamma gamma 0.04762000 0.050651593 3.471416e-01 0.019668167 1.547059e-02
m         m 2.10076569 0.395947806 1.122641e-07 0.220442242 0.000000e+00
theta theta 0.00482748 0.001714988 4.879595e-03 0.001096446 1.068423e-05
w2       w2 1.00000774 2.327727325 6.674816e-01 0.710438121 1.592516e-01

2. Aug-2013 till Jan-2022 (Reason: 8.5 years)

df1 <- read.csv('/Users/shannon423/Documents/QF 604 Econometric/Project/df_Jan.csv')
df1$date <- as.Date(df1$date, format = "%Y-%m-%d")
df1$month <- as.Date(df1$month, format = "%Y-%m-%d")
tail(df1)
           date    Price Log_Returns     Returns2      month cpu_index
3101 2022-01-26 36988.93   0.5827370 3.395825e-05 2022-01-01  209.0009
3102 2022-01-27 36870.44  -0.3208488 1.029439e-05 2022-01-01  209.0009
3103 2022-01-28 37276.84   1.0962060 1.201668e-04 2022-01-01  209.0009
3104 2022-01-29 37852.58   1.5326905 2.349140e-04 2022-01-01  209.0009
3105 2022-01-30 38232.18   0.9978421 9.956888e-05 2022-01-01  209.0009
3106 2022-01-31 37983.15  -0.6534856 4.270435e-05 2022-01-01  209.0009
fit_mfgarch(data = df1, y = "Log_Returns", x = "cpu_index", low.freq = "month", K = 6, weighting = "beta.restricted")
[1] "For ensuring numerical stability of the parameter optimization and inversion of the Hessian, it is best to multiply log returns by 100."
[1] "No frequency specified for calculating the variance ratio - default: low.freq = month"
       term    estimate rob.std.err      p.value opg.std.err  opg.p.value
mu       mu 0.123935290 0.054720462 2.352003e-02 0.155679637 4.259787e-01
alpha alpha 0.087778643 0.024934472 4.309403e-04 0.015048529 5.442717e-09
beta   beta 0.850126068 0.045101950 0.000000e+00 0.016913866 0.000000e+00
gamma gamma 0.043891173 0.049397993 3.742604e-01 0.019048692 2.121385e-02
m         m 2.028480521 0.426158203 1.936662e-06 0.233549962 0.000000e+00
theta theta 0.005355593 0.001881043 4.411388e-03 0.001201846 8.344910e-06
w2       w2 1.000001716 1.930346993 6.044286e-01 0.676354622 1.392695e-01

3. Aug-2013 till July-2021 (Reason: 8 years)

df2 <- read.csv('/Users/shannon423/Documents/QF 604 Econometric/Project/df_august1.csv')
df2$date <- as.Date(df2$date, format = "%Y-%m-%d")
df2$month <- as.Date(df2$month, format = "%Y-%m-%d")
tail(df2)
           date    Price Log_Returns     Returns2      month cpu_index
2917 2021-07-26 35456.12   3.5672783 1.272547e-03 2021-07-01  244.3479
2918 2021-07-27 37281.92   5.0212432 2.521288e-03 2021-07-01  244.3479
2919 2021-07-28 39076.59   4.7015223 2.210431e-03 2021-07-01  244.3479
2920 2021-07-29 40031.20   2.4135443 5.825196e-04 2021-07-01  244.3479
2921 2021-07-30 39977.76  -0.1335883 1.784584e-06 2021-07-01  244.3479
2922 2021-07-31 41936.26   4.7827659 2.287485e-03 2021-07-01  244.3479
fit_mfgarch(data = df2, y = "Log_Returns", x = "cpu_index", low.freq = "month", K = 6, weighting = "beta.restricted")
[1] "For ensuring numerical stability of the parameter optimization and inversion of the Hessian, it is best to multiply log returns by 100."
[1] "No frequency specified for calculating the variance ratio - default: low.freq = month"
       term    estimate rob.std.err      p.value opg.std.err  opg.p.value
mu       mu 0.138247765 0.055878696 1.335838e-02 0.162213434 3.940707e-01
alpha alpha 0.104935597 0.029035284 3.014257e-04 0.018183388 7.882143e-09
beta   beta 0.830423866 0.047282421 0.000000e+00 0.018927380 0.000000e+00
gamma gamma 0.048922238 0.054175928 3.665124e-01 0.022757093 3.157438e-02
m         m 2.006186131 0.484835267 3.505423e-05 0.257879442 7.327472e-15
theta theta 0.006258012 0.002344988 7.615095e-03 0.001250802 5.638647e-07
w2       w2 1.000005453 2.387695514 6.753505e-01 0.617260319 1.052171e-01

4. Aug-2013 - Oct-2022 (Reason: 6 months before Apr-2023)

df3 <- read.csv('/Users/shannon423/Documents/QF 604 Econometric/Project/df_oct.csv')
df3$date <- as.Date(df3$date, format = "%Y-%m-%d")
df3$month <- as.Date(df3$month, format = "%Y-%m-%d")
tail(df3)
           date    Price Log_Returns     Returns2      month cpu_index
3374 2022-10-26 20765.97   3.3309063 1.109494e-03 2022-10-01  204.4393
3375 2022-10-27 20291.38  -2.3119486 5.345106e-04 2022-10-01  204.4393
3376 2022-10-28 20598.34   1.5014526 2.254360e-04 2022-10-01  204.4393
3377 2022-10-29 20829.55   1.1162080 1.245920e-04 2022-10-01  204.4393
3378 2022-10-30 20640.64  -0.9110957 8.300954e-05 2022-10-01  204.4393
3379 2022-10-31 20594.74  -0.2225970 4.954944e-06 2022-10-01  204.4393
fit_mfgarch(data = df3, y = "Log_Returns", x = "cpu_index", low.freq = "month", K = 6, weighting = "beta.restricted")
[1] "For ensuring numerical stability of the parameter optimization and inversion of the Hessian, it is best to multiply log returns by 100."
[1] "No frequency specified for calculating the variance ratio - default: low.freq = month"
       term   estimate rob.std.err      p.value opg.std.err  opg.p.value
mu       mu 0.10837173 0.052366020 3.849874e-02 0.147420144 4.622654e-01
alpha alpha 0.08866399 0.024351375 2.715536e-04 0.014914105 2.764977e-09
beta   beta 0.84638906 0.043609188 0.000000e+00 0.016942866 0.000000e+00
gamma gamma 0.04580072 0.047974827 3.397383e-01 0.018227576 1.198058e-02
m         m 2.15198513 0.368871148 5.412217e-09 0.218791433 0.000000e+00
theta theta 0.00425343 0.001593745 7.611662e-03 0.001086521 9.050734e-05
w2       w2 1.00000193 1.822276335 5.831666e-01 0.801458765 2.121310e-01

5. Aug-2013 - Apr-2022 (Reason: 1 year before Apr-2023)

df4 <- read.csv('/Users/shannon423/Documents/QF 604 Econometric/Project/df_apr.csv')
df4$date <- as.Date(df4$date, format = "%Y-%m-%d")
df4$month <- as.Date(df4$month, format = "%Y-%m-%d")
tail(df4)
           date    Price Log_Returns     Returns2      month cpu_index
3190 2022-04-25 39469.05  -0.2346689 5.506947e-06 2022-04-01  225.9683
3191 2022-04-26 40488.88   2.5510500 6.507856e-04 2022-04-01  225.9683
3192 2022-04-27 38134.22  -5.9915395 3.589855e-03 2022-04-01  225.9683
3193 2022-04-28 39237.95   2.8532451 8.141008e-04 2022-04-01  225.9683
3194 2022-04-29 39741.77   1.2758318 1.627747e-04 2022-04-01  225.9683
3195 2022-04-30 38650.55  -2.7841682 7.751593e-04 2022-04-01  225.9683
fit_mfgarch(data = df4, y = "Log_Returns", x = "cpu_index", low.freq = "month", K = 6, weighting = "beta.restricted")
[1] "For ensuring numerical stability of the parameter optimization and inversion of the Hessian, it is best to multiply log returns by 100."
[1] "No frequency specified for calculating the variance ratio - default: low.freq = month"
       term    estimate rob.std.err      p.value opg.std.err  opg.p.value
mu       mu 0.115792806 0.054272787 3.288099e-02 0.153521349 4.507017e-01
alpha alpha 0.076040159 0.022154681 5.986200e-04 0.012829730 3.087603e-09
beta   beta 0.867971347 0.041451073 0.000000e+00 0.014511885 0.000000e+00
gamma gamma 0.039824488 0.044692658 3.728892e-01 0.016326335 1.471660e-02
m         m 1.997782877 0.400222853 5.985755e-07 0.228950810 0.000000e+00
theta theta 0.005172982 0.001780179 3.662256e-03 0.001210888 1.936774e-05
w2       w2 1.000017677 2.054372538 6.264176e-01 0.668171286 1.344847e-01