Wednesday, 13 February 2013

ITBAL Session # 6

Assignment 1 :

Create log of the return data ( using log (st-st-1)/(st-1)
Calculate Historical volatility
Create acf plot for log(returns ) data and adf and interpret. NSE nifty index(from jan2012 to 31 jan 2013)

> z<-read.csv(file.choose(),header=T)
> closingprice<-z$Close
> closingprice.ts<-ts(closingprice,frequency=252)
> laggingtable<-cbind(closingprice.ts,lag(closingprice.ts,k=-1),closingprice.ts-lag(closingprice.ts,k=-1))
> Return<-(closingprice.ts-lag(closingprice.ts,k=-1))/lag(closingprice.ts,k=-1)
> Manipulate<-scale(Return)+10
> logreturn<-log(Manipulate)
> acf(logreturn)






 

 
 
 
 
 
 
 
 
 
From the figure it can be observed that all the standard errors are within the 95% confidence interval and hence we can say that the time series is stationary.


>T<-252^.5
>Historicalvolatility<-sd(Return)*T
> Historicalvolatility
[1] 0.1475815
> adf.test(logreturn)


        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
Since p-value is less than (1-.95) ,we can say that null hypothesis is rejected and hence the time series is stationary so data analysis can be done.

Thursday, 7 February 2013

IT BAL LAB Session 5

 
 
 
 
 
 

ASSIGNMENT 2 :



Data 1-700 is available. Using GLM distribution & LOGIT analysis predict data for 701-850



Commands:



>logit.eg<-read.csv(file.choose(),header=T)

>z1<-logit.eg[1:700,1:9]

>head(z1)

>z1$ed<-factor(z1$ed)

>z1.est<-glm(default~age+ed+employee+address+income,data=z1,family="binomial)

>summary(z1.est)

>forecast<-logit.eg[701:850,1:8]

>forecast$ed<-factor(forecast$ed)

>forecast$probability<-predict(z1.est,newdata=forecast,type="response")

>head(forecast)



 
 
 
 
 

ITBAL Assignment, Session 5