Wednesday, 13 February 2013

Day 6 : IT Lab

Date : 12-Feb-2013

Assignment 1 - Download data for NIFTY index from 1st Jan , 2012 to 31st Jan 2013.. Calculcate the log of returns data and find out the historical volatility.

Soln -:

Commands used - :

readData<-read.csv(file.choose() , header=T)
closePrice<-readData[,5] // Reading Closing Price Column
closePrice.ts<-ts(closePrice , frequenxy=252)  // making a time series
varLag<- lag(closePrice.ts , k=-1) // calculating stock price for time (t-1)
logNum<- log(closePrice.ts , base=exp(1)) - log(varLag , base=exp(1)) // Calculating log
LogReturns<-logNum/log(varLag , base=exp(1)) // calculating log for returns data








// To calculate Historical volatility
sqrt<-(252)^0.5
histVolaitility<-sd(logreturns)*sqrt






Assignment 2 :

To create an acf plot for the log returns data calculated previously. Also do and adf test and interpret the findings.

Soln -:

// to create acf plot

acf(logReturns)






Grahical Interpreation

-  the blue dotted lines represent confidence interval for the hypothesis (95% in default case)
- As all the co-relations plots(vertical lines) lie inside those two blue dotted lines , we can safely suggest that the returns data is "Stationary" in nature. This is visual inspection method for determining stationarity.


Using ADF test
Command used
adf.test(logReturns)





Interpretation from ADF test
Null Hypothesis -: The returns data is not Stationary
Alternative Hypothesis -: Returns Data is stationary

As from the test results p-value = 0.01 which is less than 0.05 value as stated for 95%confidence interval.
Hence Null Hypothesis is rejected.

Results -: given data is stationary in nature

Thursday, 7 February 2013

Day 5 : 5th Feb 2013


We converted data into Time series and calculated returns

Assignment 1:
Find Returns of NSE data for > 6 months having selected the 10th data point as start and 95th data point as end
Also Plot the return
Data set : S&P CNX NIfty data from 1st july 2012 - 31st December 2012 ( 6 months)



Assignment 2 :

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