Professional Documents
Culture Documents
END TERM
1|Page
GBP-INR Return Series
2. Compute the sample mean, variance, skewness, excess kurtosis, and minimum and
maximum of the four log return series.
Sample Excess Minimum Maximum
Currency Variance Skewness
Mean Kurtosis return Return
USD 0 .0001 -0.01 21.59 -0.06 0.06
JPY 0 .0001 0.05 49.82 -0.17 0.16
EUR 0 .0001 0.07 66.14 -0.15 0.16
GBP 0 .0001 -0.44 8.64 -0.07 0.06
The mean returns of all the currencies are 0. As we can see from the table maximum skewness
is seen in the returns from GBP. The most leptokurtic curve is that of Euro while JPY had given
the maximum negative return of 17%.
To check for the stationarity of the log returns we use the Augmented Dickey Fuller test and
check the p-values. The null hypothesis for the test is non-stationarity and as the p-values for all
the currencies are 0.01 which is less than 0.05, we conclude that all the log returns are non-
stationary.
Jarque-Bera Test is used to check for the normality of a time series data. The null hypothesis for
the test is that the series is normal. Looking at the p-values from the test conducted on the data
2|Page
we see that all of them are less than 0.05 and hence can conclude that the distribution is not
normal for all the four currencies.
p-value (Jarque-Bera
Exchange Currency X squared df
Test)
INR-USD < 2.2e-16 68411 2
INR-JPY < 2.2e-16 364180 2
INR-EUR < 2.2e-16 641690 2
INR-GBP < 2.2e-16 11060 2
5. Build an AR model for each series and check the fitted model.
As per the Auto-Regressive or AR model, the log return value should depend linearly on its own
previous values. We try to fit in the data on an AR model and check for the AIC value to see which
order gives the best result. For the USD the order comes out to be 8 while that for GBP it is only
1.
USD-INR
ar(x = INRUSD_return, aic = TRUE, order.max = NULL)
Coefficients:
1 2 3 4 5 6 7 8
-0.1522 0.0298 -0.0061 0.0238 0.0571 -0.0240 -0.0012 0.0398
JPY-INR
ar(x = INRJPY_return, aic = TRUE, order.max = NULL)
Coefficients:
1 2
-0.1967 -0.0501
EURO-INR
ar(x = INREURO_return, aic = TRUE, order.max = NULL)
Coefficients:
1 2
-0.2984 -0.0787
3|Page
GBP-INR
ar(x = INRGBP_return, aic = TRUE, order.max = NULL)
Coefficients:
1
-0.122
To Check the fitted model we evaluate the model on 4 parameters i.e. mean of residuals is
zero, they are stationary and they do not have autocorrelation
USD: Dickey-Fuller = -13.527, Lag order = 15, p-value = 0.01 : Series is Stationary
JPY: Dickey-Fuller = -14.367, Lag order = 15, p-value = 0.01 : Series is Stationary
EUR: Dickey-Fuller = -14.987, Lag order = 15, p-value = 0.01 : Series is Stationary
GBP: Dickey-Fuller = -14.622, Lag order = 15, p-value = 0.01 : Series is Stationary
USD-INR
Autocorrelations of series ‘(fit_arUSD$resid)’, by lag
0 1 2 3 4 5 6 7 8 9 10
1.000 0.000 -0.001 -0.004 0.025 0.053 -0.031 0.005 0.037 0.000 0.031
JPY-INR
EURO-INR
GBP-INR
4|Page
We see that in all the above the ACF value for the series is much below 0.05, hence the
residual series does not have auto-correlation. Also, the p-value for Box-Ljung statistics is 1
for all lags up to 10.
6. Build an MA model for each series and check the fitted model.
Simple Moving average function was used to fit the MA model to the return series using the
AIC criterion as the selection criterion. The Model for different series is as described below:
USD-INR
JPY-INR
Information criteria:
AIC AICc BIC
-22561.53 -22561.53 -22549.20
EURO-INR
Information criteria:
AIC AICc BIC
-23170.96 -23170.95 -23158.63
5|Page
GBP-INR
Model estimated: SMA(198)
Initial values were produced using backcasting.
2 parameters were estimated in the process
Residuals standard deviation: 0.007
Cost function type: MSE; Cost function value: 0
Information criteria:
AIC AICc BIC
-24647.97 -24647.96 -24635.64
To Check the fitted model, we evaluate the model on 4 parameters i.e. mean of residuals is
zero, they are stationary, and they do not have autocorrelation.
USD: Dickey-Fuller = -13.675, Lag order = 15, p-value = 0.01 : Series is Stationary
JPY: Dickey-Fuller = -14.495, Lag order = 15, p-value = 0.01 : Series is Stationary
EUR: Dickey-Fuller = -15.495, Lag order = 15, p-value = 0.01 : Series is Stationary
GBP: Dickey-Fuller = -14.689, Lag order = 15, p-value = 0.01 : Series is Stationary
USD-INR
Autocorrelations of series ‘(fit_maUSD$residuals)’, by lag
0 1 2 3 4 5 6 7 8 9 10
1.000 -0.159 0.052 -0.019 0.018 0.051 -0.038 0.005 0.035 -0.011 0.030
JPY-INR
EURO-INR
6|Page
GBP-INR
Autocorrelations of series ‘(fit_maGBP$residuals)’, by lag
0 1 2 3 4 5 6 7 8 9 10
1.000 -0.122 0.024 -0.011 0.012 0.009 0.007 -0.002 0.033 -0.013 -0.012
For all the series, we see that there is a strong auto-correlation at lag 1 onwards only. Also,
the Box-Ljung for lags up to 10 is less than 0.05 for each lag. Hence the residuals from the
fitted MA model for all series have significant auto-correlation.
7. Build an ARMA model for each series and check the fitted model.
The ARMA model was fitted to different series using AIC as the selection criterion and the
different model fitted are shown below:
Exchange
AIC Value AR Order MA Order
Currency
INR-USD -27096.10 2 0
INR-JPY -22712.56 0 1
INR-EUR -23488.71 0 1
INR-GBP -24719.22 1 0
USD-INR
Coefficients:
ar1 ar2
-0.1524 0.0294
s.e. 0.0169 0.0169
JPY-INR
Coefficients:
ma1
-0.2001
s.e. 0.0168
7|Page
EURO-INR
ARIMA(0,0,1) with zero mean
Coefficients:
ma1
-0.2974
s.e. 0.0159
GBP-INR
ARIMA(1,0,0) with zero mean
Coefficients:
ar1
-0.1221
s.e. 0.0168
To Check the fitted model, we evaluate the model on 4 parameters i.e. mean of residuals is
zero, they are stationary, and they do not have autocorrelation.
USD: Dickey-Fuller = -13.533, Lag order = 15, p-value = 0.01 : Series is Stationary
JPY: Dickey-Fuller = -14.356, Lag order = 15, p-value = 0.01 : Series is Stationary
EUR: Dickey-Fuller = -14.881, Lag order = 15, p-value = 0.01 : Series is Stationary
GBP: Dickey-Fuller = -14.611, Lag order = 15, p-value = 0.01 : Series is Stationary
USD-INR
8|Page
JPY-INR
Autocorrelations of series ‘(fit_armaJPY$residuals)’, by lag
0 1 2 3 4 5 6 7 8 9 10
1.000 0.003 -0.014 -0.005 0.015 -0.014 -0.012 -0.015 0.041 0.003 0.036
EURO-INR
Autocorrelations of series ‘(fit_armaEURO$residuals)’, by lag
0 1 2 3 4 5 6 7 8 9 10
1.000 -0.003 0.005 0.006 0.013 0.004 -0.002 0.027 0.031 -0.027 0.000
GBP-INR
From the ACF values, we observe that there is no significant auto correlation up to a lag of
10. Also, Box-Ljung test shows favorable results as the p-value for USD is above 0.05 up to
lag 5, for JPY up to lag 8 and up to lag 10 for EURO and GBP.
8. Use the fitted models to compute 1-day ahead and 7-day ahead forecasts starting from 1
July 2017.
The 1-Day and 7-Day forecasted values for the ARMA models are shown below:
USD-INR
Day Point Forecast Low 80 High 80 Low 95 High 95
1 -6.500054e-04 -0.007230801 0.005930790 -0.010714463 0.009414453
2 2.231415e-04 -0.006433661 0.006879944 -0.009957559 0.010403842
3 -5.309487e-05 -0.006718888 0.006612698 -0.010247545 0.010141355
4 1.464389e-05 -0.006651656 0.006680943 -0.010180582 0.010209869
5 -3.790832e-06 -0.006670129 0.006662547 -0.010199075 0.010191494
6 1.007727e-06 -0.006665333 0.006667348 -0.010194281 0.010196296
7 -2.648925e-07 -0.006666606 0.006666076 -0.010195554 0.010195024
JPY-INR
9|Page
EURO-INR
GBP-INR
9. Is there evidence of ARCH effects in the log return series? Use Box-Ljung and other
tests to answer the question.
The autoregressive conditional heteroskedasticity (ARCH) model is a statistical model for
time series data that describes the variance of the current error term or innovation as a
function of the actual sizes of the previous time periods' error terms; often the variance is
related to the squares of the previous innovations.
Evaluating the serial correlation in the log return series and squared log return series of all
currencies using Box-Ljung test, the results are described below:
USD-INR
Box-Ljung test
data: INRUSD_return
X-squared = 122.31, df = 10, p-value < 2.2e-16
Box-Ljung test
data: INRUSD_return^2
X-squared = 2012.1, df = 10, p-value < 2.2e-16
We observe that the p-value for both the series is less than 0.05 and hence there is serial
correlation present in the series showing evidence of ARCH effect.
10 | P a g e
JPY-INR
Box-Ljung test
data: INRJPY_return
X-squared = 139.98, df = 10, p-value < 2.2e-16
Box-Ljung test
data: INRJPY_return^2
X-squared = 813.03, df = 10, p-value < 2.2e-16
We observe that the p-value for both the series is less than 0.05 and hence there is serial
correlation present in the series showing evidence of ARCH effect.
EURO-JPY
Box-Ljung test
data: INREURO_return
X-squared = 279.26, df = 10, p-value < 2.2e-16
Box-Ljung test
data: INREURO_return^2
X-squared = 876.79, df = 10, p-value < 2.2e-16
We observe that the p-value for both the series is less than 0.05 and hence there is serial
correlation present in the series showing evidence of ARCH effect.
GBP-INR
Box-Ljung test
data: INRGBP_return
X-squared = 60.682, df = 10, p-value = 2.692e-09
Box-Ljung test
data: INRGBP_return^2
X-squared = 748.77, df = 10, p-value < 2.2e-16
We observe that the p-value for both the series is less than 0.05 and hence there is serial
correlation present in the series showing evidence of ARCH effect.
10. Use the ACF/PACF of the squared log returns to identify an ARCH model for each
series. What are the fitted models?
The ACF/PACF plots for different return series are as shown below:
11 | P a g e
USD-INR
Log-Return of USD-INR
12 | P a g e
From the above ACF/PACF plots, we observe that the partial auto-correlation is strong up till
lag of 9. This is evidenced by the model constructed by observing the AIC values of different
models.
GARCH(0,9)
Residuals:
Min 1Q Median 3Q Max
-8.606903 -0.514286 -0.004931 0.541921 7.385154
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 4.456e-06 2.395e-07 18.603 < 2e-16 ***
a1 2.208e-01 1.602e-02 13.781 < 2e-16 ***
a2 1.067e-01 1.618e-02 6.596 4.24e-11 ***
a3 3.260e-02 1.312e-02 2.486 0.012932 *
a4 1.183e-01 1.402e-02 8.433 < 2e-16 ***
a5 1.214e-01 1.395e-02 8.698 < 2e-16 ***
a6 7.316e-02 1.490e-02 4.909 9.17e-07 ***
a7 1.478e-01 8.711e-03 16.971 < 2e-16 ***
a8 5.434e-02 1.334e-02 4.074 4.61e-05 ***
a9 4.868e-02 1.415e-02 3.440 0.000581 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 2489.5, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 0.00045927, df = 1, p-value = 0.9829
JPY-INR
Log-Return of JPY-INR
13 | P a g e
Squared Log-Return of JPY-INR
From the above ACF/PACF plots, we observe that the partial auto-correlation is strong up till
lag of 7. This is evidenced by the model constructed by observing the AIC values of different
models.
Model:
ARCH(7)
Residuals:
Min 1Q Median 3Q Max
-9.4302 -0.5862 -0.0161 0.5605 6.4720
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 2.147e-05 1.326e-06 16.197 < 2e-16 ***
a1 1.732e-01 1.538e-02 11.256 < 2e-16 ***
a2 8.366e-02 1.216e-02 6.878 6.07e-12 ***
a3 6.080e-02 1.376e-02 4.419 9.90e-06 ***
a4 1.164e-01 1.033e-02 11.267 < 2e-16 ***
a5 2.127e-01 6.321e-03 33.646 < 2e-16 ***
a6 1.092e-01 1.485e-02 7.351 1.97e-13 ***
14 | P a g e
a7 7.973e-02 1.354e-02 5.890 3.87e-09 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 3128.4, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 0.45658, df = 1, p-value = 0.4992
EURO-INR
Log-Return of EURO-INR
15 | P a g e
Model Log Likelihood AIC
Arch(1) 11988.62 -23973.24
Arch(2) 11980.97 -23955.94
Arch(3) 11972.64 -23937.28
Arch(4) 12033.44 -24056.87
Arch(5) 12026.84 -24041.68
Arch(6) 12034.92 -24055.84
Arch(7) 12075.89 -24135.79
Arch(8) 12092.94 -24167.88
Arch(9) 12140.31 -24260.63
Arch(10) 12210.92 -24399.84
From the above ACF/PACF plots, we observe that the partial auto-correlation is strong up till
lag of 9. This is evidenced by the model constructed by observing the AIC values of different
models. Although, from the AIC values ARCH(3) can also be considered as a fit but the PACF
plot favors ARCH(9).
Model:
ARCH(9)
Residuals:
Min 1Q Median 3Q Max
-4.27824 -0.54298 0.01051 0.56343 16.96629
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 2.611e-05 1.302e-06 20.051 <2e-16 ***
a1 1.359e-01 1.123e-02 12.104 <2e-16 ***
a2 2.840e-14 1.101e-02 0.000 1.0000
a3 9.012e-04 8.921e-03 0.101 0.9195
a4 1.124e-01 1.264e-02 8.888 <2e-16 ***
a5 3.781e-02 1.530e-02 2.471 0.0135 *
a6 2.691e-02 1.219e-02 2.208 0.0272 *
a7 1.413e-01 1.981e-02 7.130 1e-12 ***
a8 3.956e-02 1.346e-02 2.939 0.0033 **
a9 1.567e-01 1.436e-02 10.914 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 102800, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 0.60204, df = 1, p-value = 0.4378
16 | P a g e
GBP-INR
Log-Return of GBP-INR
17 | P a g e
From the above ACF/PACF plots, we observe that the partial auto-correlation is strong up till
lag of 3. This is evidenced by the model constructed by observing the AIC values of different
models. Although, from the AIC values ARCH(7) can also be considered as a fit but the PACF
plot favors ARCH(3).
Residuals:
Min 1Q Median 3Q Max
-8.02607 -0.57430 0.00983 0.59645 8.02792
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 3.231e-05 7.029e-07 45.958 < 2e-16 ***
a1 1.907e-01 1.130e-02 16.870 < 2e-16 ***
a2 1.324e-01 1.400e-02 9.461 < 2e-16 ***
a3 3.965e-02 1.261e-02 3.145 0.00166 **
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 2632.1, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 0.42628, df = 1, p-value = 0.5138
11. Build a GARCH model with Gaussian innovations for the log returns of each series.
The GARCH model for different series is constructed based on AIC values as selection
criterion.
USD-INR
Model:
GARCH(1,2)
Residuals:
Min 1Q Median 3Q Max
-6.6401 -0.5174 0.0000 0.5509 8.3773
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 4.337e-07 4.474e-08 9.692 <2e-16 ***
a1 1.499e-01 1.522e-02 9.851 <2e-16 ***
18 | P a g e
a2 1.451e-09 1.739e-02 0.000 1
b1 8.473e-01 1.029e-02 82.351 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 2250.2, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 3.8414, df = 1, p-value = 0.05
JPY-INR
Model:
GARCH(1,1)
Residuals:
Min 1Q Median 3Q Max
-8.81404 -0.56479 -0.03105 0.56845 7.53766
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 9.196e-07 1.006e-07 9.145 <2e-16 ***
a1 8.112e-02 5.049e-03 16.066 <2e-16 ***
b1 9.123e-01 3.841e-03 237.544 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 3011.2, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 21.599, df = 1, p-value = 3.361e-06
EURO-INR
19 | P a g e
Model:
GARCH(1,1)
Residuals:
Min 1Q Median 3Q Max
-4.7120041 -0.5086367 -0.0009633 0.5333912 20.7455549
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 4.997e-05 1.245e-06 40.123 <2e-16 ***
a1 3.098e-01 1.442e-02 21.484 <2e-16 ***
b1 3.599e-03 2.435e-02 0.148 0.882
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 541230, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 0.15027, df = 1, p-value = 0.6983
GBP-INR
Model:
GARCH(1,2)
Residuals:
Min 1Q Median 3Q Max
-7.96605 -0.58223 0.01702 0.59746 8.06997
Coefficient(s):
Estimate Std. Error t value Pr(>|t|)
a0 2.957e-06 4.792e-07 6.17 6.82e-10 ***
a1 1.353e-01 1.164e-02 11.62 < 2e-16 ***
a2 9.825e-09 1.953e-02 0.00 1
b1 8.149e-01 1.940e-02 42.01 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Diagnostic Tests:
Jarque Bera Test
data: Residuals
X-squared = 1815, df = 2, p-value < 2.2e-16
Box-Ljung test
data: Squared.Residuals
X-squared = 1.7132, df = 1, p-value = 0.1906
20 | P a g e
12. Compare the fitted ARCH and GARCH models. Is there any significant difference?
USD-INR
ARCH Residuals
GARCH Residuals
As we observe that the auto-correlation in the residual series is more or less the same from
both the models and there is no significant difference in the two models.
21 | P a g e
JPY-INR
ARCH Residuals
GARCH Residuals
As we observe that the auto-correlation in the residual series is more or less the same from
both the models and there is no significant difference in the two models.
22 | P a g e
EURO-INR
ARCH Residuals
GARCH Residuals
As we observe that the auto-correlation in the residual series is more or less the same from
both the models and there is no significant difference in the two models.
23 | P a g e
GBP-INR
ARCH Residuals
GARCH Residuals
As we observe that the auto-correlation in the residual series is different for both the
models and hence there is significant difference in the two models.
24 | P a g e
13. Check the estimated error series for first and second order dependence
(autocorrelation).
The estimated error series from ARMA- GARCH model is tested for first and second order
auto-correlation using box-Ljung test. The results are as described below:
USD-INR
First Order:
Box-Ljung test
data: error_hatreturnUSD
X-squared = 46.797, df = 10, p-value = 0.1625 : No Auto-Correlation
Second Order:
Box-Ljung test
data: error_hatreturnUSD^2
X-squared = 21.11, df = 10, p-value = 0.6258 : No Auto-Correlation
JPY-INR
First Order:
Box-Ljung test
data: error_hatreturnJPY
X-squared = 68.331, df = 10, p-value = 0.1568 : No Auto-Correlation
Second Order:
Box-Ljung test
data: error_hatreturnJPY^2
X-squared = 12.621, df = 10, p-value = 0.2963 : No Auto-Correlation
EURO-INR
First Order:
Box-Ljung test
data: error_hatreturnEURO
X-squared = 181.66, df = 10, p-value = 0.7895 : No Auto-Correlation
Second Order:
Box-Ljung test
data: error_hatreturnEURO^2
X-squared = 544.12, df = 10, p-value = 0.6995 : No Auto-Correlation
GBP-INR
First Order:
Box-Ljung test
data: error_hatreturnGBP
X-squared = 9.6046, df = 10, p-value = 0.4758 : No Auto-Correlation
25 | P a g e
Second Order:
Box-Ljung test
data: error_hatreturnGBP^2
X-squared = 52.002, df = 10, p-value = 0.3542 : No Auto-Correlation
14. Compute the descriptive statistics for the standardized estimated error. Comment
on the distribution of error.
The descriptive statistics of the standardized error series are:
USD-INR
JPY-INR
EURO-INR
GBP-INR
We observe that there is skewness in the distribution and all have Kurtosis > 3, implying they
are leptokurtic.
15. Is the error distribution normal? If not, fit a Pearson Type IV and also a Johnson SU
distribution to the errors, separately and test their goodness of fit.
To evaluate if the distribution is nor, we use the Jarque-Bera test. The null hypothesis for the
test states that the distribution of the series is normal.
USD-INR
26 | P a g e
JPY-INR
Jarque Bera Test
data: (error_hatreturnJPY)
X-squared = 3083.2, df = 2, p-value < 2.2e-16
EURO-INR
Jarque Bera Test
data: (error_hatreturnEURO)
X-squared = 505860, df = 2, p-value < 2.2e-16
GBP-INR
As the p-value for the Jarque-Bera test on all the exchange rates is less than 0.05, we reject
the null hypothesis. This means that none of the distributions is normal.
JPY-INR
USD-INR
$type
$type
[1] 4
[1] 4
$m
$m
[1] 3.198877
[1] 2.595808
$nu
$nu
[1] -0.4569915
[1] -0.2577018
$location
$location
[1] -0.1814577
[1] -0.09913087
$scale
$scale
[1] 1.827377
[1] 1.531185
EURO-INR GBP-INR
$type $type
[1] 4 [1] 4
$m $m
[1] 3.050786 [1] 4.266978
$nu $nu
[1] -0.2117569 [1] 0.2092388
$location $location
[1] -0.06539945 [1] 0.08288153
$scale $scale
[1] 1.626412 [1] 2.307303
27 | P a g e
Fitting Johnson Su Distribution
USD-INR JPY-INR
$gamma $gamma
[1] -0.1331926 [1] -0.2659394
$delta $delta
[1] 1.436355 [1] 1.8336
$xi $xi
[1] -0.1025944 [1] -0.2370942
$lambda $lambda
[1] 1.133384 [1] 1.498772
$type $type
[1] "SU" [1] "SU"
EURO-INR GBP-INR
$gamma $gamma
[1] -0.006814973 [1] 0.03477674
$delta $delta
[1] 1.668804 [1] 2.613961
$xi $xi
[1] 0.01095228 [1] 0.04112658
$lambda $lambda
[1] 1.239918 [1] 2.323304
$type $type
[1] "SU" [1] "SU"
16. Find the 95%, 97.5%, 99% and 99.9% VaRs for
each exchange rate for a period of six months in the collected data series and
comment.
The VaR values for the series based on Pearson and Johnson SU Distributions are:
USD-INR
JPY-INR
28 | P a g e
EURO-INR
GBP-INR
17. Compute the cross-correlation matrix of the returns of the four exchange rates.
29 | P a g e
Cross Correlation plot for USD-EURO
30 | P a g e
Cross Correlation plot for JPY-GBP
18. Construct a suitable portfolio with these exchange rates and compute the VaRs as
mentioned in question 16.
The Variance-Covariance matrix for the four exchange rates is shown below:
31 | P a g e
The decomposed Cholesky matrix is sown below:
Taking a portfolio of equal weights (25%) for all exchange rates the VaR quantiles for the
portfolio returns are as follows:
% VaR Error
95% -0.0000951931
97.5% -0.0001214662
99% -0.0001582043
99.9% -0.0002654963
19. Compute the VaRs as mentioned in question 16 for at least two exchange rates
using Extreme Value Theory using the peak over threshold method.
The VaR using EVT is calculated in R with point of threshold kept as the 1% quantile in the
returns for the last 15 years.
32 | P a g e
Appendix (R Code)
INR_USD<-getSymbols("USDINR=X", src="yahoo", from = hist(INREURO_return, breaks = 100)
"2000-01-01", to = "2017-06-30", auto.assign = FALSE) hist(INRGBP_return, breaks = 100)
INR_JPY<-getSymbols("JPYINR=X",src="yahoo", from =
"2000-01-01", to = "2017-06-30", auto.assign = FALSE) #Plot Returns
INR_EURO<-getSymbols("EURINR=X",src="yahoo", from plot(INRUSD_return)
= "2000-01-01", to = "2017-06-30", auto.assign = FALSE) plot(INRJPY_return)
INR_GBP<-getSymbols("GBPINR=X",src="yahoo", from = plot(INREURO_return)
"2000-01-01", to = "2017-06-30", auto.assign = FALSE) plot(INRGBP_return)
33 | P a g e
fit_arEURO mean(na.omit(fit_maGBP$residuals))
#p-values for AR #stationarity
(1- adf.test((na.omit(fit_maUSD$residuals)))
pnorm(abs(fit_arEURO$ar)/sqrt(diag(fit_arEURO$asy.var adf.test((na.omit(fit_maJPY$residuals)))
.coef))))*2 adf.test((na.omit(fit_maEURO$residuals)))
fit_arGBP<-ar(INRGBP_return, aic = TRUE, order.max = adf.test((na.omit(fit_maGBP$residuals)))
3) #normality
head(fit_arGBP) #autocorrelation
summary(fit_arGBP) chart.ACFplus(na.omit(fit_maUSD$residuals))
fit_arGBP stnrty_maUSD <-
#p-values for AR acf(na.omit(fit_maUSD$residuals),lag.max = 10)
(1- stnrty_maUSD
pnorm(abs(fit_arGBP$ar)/sqrt(diag(fit_arGBP$asy.var.co #Box.Ljung.Test(na.omit(fit_maUSD$residuals))
ef))))*2 #table.Autocorrelation(na.omit(fit_arUSD$resid),digits =
10)
#Checking the fit for the AR model stnrty_maJPY <-
#mean=0 acf(na.omit(fit_maJPY$residuals),lag.max = 10)
mean(na.omit(fit_arUSD$resid)) stnrty_maJPY
mean(na.omit(fit_arJPY$resid)) stnrty_maEURO <-
mean(na.omit(fit_arEURO$resid)) acf(na.omit(fit_maEURO$residuals),lag.max = 10)
mean(na.omit(fit_arGBP$resid)) stnrty_maEURO
#stationarity stnrty_maGBP <-
adf.test((na.omit(fit_arUSD$resid))) acf(na.omit(fit_maGBP$residuals),lag.max = 10)
adf.test((na.omit(fit_arJPY$resid))) stnrty_maGBP
adf.test((na.omit(fit_arEURO$resid)))
adf.test((na.omit(fit_arGBP$resid))) #ARMA Fit
#normality fit_armaUSD<-auto.arima(INRUSD_return,d=0,D=0,
#autocorrelation max.p=5, max.q=5,max.P=2, max.Q=2,
chart.ACFplus(na.omit(fit_arUSD$resid)) max.order=6,stationary=TRUE,ic="aic")
stnrty_USD <- acf(na.omit(fit_arUSD$resid),lag.max = summary(fit_armaUSD)
10) residuals_armaUSD <- fit_armaUSD$residuals
stnrty_USD fit_armaJPY<-auto.arima(INRJPY_return,d=0,D=0,
#Box.Ljung.Test(na.omit(fit_arUSD$resid)) max.p=5, max.q=5,max.P=2, max.Q=2,
#table.Autocorrelation(na.omit(fit_arUSD$resid),digits = max.order=6,stationary=TRUE,ic="aic")
10) summary(fit_armaJPY)
stnrty_JPY <- acf(na.omit(fit_arJPY$resid),lag.max = 10) residuals_armaJPY <- fit_armaJPY$residuals
stnrty_JPY fit_armaEURO<-auto.arima(INREURO_return,d=0,D=0,
stnrty_EURO <- acf(na.omit(fit_arEURO$resid),lag.max = max.p=5, max.q=5,max.P=2, max.Q=2,
10) max.order=6,stationary=TRUE,ic="aic")
stnrty_EURO summary(fit_armaEURO)
stnrty_GBP <- acf(na.omit(fit_arGBP$resid),lag.max = residuals_armaEURO <- fit_armaEURO$residuals
10) fit_armaGBP<-auto.arima(INRGBP_return,d=0,D=0,
stnrty_GBP max.p=5, max.q=5,max.P=2, max.Q=2,
max.order=6,stationary=TRUE,ic="aic")
# MA Model summary(fit_armaGBP)
fit_maUSD<-sma(INRUSD_return,order=NULL) residuals_armaGBP <- fit_armaGBP$residuals
fit_maUSD #Checking the fit for the MA model
summary(fit_maUSD) #mean=0
#p-values for MA mean(na.omit(fit_armaUSD$residuals))
#(1- mean(na.omit(fit_armaJPY$residuals))
pnorm(abs(fit_maUSD$ma)/sqrt(diag(fit_arUSD$asy.var. mean(na.omit(fit_armaEURO$residuals))
coef))))*2 mean(na.omit(fit_armaGBP$residuals))
fit_maJPY<-sma(INRJPY_return,order=NULL) #stationarity
summary(fit_maJPY) adf.test((na.omit(fit_armaUSD$residuals)))
fit_maEURO<-sma(INREURO_return,order=NULL) adf.test((na.omit(fit_armaJPY$residuals)))
summary(fit_maEURO) adf.test((na.omit(fit_armaEURO$residuals)))
fit_maGBP<-sma(INRGBP_return,order=NULL) adf.test((na.omit(fit_armaGBP$residuals)))
summary(fit_maGBP) #normality
#Checking the fit for the MA model #autocorrelation
#mean=0 chart.ACFplus(na.omit(fit_armaUSD$residuals))
mean(na.omit(fit_maUSD$residuals)) stnrty_armaUSD <-
mean(na.omit(fit_maJPY$residuals)) acf(na.omit(fit_armaUSD$residuals),lag.max = 10)
mean(na.omit(fit_maEURO$residuals)) stnrty_armaUSD
34 | P a g e
Box.Ljung.Test(na.omit(fit_armaUSD$residuals)) test_boxljungJPY2<-Box.test(INRJPY_return^2, lag = 10,
#table.Autocorrelation(na.omit(fit_armaUSD$residuals), type = "Ljung" )
digits = 10) test_boxljungJPY2
stnrty_armaJPY <- test_boxljungEURO<-Box.test(INREURO_return, lag = 10,
acf(na.omit(fit_armaJPY$residuals),lag.max = 10) type = "Ljung" )
stnrty_armaJPY test_boxljungEURO
Box.Ljung.Test(na.omit(fit_armaJPY$residuals)) test_boxljungEURO2<-Box.test(INREURO_return^2, lag =
stnrty_armaEURO <- 10, type = "Ljung" )
acf(na.omit(fit_armaEURO$residuals),lag.max = 10) test_boxljungEURO2
stnrty_armaEURO test_boxljungGBP<-Box.test(INRGBP_return, lag = 10,
Box.Ljung.Test(na.omit(fit_armaEURO$residuals)) type = "Ljung" )
stnrty_armaGBP <- test_boxljungGBP
acf(na.omit(fit_armaGBP$residuals),lag.max = 10) test_boxljungGBP2<-Box.test(INRGBP_return^2, lag =
stnrty_armaGBP 10, type = "Ljung" )
Box.Ljung.Test(na.omit(fit_armaGBP$residuals)) test_boxljungGBP2
35 | P a g e
#Fit GARCH with gaussian innovations to returns jarque.bera.test(na.omit(error_hatreturnEURO))
fit_garchUSD <- garch(INRUSD_return, order = c(1,1))
summary(fit_garchUSD) fit_gsigmaGBP<-((fit_garchGBP$fitted.values)[,1])
AIC(fit_garchUSD) residuals_gsigmaGBP <- (fit_garchGBP$residuals)
logLik(fit_garchUSD) fit_ameuGBP<-na.omit(fit_armaGBP$fitted)
#fit = garchAuto(INRUSD_return, cores=8, trace=TRUE) log_returnsGBP <- na.omit(INRGBP_return)
fit_garchJPY <- garch(INRJPY_return, order = c(1,1)) error_hatreturnGBP <- ((log_returnsGBP)-
summary(fit_garchJPY) fit_ameuGBP)/(fit_gsigmaGBP)
AIC(fit_garchJPY) head(error_hatreturnGBP, n=8)
logLik(fit_garchJPY) Box.test(error_hatreturnGBP^2,lag = 10, type = "Ljung")
fit_garchEURO <- garch(INREURO_return, order = c(1,1)) jarque.bera.test(na.omit(error_hatreturnGBP))
summary(fit_garchEURO)
AIC(fit_garchEURO) #ACF of error, error squares
logLik(fit_garchEURO) chart.ACFplus(residuals_gsigmaUSD, maxlag = NULL)
fit_garchGBP <- garch(INRGBP_return, order = c(1,2)) chart.ACFplus(residuals_gsigmaUSD^2, maxlag = NULL)
summary(fit_garchGBP) chart.ACFplus(residuals_gsigmaJPY, maxlag = NULL)
AIC(fit_garchGBP) chart.ACFplus(residuals_gsigmaJPY^2, maxlag = NULL)
logLik(fit_garchGBP) chart.ACFplus(residuals_gsigmaEURO, maxlag = NULL)
chart.ACFplus(residuals_gsigmaEURO^2, maxlag = NULL)
#Comparing ARCH & GARCH chart.ACFplus(residuals_gsigmaGBP, maxlag = NULL)
chart.ACFplus(fit_archUSD$residuals) chart.ACFplus(residuals_gsigmaGBP^2, maxlag = NULL)
chart.ACFplus(fit_garchUSD$residuals) table.Autocorrelation(residuals_gsigmaUSD, digits = 6)
chart.ACFplus(fit_archJPY$residuals) table.Autocorrelation(residuals_gsigmaUSD^2, digits =
chart.ACFplus(fit_garchJPY$residuals) 6)
chart.ACFplus(fit_archEURO$residuals) table.Autocorrelation(residuals_gsigmaJPY, digits = 6)
chart.ACFplus(fit_garchEURO$residuals) table.Autocorrelation(residuals_gsigmaEURO, digits = 6)
chart.ACFplus(fit_archGBP$residuals) table.Autocorrelation(residuals_gsigmaGBP, digits = 6)
chart.ACFplus(fit_garchGBP$residuals) plot(error_hatreturnUSD)
describe(error_hatreturnUSD)
#Checking series for auto correlation hist(error_hatreturnUSD, breaks=100)
#Box.test(fit_garchUSD$residuals^2,lag = 10, type =
"Ljung") #Descriptive Stats of Error
#Fitted Values describe(error_hatreturnUSD)
fit_gsigmaUSD<-((fit_garchUSD$fitted.values)[,1]) describe(error_hatreturnJPY)
residuals_gsigmaUSD <- (fit_garchUSD$residuals) describe(error_hatreturnEURO)
table.Autocorrelation(na.omit(fit_garchUSD$residuals)) describe(error_hatreturnGBP)
fit_ameuUSD<- na.omit(fit_armaUSD$fitted) plot(ts(residuals_gsigmaUSD))
log_returnsUSD <- na.omit(INRUSD_return) plot(error_hatreturnUSD)
error_hatreturnUSD <- ((log_returnsUSD)-
fit_ameuUSD)/(fit_gsigmaUSD) # Fitting an appropriate distribution . 1. PIV 2. Johnson
head(error_hatreturnUSD, n=8) SU
Box.test(error_hatreturnUSD,lag = 10, type = "Ljung") #PIV First
jarque.bera.test(na.omit(error_hatreturnUSD)) error_hatreturnUSD<-na.remove(error_hatreturnUSD)
error_hatreturnUSD<- as.vector(error_hatreturnUSD)
fit_gsigmaJPY<-((fit_garchJPY$fitted.values)[,1]) pearson_USD <- pearsonFitML(error_hatreturnUSD)
residuals_gsigmaJPY <- (fit_garchJPY$residuals) quantilepearson_IV<- qpearsonIV(0.001, m=
fit_ameuJPY<-na.omit(fit_armaJPY$fitted) pearson_USD$m, nu = pearson_USD$nu, location =
log_returnsJPY <- na.omit(INRJPY_return) pearson_USD$location, scale = pearson_USD$scale)
error_hatreturnJPY <- ((log_returnsJPY)- quantilepearson_IV
fit_ameuJPY)/(fit_gsigmaJPY) mean(error_hatreturnUSD)
head(error_hatreturnJPY, n=8) write.csv(REL_return,"D:/term 5/risk/New folder")
Box.test(error_hatreturnJPY^2,lag = 10, type = "Ljung") install.packages("goftest")
jarque.bera.test(na.omit(error_hatreturnJPY)) library("goftest")
goftest::cvm.test(error_hatreturnUSD)
fit_gsigmaEURO<-((fit_garchEURO$fitted.values)[,1])
residuals_gsigmaEURO <- (fit_garchEURO$residuals) error_hatreturnJPY<-na.remove(error_hatreturnJPY)
fit_ameuEURO <-na.omit(fit_armaEURO$fitted) error_hatreturnJPY<- as.vector(error_hatreturnJPY)
log_returnsEURO <- na.omit(INREURO_return) pearson_JPY <- pearsonFitML(error_hatreturnJPY)
error_hatreturnEURO <- ((log_returnsEURO)- quantilepearson_IV<- qpearsonIV(0.001, m=
fit_ameuEURO)/(fit_gsigmaEURO) pearson_JPY$m, nu = pearson_JPY$nu, location =
head(error_hatreturnEURO, n=8) pearson_JPY$location, scale = pearson_JPY$scale)
Box.test(error_hatreturnEURO^2,lag = 10, type = quantilepearson_IV
"Ljung") mean(error_hatreturnJPY)
36 | P a g e
write.csv(REL_return,"D:/term 5/risk/New folder") crosscorrelationUSD_Euro<-
goftest::cvm.test(error_hatreturnJPY) ccf(as.vector(INRUSD_return),as.vector(INREURO_retur
n),lag.max = 50)
error_hatreturnEURO<- crosscorrelationUSD_GBP<-
na.remove(error_hatreturnEURO) ccf(as.vector(INRUSD_return),as.vector(INRGBP_return),
error_hatreturnEURO<- as.vector(error_hatreturnEURO) lag.max = 50)
pearson_EURO <- pearsonFitML(error_hatreturnEURO) crosscorrelationJPY_EURO<-
quantilepearson_IV<- qpearsonIV(0.001, m= ccf(as.vector(INRJPY_return),as.vector(INREURO_return)
pearson_EURO$m, nu = pearson_EURO$nu, location = ,lag.max = 50)
pearson_EURO$location, scale = pearson_EURO$scale) crosscorrelationJPY_GBP<-
quantilepearson_IV ccf(as.vector(INRJPY_return),as.vector(INRGBP_return),l
mean(error_hatreturnEURO) ag.max = 50)
write.csv(REL_return,"D:/term 5/risk/New folder") crosscorrelationEURO_GBP<-
goftest::cvm.test(error_hatreturnEURO) ccf(as.vector(INREURO_return),as.vector(INRGBP_return
),lag.max = 50)
error_hatreturnGBP<-na.remove(error_hatreturnGBP) #Portfolio <-
error_hatreturnGBP<- as.vector(error_hatreturnGBP) merge(INRUSD_return,INRJPY_return,INREURO_return,I
pearson_GBP <- pearsonFitML(error_hatreturnGBP) NRGBP_return,join="inner")
quantilepearson_IV<- qpearsonIV(0.001, m= Portfolio1 <- merge.xts(INRUSD_return,INRJPY_return,
pearson_GBP$m, nu = pearson_GBP$nu, location = join="inner")
pearson_GBP$location, scale = pearson_GBP$scale) Portfolio2 <-
quantilepearson_IV merge.xts(INREURO_return,INRGBP_return,
mean(error_hatreturnGBP) join="inner")
write.csv(REL_return,"D:/term 5/risk/New folder") Portfolio <- merge.xts(Portfolio1, Portfolio2,
goftest::cvm.test(error_hatreturnGBP) join="inner")
Covmatrix_port <- cov(Portfolio)
#Johnson Fit chol_decom_port <- (chol(Covmatrix_port))
paramsUSD<- JohnsonFit(error_hatreturnUSD,moment = View(Covmatrix_port)
"quant") View(chol_decom_port)
quantilejohnsonsu<- errorusd <- as.xts(ts(error_hatreturnUSD))
qJohnson(0.001,paramsUSD,lower.tail = TRUE) errorjpy <- as.xts(ts(error_hatreturnJPY))
quantilejohnsonsu erroreuro <- as.xts(ts(error_hatreturnEURO))
errorgbp <- as.xts(ts(error_hatreturnGBP))
paramsJPY<- JohnsonFit(error_hatreturnJPY,moment = Portfolioerror1 <- merge.xts(errorusd,errorjpy,
"quant") join="inner")
quantilejohnsonsu<- Portfolioerror2 <- merge.xts(erroreuro,errorgbp,
qJohnson(0.001,paramsJPY,lower.tail = TRUE) join="inner")
quantilejohnsonsu Portfolioerror <- merge.xts(Portfolio1, Portfolio2,
join="inner")
paramsEURO<- transformed_error <-
JohnsonFit(error_hatreturnEURO,moment = "quant") t(chol_decom_port%*%t(Portfolioerror))
quantilejohnsonsu<- View(transformed_error)
qJohnson(0.001,paramsEURO,lower.tail = TRUE) Portfolio_errorret <- NULL
quantilejohnsonsu for (i in 1:3512){
Portfolio_errorret[i] <-
paramsGBP<- JohnsonFit(error_hatreturnGBP,moment = ((transformed_error[i,1]+transformed_error[i,2]+transfo
"quant") rmed_error[i,3]+transformed_error[i,4])/4)
quantilejohnsonsu<- }
qJohnson(0.001,paramsGBP,lower.tail = TRUE) View(Portfolio_errorret)
quantilejohnsonsu
paramsport<- JohnsonFit(Portfolio_errorret,moment =
"quant")
#calculating the log returns of the index quantilejohnsonsuport<-
#INRUSD_return <- diff(log(INRUSD_daily), lag=1)[-1] qJohnson(0.01,paramsport,lower.tail = TRUE)
#INRJPY_return <- diff(log(INRJPY_daily), lag=1)[-1] quantilejohnsonsuport
#INREURO_return <- diff(log(INREURO_daily), lag=1)[-1]
#INRGBP_return <- diff(log(INRGBP_daily), lag=1)[-1] #1000 Simulation of epsilon for Portfolio
#Cross Correlation Matrices randomPIV_USD<-rpearsonIV(3517, m
crosscorrelationUSD_JPY<- =pearson_USD$m,nu = pearson_USD$nu, location =
ccf(as.vector(INRUSD_return),as.vector(INRJPY_return),l pearson_USD$location,scale = pearson_USD$scale )
ag.max = 50) randomPIV_JPY<-rpearsonIV(3517, m
=pearson_JPY$m,nu = pearson_JPY$nu, location =
pearson_JPY$location,scale = pearson_JPY$scale )
37 | P a g e
randomPIV_EURO<-rpearsonIV(3517,m tcplot(GDist$GD , tlim = c(0.3,0.35), std.err = FALSE)
=pearson_EURO$m,nu = pearson_EURO$nu, location = install.packages("POT")
pearson_EURO$location,scale = pearson_EURO$scale ) library("POT")
randomPIV_GBP<-rpearsonIV(3517, m mle <- fitgpd(GDist$GD, thresh = 0.35, shape = 0, est =
=pearson_GBP$m,nu = pearson_GBP$nu, location = 'mle')
pearson_GBP$location,scale = pearson_GBP$scale ) gpd.fiscale(mle, conf = 0.95)
plot(mle, npy = 1, which=1)
rPIV_USD<-as.array(randomPIV_USD) plot(mle, npy = 1, which=4)
rPIV_JPY<-as.array(randomPIV_JPY) gfit <- garchFit(data = GDist$GD, cond.dist = "norm",
rPIV_EURO<-as.array(randomPIV_EURO) trace = FALSE)
rPIV_GBP<-as.array(randomPIV_GBP) library("forecast")
gforecast <- fGarch::predict(object = gfit, n.ahead = 1)
#Wrap it up in a for loop with length equal to gforecast
randomPIV install.packages("fExtremes")
fit_gsigmaUSD<- na.remove(fit_gsigmaUSD) library(fExtremes)
38 | P a g e
PerformanceAnalytics::VaR(EURINR_return,
p = 0.999, method = c("historical"))), 3)
VaR_GBPhis <-
round(c(PerformanceAnalytics::VaR(GBPINR_return, p =
0.95, method = c("historical")),
PerformanceAnalytics::VaR(GBPINR_return,
p = 0.975, method = c("historical")),
PerformanceAnalytics::VaR(GBPINR_return,
p = 0.99, method = c("historical")),
PerformanceAnalytics::VaR(GBPINR_return,
p = 0.999, method = c("historical"))), 3)
VaR_USDhis
VaR_JPYhis
VaR_EURhis
VaR_GBPhis
39 | P a g e