Tuesday, 22 January 2013

Session#-3 -: 22nd Jan,2013


Assignment 1    (a) -Groove Milage Data

Fit ‘lm’ and comment on the applicability of ‘lm’
Plot1: Residual vs Independent curve
Plot2: Standard Residual vs independent curve



As the plot is parabolic, so we will not be able to do regression.

Assignment 1  (b) -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



As this is a random plot, thus we can have regression.

QQPlot :





 QQLine :





Assignment 2:  Justify Null Hypothesis using ANOVA




p value=0.687

Since p-value is greater than 5%, we cannot reject the null hypothesis. 


Tuesday, 15 January 2013

Session#2 : BIS LABS



Assignment1 :

       a)  Create two matrices.
       b)  Select the highlighted columns.
       c)  Use cbind to form a new matrix.
       
    
      a)  sol:
> 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


> z2<-c(32,5,15,48,10,18,1,12,23)
> dim(z2)<-c(3,3)

> z2
     [,1] [,2] [,3]
[1,]   32   48    1
[2,]    5   10   12
[3,]   15   18   23

 b) Sol:
 Now , declare a new matrix "x" using data from matrix z

> x<-z[,3]
> x
[1] 28 29 91

 Now , declare a new matrix "y" using data from matrix z2
> y<-z2[,1]

c) sol:
> z3<-cbind(x,y)

> z3
      x  y
[1,] 28 32
[2,] 29  5
[3,] 91 15





 Assignment 2Multiply matrix one and two

Matrix product:
> c<-z%*%z2
> c
     [,1] [,2] [,3]
[1,] 5436 1431 2729
[2,] 1885  718 1393
[3,] 3259 1727 3326
  Assignment 3: Conduct regression analysis with a data set.(NIFTY data for 30 days from Dec1, 2012 to 31Dec, 2012).

> file<-read.csv(file.choose(),header=T)
> file
          Date    Open    High     Low   Close Shares.Traded Turnover..Rs..Cr.
1  03-Dec-2012 2289.60 2318.45 2289.60 2315.55     221786151           1759.25
2  04-Dec-2012 2315.60 2339.05 2309.55 2332.05     224551900           1999.35
3  05-Dec-2012 2334.15 2356.45 2334.15 2343.85     219629641           1946.34
4  06-Dec-2012 2344.50 2372.60 2321.10 2369.60     268855325           2261.74
5  07-Dec-2012 2370.80 2389.15 2349.30 2360.10     241957780           2259.00
6  10-Dec-2012 2361.70 2380.10 2361.70 2377.95     186464425           1753.51
7  11-Dec-2012 2379.40 2396.65 2322.65 2350.85     230985012           2031.35
8  12-Dec-2012 2352.25 2372.40 2340.90 2361.85     206841389           2276.39
9  13-Dec-2012 2362.45 2378.05 2317.65 2323.15     185643436           1786.32
10 14-Dec-2012 2323.30 2350.50 2316.50 2347.85     170835163           1579.63
11 17-Dec-2012 2347.90 2366.90 2347.90 2363.65     154928478           1421.17
12 18-Dec-2012 2363.25 2390.30 2336.95 2388.25     235307767           2213.90
13 19-Dec-2012 2390.40 2404.95 2387.25 2391.65     204243540           1990.85
14 20-Dec-2012 2389.85 2393.40 2366.00 2379.35     205320093           2144.65
15 21-Dec-2012 2377.90 2377.90 2321.40 2325.35     191408422           1927.55
16 24-Dec-2012 2325.45 2338.95 2314.90 2327.45     133759632           1217.90
17 26-Dec-2012 2328.15 2352.80 2328.15 2345.10     133492652           1147.80
18 27-Dec-2012 2346.30 2358.45 2330.15 2334.00     295318340           2323.49
19 28-Dec-2012 2335.25 2359.30 2334.70 2357.25     132734158           1222.84
20 31-Dec-2012 2357.10 2374.85 2357.10 2369.50     125335527           1123.46
> reg1<-lm(High~open,data=file)
> reg1
lm(formula = High ~ open, data = file)
Coefficients:
(Intercept)         open 
 462.5541       0.8111 

> file<-read.csv(file.choose(),header=T)
> file
          Date    Open    High     Low   Close Shares.Traded Turnover..Rs..Cr.
