Thursday, 7 February 2013

Session5




ASSIGNMENT 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 and plot  that return


z<-read.csv(file.choose(),header=T)
> close<-z$Close[10:95]
> close.ts<-ts(close,deltat=1/252)
> close.ts
> summary(close.ts)
> z.diff<-diff(close.ts)
> z.diff
> returns<-cbind(close.ts,z.diff,lag(close.ts,k=-1))
> returns
> returns<-z.diff/lag(close.ts,k=-1)
> returns
> plot(returns)




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


Commands : 

> z<-read.csv(file.choose(),header=T)
> z.data<-z[1:700,1:9]
> z.data$ed<-factor(z.data$ed)
>logit.est<glm(default~age+employ+address+income+debtinc+creddebt+othdebt,data=z.data,family="binomial")
> summary(logit.est)
> confint.default(logit.est)
>logit.eg2<with(z[701:850,1:8],data.frame(age=age,employ=employ,address=address,income=income,debtinc=debtinc,creddebt=creddebt,othdebt=othdebt,ed=factor(1:3))
> logit.eg2$prob<-predict(logit.est,newdata=logit.eg2,type="response")
> head(logit.eg2)





No comments:

Post a Comment