IT Business Application Lab Assignments#6
Session 6
Date: 12th Feb,2013
Assignment 1:
Create a log of return data for a period of more than 1 year(1.1.2012-1.1.2013) and use this data to calculate historical volatility.
Commands:
> stockprice<-read.csv(file.choose(),header=T)
> head(stockprice)
> closingprice<-stockprice$5
> closingprice.ts<-ts(closingprice,frequency=252)
> returns<-(closingprice.ts-lag(closingprice.ts,k=-1))/lag(closingprice.ts,k=-1)
> z<-scale(returns)+10
> returnslog<-log(z)
> returnslog
Assignment 2:
Calculate ACF plot for logreturns data and do an ADF test & interpret the result.
For acf plotting
> acf(returnslog)
Output:
From the above graph we can see that the results lie between 95% confidence interval.So we can safely conclude that the time series is stationary.
> T=252^0.5
> historicalvolatility<-sd(returnslog)*T
> historicalvolatility
> adf.test(returnslog)
Commands:
From the above output we find that p value is=0.01 which is < 0.05
So, we reject the null hypothesis and accept the alternate hypothesis that the time series is stationary.



No comments:
Post a Comment