You are on page 1of 40

RISK MANAGEMENT

END TERM

PRATEEK AWASTHI(P16003) | SHARDUL KAUSHIK (P16026)


VIKRAM KHANNA (P16027) |ABHISHEK PANDEY (P16039)
GROUP 4
IIM Nagpur
1. Compute the daily log returns of the four exchange rates.
The following Graphs depict the time series values of log returns. We see that there have been
aberrations in the year 2008 coinciding with the Global Financial Crisis.

USD-INR Return Series

JPY-INR Return Series

EURO-INR Return Series

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%.

3. Test the stationarity of each log return series.

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.

USD: Dickey-Fuller = -13.549, Lag order = 15, p-value = 0.01

JPY: Dickey-Fuller = -14.481, Lag order = 15, p-value = 0.01

EUR: Dickey-Fuller = -15.422, Lag order = 15, p-value = 0.01

GBP: Dickey-Fuller = -13.549, Lag order = 15, p-value = 0.01

4. Test normality of each log return series.

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.

Exchange Currency AIC Value Order


INR-USD 0 8
INR-JPY 0 2
INR-EUR 0 2
INR-GBP 0 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

Order selected 8 sigma^2 estimated as 2.625e-05

JPY-INR
ar(x = INRJPY_return, aic = TRUE, order.max = NULL)

Coefficients:
1 2
-0.1967 -0.0501

Order selected 2 sigma^2 estimated as 9.177e-05

EURO-INR
ar(x = INREURO_return, aic = TRUE, order.max = NULL)

Coefficients:
1 2
-0.2984 -0.0787

Order selected 2 sigma^2 estimated as 7.347e-05

3|Page
GBP-INR
ar(x = INRGBP_return, aic = TRUE, order.max = NULL)

Coefficients:
1
-0.122

Order selected 1 sigma^2 estimated as 5.145e-05

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

Mean of the Residuals

Exchange Currency Mean


INR-USD 9.874e-07
INR-JPY -1.828e-06
INR-EUR -4.480e-06
INR-GBP -1.7567e-06

Stationarity (ADF Test)

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

Auto-Correlation (ACF & Box-Ljung Test)

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

Autocorrelations of series ‘(fit_arJPY$resid)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.000 -0.001 -0.003 -0.015 0.015 -0.014 -0.011 -0.016 0.041 0.003 0.036

EURO-INR

Autocorrelations of series ‘(fit_arEURO$resid)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.00 -0.002 -0.005 -0.018 0.013 0.003 -0.002 0.027 0.031 -0.027 0.000

GBP-INR

Autocorrelations of series ‘(fit_arGBP$resid)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.000 0.001 0.008 -0.008 0.012 0.010 0.007 0.002 0.032 -0.011 -0.014

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:

Exchange Currency AIC Value SMA Order


INR-USD -24647.97 180
INR-JPY -22561.53 185
INR-EUR -23170.96 196
INR-GBP -24647.97 198

USD-INR

Model estimated: SMA(180)


Initial values were produced using backcasting.
2 parameters were estimated in the process
Residuals standard deviation: 0.005
Cost function type: MSE; Cost function value: 0
Information criteria:
AIC AICc BIC
-26994.68 -26994.67 -26982.35

JPY-INR

Model estimated: SMA(185)


Initial values were produced using backcasting.
2 parameters were estimated in the process
Residuals standard deviation: 0.01
Cost function type: MSE; Cost function value: 0

Information criteria:
AIC AICc BIC
-22561.53 -22561.53 -22549.20

EURO-INR

Model estimated: SMA(196)


Initial values were produced using backcasting.
2 parameters were estimated in the process
Residuals standard deviation: 0.009
Cost function type: MSE; Cost function value: 0

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.

Mean of the Residuals

Exchange Currency Mean


INR-USD -2.900e-06
INR-JPY -5.375e-06
INR-EUR 5.305e-06
INR-GBP -8.935e-06

Stationarity (ADF Test)

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