1  01-Oct-2012 5704.75 5722.95 5694.00 5718.80     123138510           4798.17
2  03-Oct-2012 5727.70 5743.25 5715.80 5731.25     165037864           6654.02
3  04-Oct-2012 5751.55 5807.25 5751.35 5787.60     171404290           6954.74
4  05-Oct-2012 5815.00 5815.35 4888.20 5746.95     255569804          12995.80
5  08-Oct-2012 5751.85 5751.85 5666.20 5676.00     142319000           5853.56
6  09-Oct-2012 5708.15 5728.65 5677.90 5704.60     119300415           5047.01
7  10-Oct-2012 5671.15 5686.50 5647.05 5652.15     126294361           4564.39
8  11-Oct-2012 5663.50 5721.10 5636.95 5708.05     148283847           6542.71
9  12-Oct-2012 5681.70 5725.00 5659.35 5676.05     130076802           6475.30
10 15-Oct-2012 5674.25 5693.70 5651.05 5687.25      93693482           3962.97
11 16-Oct-2012 5705.60 5714.00 5635.60 5648.00     117415701           5043.30
12 17-Oct-2012 5681.10 5684.35 5633.90 5660.25     123974371           5259.46
13 18-Oct-2012 5675.30 5722.50 5650.55 5718.70     144097860           6264.78
14 19-Oct-2012 5703.30 5711.70 5660.00 5684.25     124262817           5410.95
15 22-Oct-2012 5667.60 5721.55 5658.05 5717.15     103372318           4994.75
16 23-Oct-2012 5715.65 5720.80 5681.45 5691.40      81501427           3803.50
17 25-Oct-2012 5688.80 5718.75 5685.70 5705.30     158343061           7359.34
18 26-Oct-2012 5683.55 5697.20 5641.75 5664.30     101663820           4718.97
19 29-Oct-2012 5665.20 5698.30 5645.10 5665.60      93555816           3953.86
20 30-Oct-2012 5656.35 5689.90 5589.90 5597.90     116678775           5550.86
21 31-Oct-2012 5596.75 5624.40 5583.05 5619.70     112075316           4918.55
22 01-Nov-2012 5609.85 5649.75 5601.95 5645.05     107393402           4633.11
23 02-Nov-2012 5696.35 5711.30 5682.55 5697.70     111162841           4924.33
24 05-Nov-2012 5693.05 5709.20 5679.50 5704.20      74829213           3236.08
25 06-Nov-2012 5694.10 5730.80 5693.65 5724.40     115018796           4677.92
26 07-Nov-2012 5718.60 5777.30 5711.40 5760.10     133740615           5242.18
27 08-Nov-2012 5709.00 5744.50 5693.95 5738.75     117590261           4883.90
28 09-Nov-2012 5731.10 5751.70 5677.75 5686.25      98763127           4833.64
29 12-Nov-2012 5688.45 5718.90 5665.75 5683.70      92702799           4082.62
30 13-Nov-2012 5689.70 5698.25 5660.35 5666.95      16516842            680.72
31 15-Nov-2012 5650.35 5651.65 5603.55 5631.00     133979470           5554.05
32 16-Nov-2012 5624.80 5650.15 5559.80 5574.05     121900570           4996.15
33 19-Nov-2012 5577.30 5592.75 5549.25 5571.40     106988015           4336.84
34 20-Nov-2012 5604.80 5613.70 5548.35 5571.55     107481297           4399.93
35 21-Nov-2012 5582.50 5620.20 5561.40 5614.80     105148728           4228.47
36 22-Nov-2012 5628.60 5643.35 5608.00 5627.75      94058612           3867.76
37 23-Nov-2012 5635.45 5637.75 5593.55 5626.60      85082220           3213.06
38 26-Nov-2012 5648.65 5649.20 5623.45 5635.90      79291426           3246.23
39 27-Nov-2012 5658.50 5733.20 5658.00 5727.45     134407735           5380.95
40 29-Nov-2012 5736.70 5833.50 5736.10 5825.00     207295475           9110.93
41 30-Nov-2012 5836.00 5885.25 5827.85 5879.85     257047977          10777.34
42 03-Dec-2012 5878.25 5899.15 5854.60 5870.95     113423350           4726.68
43 04-Dec-2012 5866.80 5894.95 5859.00 5889.25     131020191           4816.70
44 05-Dec-2012 5906.60 5917.80 5891.35 5900.50     139653957           5583.78
45 06-Dec-2012 5926.30 5942.55 5838.90 5930.90     140267080           5667.65
46 07-Dec-2012 5934.00 5949.85 5888.65 5907.40     127607078           5722.45
47 10-Dec-2012 5916.05 5919.95 5888.10 5908.90      95975757           4339.84
48 11-Dec-2012 5923.80 5965.15 5865.45 5898.80     137415161           6403.06
49 12-Dec-2012 5917.80 5924.60 5874.25 5888.00     132665649           6117.63
50 13-Dec-2012 5900.35 5907.45 5841.35 5851.50     136616335           5976.15
51 14-Dec-2012 5846.90 5886.10 5839.15 5879.60     115159830           5012.83
52 17-Dec-2012 5860.50 5886.05 5850.15 5857.90     109547002           4998.19
53 18-Dec-2012 5873.60 5905.80 5823.15 5896.80     148907334           6740.66
54 19-Dec-2012 5917.30 5939.40 5910.80 5929.60     149439204           6731.27
55 20-Dec-2012 5934.45 5937.60 5881.45 5916.40     123911218           5390.76
56 21-Dec-2012 5888.00 5888.00 5841.65 5847.70     141152911           5603.96
57 24-Dec-2012 5869.00 5871.90 5844.70 5855.75      85336999           3433.98
58 26-Dec-2012 5864.95 5917.30 5859.55 5905.60      83871326           3447.53
59 27-Dec-2012 5930.20 5930.80 5864.70 5870.10     139613235           5955.51
60 28-Dec-2012 5887.15 5915.75 5879.50 5908.35      89669021           3863.47
61 31-Dec-2012 5901.20 5919.00 5897.15 5905.10      64809641           3021.71
62 01-Jan-2013 5937.65 5963.90 5935.20 5950.85      77902745           3298.74
63 02-Jan-2013 5982.60 6006.05 5982.00 5993.25     116057389           4992.90
64 03-Jan-2013 6015.80 6017.00 5986.55 6009.50      99989933           4883.13
65 04-Jan-2013 6011.95 6020.75 5981.55 6016.15     113232990           5191.38
> open<-file[,2]
> High<-file[,3]
> Data<-cbind(open,High)
> Data
         open    High
 [1,] 5704.75 5722.95
 [2,] 5727.70 5743.25
 [3,] 5751.55 5807.25
 [4,] 5815.00 5815.35
 [5,] 5751.85 5751.85
 [6,] 5708.15 5728.65
 [7,] 5671.15 5686.50
 [8,] 5663.50 5721.10
 [9,] 5681.70 5725.00
