Wednesday, 13 February 2013

Session 6


Assignment 1 - 

Download data for NIFTY index from 1st Jan , 2012 to 31st Jan 2013.. 
Calculate the log of returns data and find out the historical volatility.

Commands Used:

data<-read.csv(file.choose() , header=T)
closePrice<-data$Close
closePrice.ts<-ts(closePrice , frequenxy=252)
varLag<- lag(closePrice.ts , k=-1)
logClosePrice<- log(closePrice.ts , base=exp(1)) - log(varLag , base=exp(1))
LogReturns<-logClosePrice/log(varLag , base=exp(1)) 


To Calculate Historical Volatility:

> sqrt<-252^0.5
> historicalVol<-sd(LogReturns)*sqrt
> historicalVol
[1] 0.01719952

Assignment 2 :


To create an acf plot for the log returns data calculated previously. Also do and adf test and interpret the result

acf(LogReturns)

Grahical Interpretation
- As all the co-relations plots(vertical lines) lie inside confidence interval for the hypothesis (95% in default case)represented by two blue dotted lines , we can interpret that the returns data is "Stationary" in nature. This is visual inspection method for determining stationarity.




ADF Test


Command Used:
adf.test(LogReturns)

Output
     Augmented Dickey-Fuller Test

data:  LogReturns
Dickey-Fuller = -5.6217, Lag order = 6, p-value = 0.01
alternative hypothesis: stationary

Warning message:
In adf.test(LogReturns) : p-value smaller than printed p-value



Interpretation from ADF test
Null Hypothesis -: The returns data is not Stationary
Alternative Hypothesis -: Returns Data is stationary

As from the test results p-value = 0.01 which is less than 0.05 value as stated for 95%confidence interval.
Hence Null Hypothesis is rejected.

Results -: given data is stationary in nature


No comments:

Post a Comment