Auto-Correlation (ACF & Box-Ljung Test)

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

Autocorrelations of series ‘(fit_maJPY$residuals)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.000 -0.188 -0.013 -0.005 0.018 -0.014 -0.006 -0.021 0.043 -0.012 0.038

EURO-INR

Autocorrelations of series ‘(fit_maEURO$residuals)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.000 -0.277 0.004 0.001 0.011 0.001 -0.011 0.019 0.031 -0.035 0.004

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

ARIMA(2,0,0) with zero mean

Coefficients:
ar1 ar2
-0.1524 0.0294
s.e. 0.0169 0.0169

sigma^2 estimated as 2.637e-05: log likelihood=13551.05


AIC=-27096.1 AICc=-27096.09 BIC=-27077.6

JPY-INR

ARIMA(0,0,1) with zero mean

Coefficients:
ma1
-0.2001
s.e. 0.0168

sigma^2 estimated as 9.173e-05: log likelihood=11358.28


AIC=-22712.56 AICc=-22712.55 BIC=-22700.23

7|Page
EURO-INR
ARIMA(0,0,1) with zero mean

Coefficients:
ma1
-0.2974
s.e. 0.0159

sigma^2 estimated as 7.342e-05: log likelihood=11746.35


AIC=-23488.71 AICc=-23488.71 BIC=-23476.38

GBP-INR
ARIMA(1,0,0) with zero mean

Coefficients:
ar1
-0.1221
s.e. 0.0168

sigma^2 estimated as 5.143e-05: log likelihood=12361.61


AIC=-24719.22 AICc=-24719.22 BIC=-24706.89

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.

Mean of the Residuals

Exchange Currency Mean


INR-USD 0.000
INR-JPY 0.000
INR-EUR 0.000
INR-GBP 2.216e-05

Stationarity (ADF Test)

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

Auto-Correlation (ACF & Box-Ljung Test)

USD-INR

Autocorrelations of series ‘(fit_armaUSD$residuals)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.000 0.000 -0.002 -0.004 0.025 0.053 -0.031 0.005 0.037 0.000 0.031

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

Autocorrelations of series ‘(fit_armaGBP$residuals)’, by lag


0 1 2 3 4 5 6 7 8 9 10
1.000 0.001 0.008 -0.008 0.012 0.010 0.007 0.002 0.032 -0.011 -0.013

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

Day Point Forecast Low 80 High 80 Low 95 High 95


1 -0.001371838 -0.01364590 0.01090223 -0.02014340 0.01739973
2 0.00 -0.01251728 0.01251728 -0.01914353 0.01914353
3 0.00 -0.01251728 0.01251728 -0.01914353 0.01914353
4 0.00 -0.01251728 0.01251728 -0.01914353 0.01914353
5 0.00 -0.01251728 0.01251728 -0.01914353 0.01914353
6 0.00 -0.01251728 0.01251728 -0.01914353 0.01914353
7 0.00 -0.01251728 0.01251728 -0.01914353 0.01914353

9|Page
EURO-INR

Day Point Forecast Low 80 High 80 Low 95 High 95


1 -0.003508356 -0.0144896 0.007472884 -0.02030271 0.01328600
2 0.00 -0.0114567 0.011456700 -0.01752151 0.01752151
3 0.00 -0.0114567 0.011456700 -0.01752151 0.01752151
4 0.00 -0.0114567 0.011456700 -0.01752151 0.01752151
5 0.00 -0.0114567 0.011456700 -0.01752151 0.01752151
6 0.00 -0.0114567 0.011456700 -0.01752151 0.01752151
7 0.00 -0.0114567 0.011456700 -0.01752151 0.01752151

GBP-INR

Day Point Forecast Low 80 High 80 Low 95 High 95


