Thursday, 7 February 2013

ITBAL Session 4

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

SOLUTION:
commands:
z<-read.csv(file.choose(),header=T)         
close<-z$Close                                       
close
close.ts<-ts(close)                                 
close.ts
close.ts<-ts(close,deltat-1/252)               
z1<-ts(data=close.ts[10:95],frequency=1,deltat=1/252)
z1.ts<-ts(z1)
z1.ts
z1.diff<-diff(z1)
z1.diff
zlag<-lag(close.ts,k=-1)
returns<-cbind(z1.ts,z1.diff)
returns
returns<-z1.diff
plot(returns,main="returns from 10th to 95th data")
Pic1:
Pic2:


Pic3:
GRAPH 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:

Commands:
Readdata<-read.csv(file.choose(),header=T)
Readdata1<-Readdata[1:700,1:9]
Readdata1$ed<-factor(Readdata1$ed)
Readdata1.est<-glm(default~age+ed+employ+address+income+debtinc+creddebt+othdebt,data=Readdata1,family="binomial")
 summary(Readdata1.est)
Forecast<-Readdata[701:850,1:8]
Forecast$ed<-factor(Forecast$ed)
Forecast$prob<-predict(Readdata1.est,newdata=Forecast,type="response")
head(Forecast)
PIC1


PIC2



No comments:

Post a Comment