Thursday, 7 February 2013

Session 5 - IT Business Application Lab



Assignment 1 -:

Creating a table with closing prices and the differences having start point at 10th data pt and end pt as 95th data point.

Soln -:

Command Used -:

NSEData<-read.csv(file.choose(),header=T) // read file with data from 1 Jul 2012 to 31 Jan 2013

head(NSEData) // to display first few columns

closeCol<-NSEData$Close // to retrieve "Close" column contents from data into closeCol object

closeCol.ts1<-ts(data=closeCol.ts1[10:95],deltat=1/252) // Create time-series objects for close data from element (1,10 to1,95)

summary(closeCol.ts1) // showing summary

closeCol.diff = diff(closeCol.ts1)  // Calculate difference between preceding and succeeding value

retVar = closeCol.diff/lag(closeCol.ts1 , k=-1) // calculating returns

retFinal = cbind(closeCol.ts1 , closeCal.diff , retVar)  // creating a table for data , difference and return






Plotting Graphs


Graph -:


graph between Data , difference and Return








Assignment 2 :

Data from S.no 1 to 700 is provided.  Provide predictions for data from S.No 701 to 850.
Use glm estimation and do LOGIT Analysis for the same.

Soln 2:

Command Used -:

fileData<-read.csv(file.choose(),header=T) // reading file

selData<-fileData[1:700 , 1:9] // getting first 700 rows of data

head(new)



// Identifying the factor and running the Logit regression
selData$ed <- factor(selData$ed) // ed column as factor
selData.est<-glm(default ~ age + ed + employ + address + income, data=selData, family ="binomial")
 summary(selData.est)

// predicting the values for data set 701-850
newData<-fileData[701:850,1:8]
newData$ed<-factor(newData$ed)
newData$prob<-predict(selData.est, newdata =newData, type = "response")
head(newData)





=====================================END===================================

No comments:

Post a Comment