Wednesday, February 13, 2013

Session # 6

Session # 6



Assignment 1

1) Create log of returns data (from 01.01.2012 to 01.01.2013) and calculate historical volatility
2) Create ACF plot for the log returns data ,perform adf test and interpret.

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
> logreturns<-log(z)
> logreturns
> acf(logreturns)










From the above graph, we can see that the measurements lie with in the 95% confidence interval. Therefore, the time series is stationary.
> T=252^0.5
> historicalvolatility<-sd(logreturns)*T
> historicalvolatility
> adf.test(logreturns)




Augmented Dickey-Fuller Test


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

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





Interpretation:


Since p-value is less than (1-.95) ,therefore we can say null hypothesis is rejected and hence the time series is stationary so data analysis can be done.

Thursday, February 7, 2013

Session #5


Assignment 1


1. Find returns of NSE data of greater than 6 months having selected the 10th data point as start and 95th data point as end.

2. Find plot of that return

The file consist of S&P CNX Nifty data from January 2012 to July 2012.



Code




Extra Commands






Returns













Plot





Assignment 2


1-700 data is available, Predict the data from 701-850, use the GLM estimation using LOGIT Analysis for the same.


Solution:



 

Annexures: