Thursday, 7 February 2013

IT LAB : ASSIGNMENT 5


Assignment 1:


 The Data set is downloaded from  CNX Mid-cap Index downloaded from NSE from August 2012-January 2013. The data should be read in such a manner that start data is the 10th reading and the end data is the 95th reading. 

Syntax:

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

>returns<- z.diff/lag(close.time,k= -1)
>plot(returns)




Assignment 2:


Predicting the new data by doing an estimation(regression) with already available data from 1-700.

Syntax:


> z<-read.csv(file.choose(),header=T)
> z1<-z[1:700,1:9]
> head(z1)
> z1$ed<-factor(z1$ed)
> z1.est<-glm(default ~ age + ed + employ + address + income, data=z1, family ="binomial")
> summary(z1.est)
> forecast<-z[701:850,1:8]
> forecast$ed<-factor(forecast$ed)
> forecast$probability<-predict(z1.est,newdata=forecast,type="response")
> head(forecast)






No comments:

Post a Comment