[10,] 5674.25 5693.70
[11,] 5705.60 5714.00
[12,] 5681.10 5684.35
[13,] 5675.30 5722.50
[14,] 5703.30 5711.70
[15,] 5667.60 5721.55
[16,] 5715.65 5720.80
[17,] 5688.80 5718.75
[18,] 5683.55 5697.20
[19,] 5665.20 5698.30
[20,] 5656.35 5689.90
[21,] 5596.75 5624.40
[22,] 5609.85 5649.75
[23,] 5696.35 5711.30
[24,] 5693.05 5709.20
[25,] 5694.10 5730.80
[26,] 5718.60 5777.30
[27,] 5709.00 5744.50
[28,] 5731.10 5751.70
[29,] 5688.45 5718.90
[30,] 5689.70 5698.25
[31,] 5650.35 5651.65
[32,] 5624.80 5650.15
[33,] 5577.30 5592.75
[34,] 5604.80 5613.70
[35,] 5582.50 5620.20
[36,] 5628.60 5643.35
[37,] 5635.45 5637.75
[38,] 5648.65 5649.20
[39,] 5658.50 5733.20
[40,] 5736.70 5833.50
[41,] 5836.00 5885.25
[42,] 5878.25 5899.15
[43,] 5866.80 5894.95
[44,] 5906.60 5917.80
[45,] 5926.30 5942.55
[46,] 5934.00 5949.85
[47,] 5916.05 5919.95
[48,] 5923.80 5965.15
[49,] 5917.80 5924.60
[50,] 5900.35 5907.45
[51,] 5846.90 5886.10
[52,] 5860.50 5886.05
[53,] 5873.60 5905.80
[54,] 5917.30 5939.40
[55,] 5934.45 5937.60
[56,] 5888.00 5888.00
[57,] 5869.00 5871.90
[58,] 5864.95 5917.30
[59,] 5930.20 5930.80
[60,] 5887.15 5915.75
[61,] 5901.20 5919.00
[62,] 5937.65 5963.90
[63,] 5982.60 6006.05
[64,] 6015.80 6017.00
[65,] 6011.95 6020.75


