Wednesday, February 13, 2013

Business Applications Lab Session #6 on 12th Feb 2013


Assignment: 

Create log of returns data  and calculate its historical volatility

Commands : 

1) logSt-logSt-1/logSt-1
OR
2) log(St-St-1/St-1)

Create ACF Plot for log returns and do the ADF test and analyse on it
Data :
NSE Index –Jan 2012 –Jan 2013
NIFTY data –Closing prices

Commands:-

> niftychart<-read.csv(file.choose(),header=T)
> closingval<-niftychart$Close

> closingval.ts<-ts(closingval,frequency=252)
> plot(log( closingval.ts))
> minusone.ts<-lag(closingval.ts,K=-1)
> plot(log( minusone.ts))
> z<-log(closingval.ts)-log(minusone.ts)
> z



> returns<-z/log(minusone.ts)
> plot(returns,main="Plot of Log Returns;CNX NSE Nifty Jan-2012 to Jan-2013" )

 > acf(returns,main=" The Auto Correlation Plot;   Dotted line shows 95% confidence interval ")



The ACF plot shows that all the correlations lie within our expectations of a 95% confidence interval so there is a fairly good chance of considering the Data to be "STATIONARY"

> adf.test(returns)




Now with the ADF test and its P-value we can confirm that the Data is "Stationary"

# Now calculating the Historical volatility of the Data

> T<-252^0.5
> histvolatality<-sd(returns)/T

> histvolatality

No comments:

Post a Comment