Wednesday 13 February 2013

Session 6, February 12



Session 6, February 12
Assignment 1: Create a log of returns data(either by log(St- St-1)  or log(S(t)- S(t-1)/S(t-1)) and calculate the historical volatility. Use NSE index for last one year 1/1/2012 to 31/01/2013) work with closing prices.

Solution: Command


> stockprice<-read.csv(file.choose(),header=T)
> closingprice<-stockprice[,5]
> closingprice.ts<-ts(closingprice, frequency=252)
> lagtable<-cbind(closingprice.ts,lag(closingprice.ts,k = -1), closingprice.ts-lag(closingprice.ts,k = -1))
> returns<-(closingprice.ts-lag(closingprice.ts,k=-1))/lag(closingprice.ts,k=-1)
> returns.scale<-scale(returns)+10
> logreturns<-log(returns.scale)
> acf(logreturns)

Fron the visual examination of the plot it is clear the values lie between the designated confidence interval as a result the data is stationary.

Assignment 2: Create ACF plot and interpret the results for log returns data and do ADF  and interpret the result

Solution: 
Command:
 T<-252^.5
> Historicalvolatility<-sd(returns)*T
> Historicalvolatility
 After the historical  volatility is obtained, Augmented Dicky-Fuller Test is done on the returns value.
> adf.test(logreturns)


 1.1 Plot to show the stationarity of the data set 



1.2 Screenshot of the Historical data and the result obtained after the ADF test.

Conclusion: From the ADF test result, it is clear that the p value is less than alpha (0.05). Hence the null hypothesis is rejected and it can be said that the TS is stationary.