> plot(Data)
  Assignment 4: To generate data for normal distribution and plot the distribution curve


> values<-rnorm(200,0,1)
> pden<-dnorm(values)
> values
  [1] -1.212658503  1.144412737 -0.076257883 -1.662723801  1.014397349
  [6]  0.298085249  0.690832528  0.081220209 -2.174915108 -0.387846953
 [11]  0.634259291  1.598308445  0.727160263 -0.338272441 -0.284610211
 [16] -1.299069158  0.157470853  0.210125273 -0.264202880 -0.388464144
 [21]  0.193014621  0.292243457 -2.205503648  0.544266037  1.185574716
 [26] -1.339446499  0.075737603 -0.698760186  1.572288320  0.329020815
 [31]  0.276460499 -0.537984405  0.378401719  0.676361023 -0.155897623
 [36] -1.131778456  1.356299711  0.995041134 -0.910172040 -1.761406632
 [41] -1.865450544 -1.695708100 -1.478140090 -0.526595367  0.720444943
 [46] -0.666523516 -2.539917155  0.020598579  1.973118387 -0.132048748
 [51]  0.562226518  0.321094517  0.566336873 -0.251379174  0.542427053
 [56] -0.674245418  0.227679916  0.942326287 -0.758402969  0.248632960
 [61] -0.742442987 -1.110226541 -0.495990762  0.377567613 -0.555267552
 [66] -0.709519328  0.641299635  0.568955919 -1.986334551  0.379948522
 [71] -1.144519327  0.738001745 -0.560330495 -0.368725706  1.154819933
 [76]  0.766115934  0.992143437  0.014509939 -0.979219755  0.627271773
 [81]  1.323852755 -0.386161074 -1.430092347 -0.428465970  1.086108328
 [86]  1.230540751 -0.226346816  0.311076874 -0.519889259  0.053055329
 [91]  0.263290862  1.714817225 -2.032008280 -0.908068722 -0.695804818
 [96]  0.385143492  0.527130243  0.331767802 -0.001809055 -0.639069707
[101] -1.381294124  0.624865455  0.546161264 -0.435410173  0.066997403
[106]  1.575355950  0.913508254 -0.669485113 -0.205003776 -0.181824476
[111] -2.041402385  0.302366038 -1.840515652  0.251437557 -0.376584514
[116] -0.534131653 -0.183747664  0.558964468  0.362134949  0.778956820
[121] -1.182019533 -1.471734444 -0.472484362 -0.792582124  0.191165666
[126]  0.607273957 -0.557886473 -0.760747944 -1.659017754  0.666088442
[131] -0.626927113  0.451030164 -1.700966938 -1.491511562  0.574410897
[136] -2.269773313 -0.228327727  1.259212984 -0.180174079 -0.322380430
[141]  0.788689685 -0.046116542 -0.543367125  0.793947727 -0.722587411
[146]  1.459673351 -0.947418258  0.357986938  0.507150608 -0.123667094
[151] -0.164765208  1.256389987  1.262174755  0.127171044 -1.638733630
[156] -0.214731594  0.451175336 -0.161854380  0.543049150  0.259825973
[161] -0.029524774  1.457667773 -0.686271605 -0.798777698  0.545540771
[166]  0.868119095 -0.881679059 -0.365765007  0.610286050  0.976887711
[171]  1.251709083 -1.125444610  1.666270364  0.169143452  0.460544164
[176]  0.528854950 -2.094457589 -0.192393227  0.709266338  0.337996968
[181] -0.034281920  0.670046751 -0.212690045  0.609973855  1.309954043
[186]  1.235052210 -0.076415711  0.934172220 -2.645418561 -0.835514307
[191]  1.299051379 -0.409748535 -1.161706295 -0.097863317 -0.793991394
[196]  0.770426701 -0.798517339 -0.439704910 -0.464795232  1.283117423
> plot(values,pden)