Assignment 1 : Usage of cbind
> a<-c(10,31,42,91,17,23,35,25,16)
> dim(a)<-c(3,3)
> a
[,1] [,2] [,3]
[1,] 10 91 35
[2,] 31 17 25
[3,] 42 23 16
> b<-c(1,3,4,9,11,3,5,21,11)
> dim(b)<-c(3,3)
> b
[,1] [,2] [,3]
[1,] 1 9 5
[2,] 3 11 21
[3,] 4 3 11
> cbind(a,b)
[,1] [,2] [,3] [,4] [,5] [,6]
[1,] 10 91 35 1 9 5
[2,] 31 17 25 3 11 21
[3,] 42 23 16 4 3 11
> cbind(a[3,],b[3,])
[,1] [,2]
[1,] 42 4
[2,] 23 3
[3,] 16 11
> cbind(a[,3],b[,3])
[,1] [,2]
[1,] 35 5
[2,] 25 21
[3,] 16 11
> cbind(a[,3],b[,1])
[,1] [,2]
[1,] 35 1
[2,] 25 3
[3,] 16 4
>
Assignment 2,3:
Plotting the regression Line,Residuals and getting the intercepts:
nse<-read.csv(file.choose(),header=T)
> nse
Date Open High Low Close Shares.Traded Turnover..Rs..Cr.
1 01-Oct-12 5704.75 5722.95 5694.00 5718.80 123138510 4798.17
2 03-Oct-12 5727.70 5743.25 5715.80 5731.25 165037864 6654.02
3 04-Oct-12 5751.55 5807.25 5751.35 5787.60 171404290 6954.74
4 05-Oct-12 5815.00 5815.35 4888.20 5746.95 255569804 12995.80
.
.
.
62 01-Jan-13 5937.65 5963.90 5935.20 5950.85 77902745 3298.74
63 02-Jan-13 5982.60 6006.05 5982.00 5993.25 116057389 4992.90
64 03-Jan-13 6015.80 6017.00 5986.55 6009.50 99989933 4883.13
65 04-Jan-13 6011.95 6020.75 5981.55 6016.15 113232990 5191.38
> high<-nse[,2]
> open<-nse[,3]
> regression<-lm(high~open,data=nse)
> plot(regression)
Waiting to confirm page change...
Waiting to confirm page change...
> regression<-lm(high~open,data=nse)
> regression
Call:
lm(formula = high ~ open, data = nse)
Coefficients:
(Intercept) open
-67.107 1.008
> regression<-lm(high~open)
> regression
Call:
lm(formula = high ~ open)
Coefficients:
(Intercept) open
-67.107 1.008
residuals(regression)
1 2 3 4 5 6
5.9196164 8.4171333 -32.2136015 23.0755554 23.9025346 3.5768010
7 8 9 10 11 12
9.0434099 -33.4664873 -19.1957821 4.8893273 15.7868442 21.1595596
13 14 15 16 17 18
-23.0770034 15.8041206 -29.8198675 18.9857661 -5.7988354 10.6630371
19 20 21 22 23 24
-8.7952256 -9.1821291 -2.7901270 -15.2305431 9.2571252 8.0728993
25 26 27 28 29 30
-12.6393487 -34.9886327 -11.5422560 3.3036613 -6.2999621 15.7551500
31 32 33 34 35 36
23.3551851 -0.6835477 9.6476114 16.0402458 -12.8085788 9.9675304
37 38 39 40 41 42
22.4595947 24.1235882 -50.6573763 -73.5107780 -26.3494972 1.8960932
43 44 45 46 47 48
-5.3223585 11.4560041 6.2200949 6.5652611 18.7398544 -19.0496646
49 50 51 52 53 54
15.8049260 15.6337479 -16.3058819 -2.6555063 -9.4538581 0.3937561
55 56 57 58 59 60
19.3572767 22.8798463 20.1007811 -29.6902402 21.9583548 -5.9285974
61 62 63 64 65
4.8469903 -3.9402752 -1.4568842 20.7108651 13.0826970
>




No comments:
Post a Comment