Tuesday, 22 January 2013

ITBA Lab session 3


ASSIGNMENT 1:

1. Fit 'lm' and comment on mileage-groove data  and Pluto- Alpha data applicability.



a) For groove-mileage

Commands

z<-read.csv(file.choose(),header=T)

z

x<-z$groove

y<-z$mileage

reg1<-lm(y~x)

summary(reg1)

res<-resid(reg1)

res

plot(x,res)

sres<-rstandard(reg1)

sres

plot(x,sres)

qqnorm(res)

qqline(res)



Assignment 2 -Alpha-Pluto Data

Fit ‘lm’ and comment on the applicability of ‘lm’.

Plot1: Residual vs Independent curve.

Plot2: Standard Residual vs independent curve.

Also do:

Qq plot

Qqline

> file<-read.csv(file.choose(),header=T)

> file

   alpha pluto

1  0.150    20

2  0.004     0

3  0.069    10

4  0.030     5

5  0.011     0

6  0.004     0

7  0.041     5

8  0.109    20

9  0.068    10

10 0.009     0

11 0.009     0

12 0.048    10

13 0.006     0

14 0.083    20

15 0.037     5

16 0.039     5

17 0.132    20

18 0.004     0

19 0.006     0

20 0.059    10

21 0.051    10

22 0.002     0

23 0.049     5

> x<-file$alpha

> y<-file$pluto

> x

 [1] 0.150 0.004 0.069 0.030 0.011 0.004 0.041 0.109 0.068 0.009 0.009 0.048

[13] 0.006 0.083 0.037 0.039 0.132 0.004 0.006 0.059 0.051 0.002 0.049

> y

 [1] 20  0 10  5  0  0  5 20 10  0  0 10  0 20  5  5 20  0  0 10 10  0  5

> reg1<-lm(y~x)

> res<-resid(reg1)

> res

         1          2          3          4          5          6          7

-4.2173758 -0.0643108 -0.8173877  0.6344584 -1.2223345 -0.0643108 -1.1852930

         8          9         10         11         12         13         14

 2.5653342 -0.6519557 -0.8914706 -0.8914706  2.6566833 -0.3951747  6.8665650

        15         16         17         18         19         20         21

-0.5235652 -0.8544291 -1.2396007 -0.0643108 -0.3951747  0.8369318  2.1603874

        22         23

 0.2665531 -2.5087486

> plot(x,res)
> qqnorm(res)
   > qqline(res)

Assignment 3 : Justify Null Hypothesis using ANOVA

> file<-read.csv(file.choose(),header=T)

> file



   Chair Comfort.Level Chair1

1      I             2      a

2      I             3      a

3      I             5      a

4      I             3      a

5      I             2      a

6      I             3      a

7     II             5      b

8     II             4      b

9     II             5      b

10    II             4      b

11    II             1      b

12    II             3      b

13   III             3      c

14   III             4      c

15   III             4      c

16   III             5      c

17   III             1      c

18   III             2      c

> file.anova<-aov(file$Comfort.Level~file$Chair1)

> summary(file.anova)



            Df Sum Sq Mean Sq F value Pr(>F)

file$Chair1  2  1.444  0.7222   0.385  0.687

Conclusion: P Value  = 0.687



Since, the p - value is high, we cannot reject the null hypothesis. Thus we can say that all the types of chairs are not different.

Tuesday, 15 January 2013

ITBA Lab session 2

Assignment 1:
The objective is to create two 3 x 3 matrices and select 1 column of matrix 1 and another column  of matrix 2 finally merging  them into another matrix using cbind command.

Command :-

z1<-c(1,2,3,4,5,6,7,8,9)

dim(z1)<-c(3,3)

z2<-c(32,48,01,05,10,12,15,18,23)

dim(z2)<-c(3,3)

x<-z1[,3]

y<-z2[,1]

z3<-cbind(x,y)

Assignment 2:

Multiplication of matrix 1 and 2.

Command :-

mul<-z1%*%z2

mul


 


Assignment 3:

The objective is to read historical data of indices from NSE site from Dec 1 2012 to Dec 31 2012 and finding out the regression and residuals.
 To read NSE file 
 
Command :-
nse<-read.csv(file.choose(),header=T)
reg<-lm(high~open,data=nse)
To find residuals
residuals(reg)

Assignment 4:
The objective is to generate a normal distribution data and plot it.
 
Command :-
x=seq(70,130,length=200)
y=dnorm(x,mean=100,sd=10)
plot(x,y)
 
 


 


 

Tuesday, 8 January 2013

Analysis using "R" , ITBA Lab session 1

  For anylsis and plotting  the NSE data between  1st October 2012 & 8th January 2013 has been used.

 

Assignment 1: Plotting Histogram

Code
>x<-c(1,2,3)
>plot(x,type="h")

Histogram Plot



Assignment 2: Plotting point and line diagram 


Code:

>zcol3<-z[,3]
>plot(zcol3,type="b",main="NSE Graph",xlab="Time",ylab="Trend")
Point and Line Plot:

Assignment 3: Scatter Diagram for High and Low data

Code:
zcol4<-z[,4]
plot(zcol3,zcol4,type="b",main="NSE Graph",xlab="High",ylab="Low")
Scatter Diagram:

Assignment 4: Volatility of Max and Min of share value

Code:
>zcol3<-z[,3]
>zcol4<-z[,4]
mergeddata<-c(zcol3,zcol4)
> summary(mergeddata)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max.
   4888    5660    5723    5758    5884    6021
> range(mergeddata)
[1] 4888.20 6020.75