ITBAL: SESSION 6
Assignment 1:
Create log of returns for NIFTY data from 01 Jan 2012 to 31 Jan 2013 and calculate the historical volatility
head(z)
closingprice<-z[,5]
closingprice.ts<-ts(closingprice, frequency =252)
st<-log(closingprice.ts)
stlag<-log(lag(closingprice.ts,k=-1))
log.returns<-(st-stlag)/stlag
plot(log.returns)
T =(252) ^ 0.5
historicalvolatility<-sd(returns) * T
historicalvolatility
Assignment 1:
Create log of returns for NIFTY data from 01 Jan 2012 to 31 Jan 2013 and calculate the historical volatility
Solution:
z<-read.csv(file.choose(), header =T)
head(z)
closingprice<-z[,5]
closingprice.ts<-ts(closingprice, frequency =252)
st<-log(closingprice.ts)
stlag<-log(lag(closingprice.ts,k=-1))
log.returns<-(st-stlag)/stlag
plot(log.returns)
T =(252) ^ 0.5
historicalvolatility<-sd(returns) * T
historicalvolatility
Assignment 2:
Create ACF plot for the above log of returns data and perform the adf test and comment on it
The ACF plot can be done using the below formula
acf(log.returns)
Create ACF plot for the above log of returns data and perform the adf test and comment on it
The ACF plot can be done using the below formula
acf(log.returns)
It can be seen from the plot that the data lies within the 95% confidence interval and there is maximum possibility of data being stationary.
The ADF test is done using :
adf.test(returns)
The ADF test is done using :
adf.test(returns)
As the P value is less than the significant value(0.05) and we can reject the null hypothesis.
Hence as per the alternate hypothesis data being stationary, analysis can be done.
Hence as per the alternate hypothesis data being stationary, analysis can be done.



No comments:
Post a Comment