1 -1.171533e-03 -0.010362392 0.008019326 -0.01522774 0.01288467
2 1.429960e-04 -0.009116074 0.009402066 0.009402066 0.01430352
3 -1.745392e-05 -0.009277537 0.009242629 -0.01417953 0.01414462
4 2.130405e-06 -0.009257967 0.009262228 -0.01415997 0.01416423
5 -2.600347e-07 -0.009260358 0.009259838 -0.01416236 0.01416184
6 3.173953e-08 -0.009260066 0.009260130 -0.01416207 0.01416213
7 -3.874089e-09 -0.009260102 0.009260094 -0.01416210 0.01416209

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

Squared Log-Return of USD-INR

Model Log Likelihood AIC


Arch(1) 13283.71 -27643.41
Arch(2) 13889.82 -27773.65
Arch(3) 13940.93 -27873.85
Arch(4) 14019.35 -28028.71
Arch(5) 14074.87 -28137.75
Arch(6) 14113.17 -28212.33
Arch(7) 14154.39 -28292.78
Arch(8) 14161.43 -28304.87
Arch(9) 14164.55 -28309.09
Arch(10) 14163.2 -28304.39

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.

The ARCH model for USD-INR is ARCH(9):

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

Model Log Likelihood AIC


Arch(1) 11610.56 -23217.12
Arch(2) 11628.07 -23250.13
Arch(3) 11625.39 23242.78
Arch(4) 11652.14 -23294.28
Arch(5) 11883.64 -23755.27
Arch(6) 11904.24 -23794.48
Arch(7) 11917.93 -23819.85
Arch(8) 11914.01 -23810.02
Arch(9) 11884.48 -23748.96
Arch(10) 11881.54 -23741.08

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.

The ARCH model for USD-INR is ARCH(7):

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

Squared 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).

The ARCH model for USD-INR is 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

Squared Log-Return of GBP-INR

Model Log Likelihood AIC


Arch(1) 12510.2 -25016.41
Arch(2) 12540.24 -25074.48
Arch(3) 12540.56 -25073.12
Arch(4) 12561.31 -25112.63
Arch(5) 12579.11 -25146.21
Arch(6) 12588.19 -25162.37
Arch(7) 12622.05 -25228.1
Arch(8) 12620.24 -25222.48
Arch(9) 12616.53 -25213.07
Arch(10) 12619.81 -25217.62

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).

The ARCH model for USD-INR is ARCH(3):


