Wednesday, 23 January 2013

Assignment 3- session 3

Assignment 3

Assignment 3-1) Do an aggression analysis on data provided (mileage vs grooves)  and comment on the results derived.

sol:
> z<- read.csv(file.choose(),header=T)
> z
  mileage  grove
1       0 394.33
2       4 329.50
3       8 291.00
4      12 255.17
5      16 229.33
6      20 204.83
7      24 179.00
8      28 163.83
9      32 150.33

> x<-z$grove
> y<-z$mileage
> reg1<-lm(y~x)
> summary(reg1)

Call:
lm(formula = y ~ x)

Residuals:
    Min      1Q  Median      3Q     Max 
-2.5577 -1.8696 -0.8322  1.4912  3.7249 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) 47.94458    2.82389   16.98 6.03e-07 ***
x           -0.13084    0.01103  -11.86 6.87e-06 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 

Residual standard error: 2.549 on 7 degrees of freedom
Multiple R-squared: 0.9526,     Adjusted R-squared: 0.9458 
F-statistic: 140.7 on 1 and 7 DF,  p-value: 6.871e-06 

to plot the graph of the above regression
we use a function 
plot(x, res)
qqnorm(res)
qqline(res)




Comment: Since the residual plot is not scattered but shows a parabolic pattern, we can say that linearity is not applicable in this case.




ASSINMENT 3- 2:: Do the regression analysis on the data provided and comment on the applicability of regression 
The first picure is to retive data




The second graph is to plot the graph of the regression



This above screen shot is to show the residual values of the data





This is to plot the residual values of the data
plot(x, res)



The command used for this plot is as follows:
qqnorm(res)




this is a qq strightline plot:
qqline(res)



Comment:: As this is a random plot and satisfy linearity hence regression can be applied



Assignment 3-3:: To do the avova test and comment on the output


sol::
To retrieve the data
> z<- read.csv(file.choose(),header=T)
> z

   chair com chair1
1      1   2      a
2      1   3      a
3      1   5      a
4      1   3      a
5      1   2      a
6      1   3      a
7      2   5      b
8      2   4      b
9      2   5      b
10     2   4      b
11     2   1      b
12     2   3      b
13     3   3      c
14     3   4      c
15     3   4      c
16     3   5      c
17     3   1      c
18     3   2      c
> z.anova<- aov(z$com~z$chair1)
summary(z.annova)

then we get a plot ::

Conclusion:: assume that the significance level is 5% and confidence interval is 95% then, if p=.687 we can reject the null hypothesis which is all means are the same

Wednesday, 16 January 2013

Assignment -session 2 15/01/13

   Assignment-2


Assignment1:

a. Create two matrices
b. Select two columns
c. Use cbind to create a new matrix

solution:
a)  z<-c(19,10,15,100,32,56,28,29,91)
> dim(z)<-c(3,3)
> z
     [,1] [,2] [,3]
[1,]   19  100   28
[2,]   10   32   29
[3,]   15   56   91
> m<-c(1,2,3,4,4,5,5,6,6)
> dim(m)<-c(3,3)
> m
     [,1] [,2] [,3]
[1,]    1    4    5
[2,]    2    4    6
[3,]    3    5    6


b)
 x<- z[,3]
 y<-m[,3]


c) cbind(x,y)
      x y
[1,] 28 5
[2,] 29 6
[3,] 91 6



Assignment2

a. Multiply matrix1 and matrix2


solution:-

 mul<-z%*%m
> mul
     [,1] [,2] [,3]
[1,]  303  616  863
[2,]  161  313  416
[3,]  400  739  957





Assignment3

a.)Regression of NSE downloaded data 01/12/12-31/21/12

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


 high<- data[,3]
> high
 [1] 5899.15 5894.95 5917.80 5942.55 5949.85 5919.95 5965.15 5924.60 5907.45
[10] 5886.10 5886.05 5905.80 5939.40 5937.60 5888.00 5871.90 5917.30 5930.80
[19] 5915.75 5919.00

open<- data[,2]
open
 [1] 5878.25 5866.80 5906.60 5926.30 5934.00 5916.05 5923.80 5917.80 5900.35
[10] 5846.90 5860.50 5873.60 5917.30 5934.45 5888.00 5869.00 5864.95 5930.20
[19] 5887.15 5901.20

 ans<-cbind(open,high)
> ans
         open    high
 [1,] 5878.25 5899.15
 [2,] 5866.80 5894.95
 [3,] 5906.60 5917.80
 [4,] 5926.30 5942.55
 [5,] 5934.00 5949.85
 [6,] 5916.05 5919.95
 [7,] 5923.80 5965.15
 [8,] 5917.80 5924.60
 [9,] 5900.35 5907.45
[10,] 5846.90 5886.10
[11,] 5860.50 5886.05
[12,] 5873.60 5905.80
[13,] 5917.30 5939.40
[14,] 5934.45 5937.60
[15,] 5888.00 5888.00
[16,] 5869.00 5871.90
[17,] 5864.95 5917.30
[18,] 5930.20 5930.80
[19,] 5887.15 5915.75
[20,] 5901.20 5919.00
>  




 reg1<-lm(high~open,data=data)
 reg1

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

Coefficients:
(Intercept)         open  
  1578.3358       0.7355  







The regression Image is as follows







Assignment 4: Plotting a normal distribution for the data.

solution :-




Tuesday, 8 January 2013

IT lab assignment-session 1

                                                                              ASSIGNMENTS
Assignment:1 ::plot a line using the data using three points


Assignment:2) plot the histogram of the data


Assignments:3) plot the data with lines and dots with labels


Assignments:4)plot the scatter plot of the data




Assignment :5) range of the data