Wednesday, 13 February 2013

ITBAL-6 on Feb 12

Question 1:
Create a log of returns data and calculate its historical volatility. Create ACF plot for log returns, do ADF test and analyse it.

Formula used:
(log St - log St-1 )/ log St-1

Data set used:
NSE Nifty Indices from Jan 1 2012 to Jan 31 2013.

Commands:

data<-read.csv(file.choose(),header=T)
close<-data$Close
close.ts<-ts(close,frequency=252)
closeshift.ts<-lag(close.ts,k=-1)
numerator<-log(close.ts)-log(closeshift.ts)
numerator
returns<-numerator/log(closeshift.ts)
plot(returns,main="Log Returns;NIFTY 1 Jan 2012 to 31 Jan 2013")
acf(returns,main="Auto Correlation Function on log returns")
adf.test(returns)
T<-252^0.5
histvol<-sd(returns)/T
histvol


Return values:



Plot of log returns:


ACF Plot of log returns:

Autocorrelation calculates the correlation between different time steps/lags within the same variable. Since the correlation measurements lie within the confidence interval of 95% (the 2 dotted lines) and pattern exists in the correlation, time series is stationary.


ADF test and Historical Volatility:


Confidence interval = 95%
implies, Alpha = 0.05
After ADF test, obtained p-value = 0.01 which is < alpha
Hence, we REJECT the null hypothesis.

No comments:

Post a Comment