Model:
GARCH(0,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 Log Likelihood AIC


GARCH(1,1) 14210.19 -28414.37
GARCH(1,2) 14214.02 -28436.41
GARCH(2,1) 14222.21 -28420.04
GARCH(2,2) 14217.76 -28425.52

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 Log Likelihood AIC


GARCH(1,1) 11966.57 -23927.14
GARCH(1,2) 11966.15 -23924.3
GARCH(2,1) 11966.96 -23925.92
GARCH(2,2) 11960.12 -23910.25

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

Model Log Likelihood AIC


GARCH(1,1) 12315.35 -24620.7
GARCH(1,2) 11971.12 -23935.02
GARCH(2,1) 12294.55 -24581.1
GARCH(2,2) 12008.31 -24010.61

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 Log Likelihood AIC


GARCH(1,1) 12612.1 -25216.2
GARCH(1,2) 12620.79 -25235.38
GARCH(2,1) 12619.7 -25231.39
GARCH(2,2) 12618.26 -25226.51

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

N Vars Mean SD Median Mad Min Max Skew Kurtosis SE


3516 1 0.02 1.02 -0.01 0.8 -7.21 8.85 0.18 4.21 0.02

JPY-INR

N Vars Mean SD Median Mad Min Max Skew Kurtosis SE


3516 1 0.01 1 -0.02 0.085 -8.86 7.46 0.08 4.58 0.02

EURO-INR

N Vars Mean SD Median Mad Min Max Skew Kurtosis SE


3515 1 0.03 1 0.01 0.77 -4.69 20.54 3.37 58.35 0.02

GBP-INR

N Vars Mean SD Median Mad Min Max Skew Kurtosis SE


3511 1 0.01 0.99 0.01 0.89 -7.93 8.11 -0.11 3.66 0.02

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

Jarque Bera Test


data: (error_hatreturnUSD)
X-squared = 2627.2, df = 2, p-value < 2.2e-16

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

Jarque Bera Test


data: (error_hatreturnGBP)
X-squared = 1969.5, df = 2, p-value < 2.2e-16

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.

Fitting the Pearson IV Distribution

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

Pearson Distribution Johnson SU Distribution


% VaR
Error VaR Error Var
95% -1.517131 -0.0003 -1.528114 -0.00028
97.5% -1.952315 -0.0008 -1.9653 -0.00083
99% -2.594205 -0.00243 -2.588459 -0.00241
99.9% -4.78407 -0.00797627 -4.470794 -0.00718

JPY-INR

Pearson Distribution Johnson SU Distribution


% VaR
Error VaR Error Var
95% -1.515258 -0.00116 -1.473493 -0.00094
97.5% -1.900218 -0.00319 -1.827341 -0.00281
99% -2.435599 -0.00603 -2.298749 -0.0053
99.9% -4.060524 -0.01462297 -3.573113 -0.01204

28 | P a g e
EURO-INR

Pearson Distribution Johnson SU Distribution


% VaR
Error VaR Error Var
95% -1.407682 -0.0014 -1.411174 -0.0138
97.5% -1.786655 -0.00139 -1.794987 -0.00146
99% -2.323131 -0.00535 -2.323508 -0.00536
99.9% -4.003586 -0.017759 -3.825035 -0.01644

GBP-INR

Pearson Distribution Johnson SU Distribution


% VaR
Error VaR Error Var
95% -1.579172 -0.000036 -1.55661 -0.00012
97.5% -1.972265 -0.00273 -1.908966 -0.0023
99% -2.498233 -0.00634 -2.3547 -0.00535
99.9% -3.958484 -0.016349 -3.446947 -0.01284

17. Compute the cross-correlation matrix of the returns of the four exchange rates.

Cross Correlation plot for USD-JPY

29 | P a g e
Cross Correlation plot for USD-EURO

Cross Correlation plot for USD-GBP

Cross Correlation plot for JPY-EURO

30 | P a g e
Cross Correlation plot for JPY-GBP

Cross Correlation plot for EURO-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:

USDINR JPYINR EURINR GBPINR

USDINR 2.703962e-05 2.758446e-05 2.013538e-05 2.017695e-05

JPYINR 2.758446e-05 9.520951e-05 1.225089e-05 2.409175e-05

EURINR 2.013538e-05 1.225089e-05 8.004536e-05 3.983777e-05

GBPINR 2.017695e-05 2.409175e-05 3.983777e-05 5.216926e-05

31 | P a g e
The decomposed Cholesky matrix is sown below:

USDINR JPYINR EURINR GBPINR

USDINR 0.005199964 0.0000000000 0.000000000 0.000000000

JPYINR 0.005304741 0.0081895809 0.000000000 0.000000000

EURINR 0.003872216 -0.0010122876 0.008001661 0.000000000

GBPINR 0.003880210 0.0004283785 0.003155145 0.005193725

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.

% VaR USD-INR JPY-INR EURO-INR GBP-INR


95% -0.007 -0.013 -0.012 -0.011
97.5% -0.010 -0.017 -0.015 -0.014
99% -0.013 -0.022 -0.019 -0.018
99.9% -0.029 -0.057 -0.061 -0.048

20. Comment on all the results obtained above.


We see that the returns are exchange rate leptokurtic in nature and the three distributions,
Pearson type IV, Johnson Su and EVT were used to determine the VaR. Of the three
distributions, EVT gives the maximum value of the VaR as it takes into consideration beyond
1% quantile from return and fit in into separate Generalized Parreto Distribution.

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)

#Stores closing price #Descriptive stats of returns


