Tuesday, 22 January 2013

IT and Business Application lab : Assignment 3


Problem 1: Using Mileage-Groove data, fit 'lm' and 'comment on the applicability of 'lm'.
Solution:
Commands:
>test1<-read.csv(file.choose(),header=T)


> a<-test1$mileage
> b<-test1$groove
> reg1<- lm(a~b)
> reg1


> res_var<-resid(reg1)
> res_var


> plot(b,res_var)

> qqnorm(res_var)

>qqline(res_var)

Linear Regression is not applicable as can be seen from the graph

Problem 2:
a) Plot residual and standard residual of independent variable
Solution: 
Commands:
 > test2<-read.csv(file.choose(),header=T)

> a<-test2$Pluto
> b<-test2$alpha
> reg1<- lm(a~b)
> reg1


> res_var<-resid(reg1)
> sres<-rstandard(reg1)



B) Plot qqplot and add a qqline
Solution:
Commands:
> plot(b,res_var)
> qqnorm(res_var)


> qqline(res_var)

Problem 3: Justify null hypothesis using Anova
Solution:
Commands:
> anova1<-read.csv(file.choose(),header=T)
> anova2<-aov(anova1$Comfort_level~anova1$Chair)     

p value=0.687
Since p-value is greater than 5%, we can't reject the null hypothesis.
 











Tuesday, 15 January 2013

IT and Business Application lab : Assignment 2


Problem 1
a) Create two matrices
Solution:            
Command
> a<- c(1,2,3,4,5,6,7,8,9)
> b<- c(32,48,1,5,10,12,15,18,23)
> dim(a)<- c(3,3)
> dim(b)<- c(3,3)
> a
     [,1] [,2] [,3]
[1,]    1    4    7
[2,]    2    5    8
[3,]    3    6    9
> b
     [,1] [,2] [,3]
[1,]   32    5   15
[2,]   48   10   18
[3,]    1   12   23  
b) Select 3rd column from first matrix {a} and 1st column from second matrix {b}
Solution:
Command
> a1<-a[ ,3]
> a1
[1] 7 8 9
> b1<-b[ ,1]
> b1
[1] 32  48 1
c) Combine the two matrices
Solution:
Command
> combine<-cbind(a1,b1)
> combine
     a1 b1
[1,]  7 32
[2,]  8 48
[3,]  9 1

Problem 2: Find the product of two matrices
Solution:
Command
> multiple<- a%*%b
> multiple
     [,1] [,2] [,3]
[1,]  231  129  248
[2,]  312  156  304
[3,]  393  183  360

Problem 3: Find the regression using nifty data from 01 Dec 2012 to 31 Dec 2012 ?
Solution:
Command
> nifty<-read.csv(file.choose(),header=T)

> open<- nifty[ ,2]
> high<- nifty[ ,3]
> data<- cbind(open,high)
> reg1<-lm(high~open,data=nifty)
> reg1

Call:
lm(formula = high ~ open, data = nifty)

Coefficients:
(Intercept)        open
  1578.3358       0.7355


Problem 4: Generate and plot a normal distribution curve
Solution:
Command
> x<-seq(0,100)
> y<-dnorm(x,mean=50,sd=5)
> plot(x,y,type="l")

Tuesday, 8 January 2013

IT and Business Application lab : Assignment 1


Problem 1:
a) Create line plot of x, where x is a variable.
Solution:            
Command:          
> x<-c(1,2,3)
> plot(x,type="l")

b) Create histogram of NSE data extracted from 1st October 2012 to 4th January 2013.
Solution:            
Command:       
>z<-read.csv(file.choose(),header=T)
>zcol1<-z[ ,3]
> plot(zcol1,type="h")


Problem 2:
Plot both lines and points. Also name the plot, x axis and y axis
Command:
>plot(zcol1,type="b",main="NSEGraph",xlab="Time",ylab="nifty")


Problem 3:
Create scatter plot by selecting the low values.
Command:
> zcol4<- z[,4]
> plot(zcol1,zcol4)


Problem 4:
Find the volatility of data?