INRUSD_daily <- INR_USD[,"USDINR=X.Close"] describe(INRUSD_return)
INRJPY_daily<- INR_JPY[,"JPYINR=X.Close"] describe(INRJPY_return)
INREURO_daily<- INR_EURO[,"EURINR=X.Close"] describe(INREURO_return)
INRGBP_daily<- INR_GBP[,"GBPINR=X.Close"] describe(INRGBP_return)

#Removes NA #ACF of log retunrs


INR_USD<-na.omit(INRUSD_daily) chart.ACFplus(INRUSD_return, maxlag = NULL)
INR_JPY<-na.omit(INRJPY_daily) chart.ACFplus(INRJPY_return, maxlag = NULL)
INR_EURO<-na.omit(INREURO_daily) chart.ACFplus(INREURO_return, maxlag = NULL)
INR_GBP<-na.omit(INRGBP_daily) chart.ACFplus(INRGBP_return, maxlag = NULL)
# plot all closing prices table.Autocorrelation(INRUSD_return, digits = 20)
plot(INR_USD) table.Autocorrelation(INRJPY_return, digits = 20)
plot(INR_JPY) table.Autocorrelation(INREURO_return, digits = 20)
plot(INR_EURO) table.Autocorrelation(INRGBP_return, digits = 20)
plot(INR_GBP)
#ADF Test (unit root test) of Returns
#Descriptive Statistics of Index adf.test(INRUSD_return)
describe(INR_USD) adf.test(INRJPY_return)
describe(INR_JPY) adf.test(INREURO_return)
describe(INR_EURO) adf.test(INRUSD_return)
describe(INR_GBP)
# Test of Normality - Jarquee Bera Test
#Drawing the Histogram jarque.bera.test(INRUSD_return)
hist(INR_USD, breaks = 100) jarque.bera.test(INRJPY_return)
hist(INR_JPY, breaks = 100) jarque.bera.test(INREURO_return)
hist(INR_EURO, breaks = 100) jarque.bera.test(INRGBP_return)
hist(INR_GBP, breaks = 100)
#AR FIt
#ACF of Index fit_arUSD<-ar(INRUSD_return, aic = TRUE, order.max =
chart.ACF(INR_USD,maxlag = NULL) 3)
chart.ACF(INR_JPY,maxlag = NULL) head(fit_arUSD)
chart.ACF(INR_EURO,maxlag = NULL) summary(fit_arUSD)
chart.ACF(INR_GBP,maxlag = NULL) fit_arUSD
#p-values for AR
#ADF Test (unit root test) (1-
adf.test(INR_USD) pnorm(abs(fit_arUSD$ar)/sqrt(diag(fit_arUSD$asy.var.co
adf.test(INR_JPY) ef))))*2
adf.test(INR_EURO) fit_arJPY<-ar(INRJPY_return, aic = TRUE, order.max = 3)
adf.test(INR_GBP) head(fit_arJPY)
summary(fit_arJPY)
#calculating the log returns of the index fit_arJPY
INRUSD_return <- diff(log(INR_USD), lag=1)[-1] #p-values for AR
INRJPY_return <- diff(log(INR_JPY), lag=1)[-1] (1-
INREURO_return <- diff(log(INR_EURO), lag=1)[-1] pnorm(abs(fit_arJPY$ar)/sqrt(diag(fit_arJPY$asy.var.coef
INRGBP_return <- diff(log(INR_GBP), lag=1)[-1] ))))*2
fit_arEURO<-ar(INREURO_return, aic = TRUE, order.max
#Histograms of log returns = 3)
hist(INRUSD_return, breaks = 100) head(fit_arEURO)
hist(INRJPY_return, breaks = 100) summary(fit_arEURO)

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

#Plot ACF of residuals #Plot ACF of residuals


chart.ACFplus(residuals_armaUSD) chart.ACFplus(INRUSD_return)
chart.ACFplus(residuals_armaUSD^2) chart.ACFplus(INRUSD_return^2)
chart.ACFplus(residuals_armaJPY) chart.ACFplus(INRJPY_return)
chart.ACFplus(residuals_armaJPY^2) chart.ACFplus(INRJPY_return^2)
chart.ACFplus(residuals_armaEURO) chart.ACFplus(INREURO_return)
chart.ACFplus(residuals_armaEURO^2) chart.ACFplus(INREURO_return^2)
chart.ACFplus(residuals_armaGBP) chart.ACFplus(INRGBP_return)
chart.ACFplus(residuals_armaGBP^2) chart.ACFplus(INRGBP_return^2)
#table.Autocorrelation(residuals_armaUSD, digits = 6) #ARCH Model(refer wikipedia for analysis of p value)
#table.Autocorrelation(residuals_armaUSD^2, digits = 6) fit_archUSD <- ArchTest (residuals_armaUSD, lags=12,
#table.Autocorrelation(residuals_armaJPY, digits = 6) demean = FALSE)
#table.Autocorrelation(residuals_armaJPY^2, digits = 6) summary(fit_archUSD)
#table.Autocorrelation(residuals_armaEURO, digits = 6) fit_archUSD
#table.Autocorrelation(residuals_armaEURO^2, digits = fit_archJPY <- ArchTest (residuals_armaJPY, lags=12,
6) demean = FALSE)
#table.Autocorrelation(residuals_armaGBP, digits = 6) summary(fit_archJPY)
#table.Autocorrelation(residuals_armaGBP^2, digits = 6) fit_archEURO <- ArchTest (residuals_armaEURO,
##plot(residuals_armaUSD) lags=12, demean = FALSE)
##hist(residuals_armaUSD,breaks = 100) summary(fit_archEURO)
##describe(residuals_armaUSD) fit_archGBP <- ArchTest (residuals_armaGBP, lags=12,
fcast_USD<-forecast(fit_armaUSD,h=7) demean = FALSE)
plot(fcast,type='l')#lim=c(2016,2017)) summary(fit_archGBP)
fcast_USD ##other method for arch only
fcast_JPY<-forecast(fit_armaJPY,h=7) fit_archUSD <- garch(residuals_armaUSD, order = c(0, 9),
fcast_JPY series = NULL)
fcast_EURO<-forecast(fit_armaEURO,h=7) summary(fit_archUSD)
fcast_EURO logLik(fit_archUSD)
fcast_GBP<-forecast(fit_armaGBP,h=7) AIC(fit_archUSD)
fcast_GBP #fit_archUSD
fit_archJPY <- garch(residuals_armaJPY, order = c(0, 7),
#Evidence of ARCH series = NULL)
#test_boxljungUSD<-Box.Ljung.Test(residuals_armaUSD, summary(fit_archJPY)
lag = NULL, main = NULL) logLik(fit_archJPY)
#summary(test_boxljungUSD) AIC(fit_archJPY)
#test_durbinwUSD <- fit_archEURO <- garch(residuals_armaEURO, order = c(0,
durbinWatsonTest(residuals_armaUSD) 9), series = NULL)
#summary(test_durbinwUSD) summary(fit_archEURO)
test_boxljungUSD<-Box.test(INRUSD_return, lag = 10, logLik(fit_archEURO)
type = "Ljung" ) AIC(fit_archEURO)
test_boxljungUSD fit_archGBP <- garch(residuals_armaGBP, order = c(0, 3),
test_boxljungUSD2<-Box.test(INRUSD_return^2, lag = series = NULL)
10, type = "Ljung" ) summary(fit_archGBP)
test_boxljungUSD2 logLik(fit_archGBP)
test_boxljungJPY<-Box.test(INRJPY_return, lag = 10, type AIC(fit_archGBP)
= "Ljung" )
test_boxljungJPY

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)

array_return<-matrix(,nrow=4, ncol=3517) # EVT - POT


for (i in 1:380){ thres_USD <- quantile(INRUSD_return,0.01)
for(j in 1:length(rPIV_USD)-1){ thres_JPY <- quantile(JPYINR_return,0.01)
erMatrix<-0 thres_EUR <- quantile(EURINR_return,0.01)
mmult<-0 thres_GBP <- quantile(GBPINR_return,0.01)
rt_USD<-0 GPDU <- gpdFit(as.numeric(INRUSD_return)*-1, u =
rt_JPY<-0 thres_USD *-1, type = c("mle"))
rt_EURO<-0 GPDJ <- gpdFit(as.numeric(JPYINR_return)*-1, u =
rt_GBP<-0 thres_JPY *-1, type = c("mle"))
weighted_rt<-0 GPDE <- gpdFit(as.numeric(EURINR_return)*-1, u =
erMatrix<- matrix(c(rPIV_USD[j], thres_EUR *-1, type = c("mle"))
rPIV_JPY[j],rPIV_EURO[j],rPIV_GBP[j]), nrow= 4, ncol=1) GPDG <- gpdFit(as.numeric(GBPINR_return)*-1, u =
mmult<-chol_decom_port%*%erMatrix thres_GBP *-1, type = c("mle"))
rt_USD<- VaR_USD <-round(tailRisk(GPDU, prob=c(0.95, 0.975,
fit_armaUSD$residuals[1000+i]+fit_gsigmaUSD[1000+i]* 0.99, 0.999) ), 3)
mmult[1,] VaR_JPY <-round(tailRisk(GPDJ, prob=c(0.95, 0.975,
rt_JPY<- 0.99, 0.999) ), 3)
fit_armaJPY[1000+i]+fit_gsigmaJPY[1000+i]*mmult[1,] VaR_EUR <-round(tailRisk(GPDE, prob=c(0.95, 0.975,
rt_EURO<- 0.99, 0.999) ), 3)
fit_armaEURO[1000+i]+fit_gsigmaEURO[1000+i]*mmult[ VaR_GBP <-round(tailRisk(GPDG, prob=c(0.95, 0.975,
1,] 0.99, 0.999) ), 3)
rt_GBP<- VaR_JPYhis <-
fit_armaGBP[1000+i]+fit_gsigmaGBP[1000+i]*mmult[1,] round(c(PerformanceAnalytics::VaR(JPYINR_return, p =
weighted_rt<- 0.25*rt_USD + 0.25*rt_JPY + 0.95, method = c("historical")),
0.25*rt_EURO + 0.25*rt_GBP PerformanceAnalytics::VaR(JPYINR_return,
array_return[i,j]<- weighted_rt p = 0.975, method = c("historical")),
} PerformanceAnalytics::VaR(JPYINR_return,
} p = 0.99, method = c("historical")),
#EVT - POT PerformanceAnalytics::VaR(JPYINR_return,
install.packages("evir") p = 0.999, method = c("historical"))), 3)
install.packages("extRemes") VaR_USDhis <-
library("evir") round(c(PerformanceAnalytics::VaR(INRUSD_return, p =
library("extRemes") 0.95, method = c("historical")),
emplot(error_hatreturnJPY, alog = "xy") PerformanceAnalytics::VaR(INRUSD_return,
qplot(error_hatreturnJPY, trim = 250) p = 0.975, method = c("historical")),
meplot(error_hatreturnJPY, omit = 0) PerformanceAnalytics::VaR(INRUSD_return,
p = 0.99, method = c("historical")),
#Gumbel_density(GD) PerformanceAnalytics::VaR(INRUSD_return,
GD <- exp(-error_hatreturnJPY - exp(- p = 0.999, method = c("historical"))), 3)
error_hatreturnJPY)) VaR_EURhis <-
View(GD) round(c(PerformanceAnalytics::VaR(EURINR_return, p =
plot(error_hatreturnJPY, GD) 0.95, method = c("historical")),
GDist <- data.frame(error_hatreturnJPY, GD) PerformanceAnalytics::VaR(EURINR_return,
View(GDist) p = 0.975, method = c("historical")),
par(mfrow=c(1,2)) PerformanceAnalytics::VaR(EURINR_return,
install.packages("evd") p = 0.99, method = c("historical")),
library("evd")

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

You might also like