The main objective of this analysis is to determine factors affecting petrol prices.
Following are the goals to achieve:
Find factors, Correlation, Importance
The dataset contains one response variable and six regressor variables. 84 observations data points of monthly data from April, 2014 to March, 2021 are available for these variables.
#Load library
library(caret)
## Loading required package: lattice
## Loading required package: ggplot2
library(tidyverse)
## ── Attaching packages ─────────────────────────────────────────────── tidyverse 1.3.0 ──
## ✓ tibble 3.0.3 ✓ dplyr 1.0.2
## ✓ tidyr 1.1.2 ✓ stringr 1.4.0
## ✓ readr 1.3.1 ✓ forcats 0.5.0
## ✓ purrr 0.3.4
## ── Conflicts ────────────────────────────────────────────────── tidyverse_conflicts() ──
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
## x purrr::lift() masks caret::lift()
library(olsrr)
##
## Attaching package: 'olsrr'
## The following object is masked from 'package:datasets':
##
## rivers
library(MASS)
##
## Attaching package: 'MASS'
## The following object is masked from 'package:olsrr':
##
## cement
## The following object is masked from 'package:dplyr':
##
## select
library(ROCR)
data <- read.csv("Petrol_Consumption_Dataset.csv")
head(data)
## Date Petrol.Price.per.litre.in.INR
## 1 4/1/2014 64.07333
## 2 5/1/2014 64.21833
## 3 6/1/2014 64.36333
## 4 7/1/2014 64.50833
## 5 8/1/2014 64.65333
## 6 9/1/2014 64.79833
## Consumption.of.petrol...000.Metric.Tonnes.
## 1 11008
## 2 12710
## 3 12827
## 4 14487
## 5 13487
## 6 13673
## Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## 1 10699
## 2 9742
## 3 11489
## 4 11441
## 5 9864
## 6 10651
## Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.
## 1 17988
## 2 17518
## 3 17564
## 4 17760
## 5 18291
## 6 17921
## Imports.of.petroleum.products.to.India...000.Metric.Tonnes.
## 1 17378
## 2 19098
## 3 19146
## 4 16861
## 5 17952
## 6 17637
## Exports.of.petroleum.products.from.India...000.Metric.Tonnes.
## 1 4656
## 2 4982
## 3 4049
## 4 3864
## 5 3766
## 6 4605
## Dollar.Rupee.exchange.rate..in.INR.
## 1 66
## 2 63
## 3 67
## 4 65
## 5 63
## 6 63
summary(data)
## Date Petrol.Price.per.litre.in.INR
## Length:84 Min. :64.07
## Class :character 1st Qu.:68.69
## Mode :character Median :80.28
## Mean :81.24
## 3rd Qu.:95.13
## Max. :98.98
## Consumption.of.petrol...000.Metric.Tonnes.
## Min. :10037
## 1st Qu.:13262
## Median :16103
## Mean :15225
## 3rd Qu.:16947
## Max. :17999
## Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## Min. : 9662
## 1st Qu.:11432
## Median :11952
## Mean :11951
## 3rd Qu.:12658
## Max. :13458
## Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.
## Min. :17518
## 1st Qu.:19301
## Median :20740
## Mean :20351
## 3rd Qu.:21427
## Max. :22299
## Imports.of.petroleum.products.to.India...000.Metric.Tonnes.
## Min. :16861
## 1st Qu.:19103
## Median :20815
## Mean :20653
## 3rd Qu.:22135
## Max. :24617
## Exports.of.petroleum.products.from.India...000.Metric.Tonnes.
## Min. :3766
## 1st Qu.:4898
## Median :5446
## Mean :5566
## 3rd Qu.:6367
## Max. :7235
## Dollar.Rupee.exchange.rate..in.INR.
## Min. :63.00
## 1st Qu.:64.00
## Median :66.00
## Mean :67.24
## 3rd Qu.:69.25
## Max. :77.00
str(data)
## 'data.frame': 84 obs. of 8 variables:
## $ Date : chr "4/1/2014" "5/1/2014" "6/1/2014" "7/1/2014" ...
## $ Petrol.Price.per.litre.in.INR : num 64.1 64.2 64.4 64.5 64.7 ...
## $ Consumption.of.petrol...000.Metric.Tonnes. : int 11008 12710 12827 14487 13487 13673 12170 11826 12526 11440 ...
## $ Production.of.petroleum.products.in.India...000.Metric.Tonnes.: int 10699 9742 11489 11441 9864 10651 9662 11101 11407 9738 ...
## $ Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. : int 17988 17518 17564 17760 18291 17921 18000 18341 18423 18262 ...
## $ Imports.of.petroleum.products.to.India...000.Metric.Tonnes. : int 17378 19098 19146 16861 17952 17637 19086 16918 18329 17005 ...
## $ Exports.of.petroleum.products.from.India...000.Metric.Tonnes. : int 4656 4982 4049 3864 3766 4605 4535 4248 4185 4725 ...
## $ Dollar.Rupee.exchange.rate..in.INR. : int 66 63 67 65 63 63 65 63 66 65 ...
Remove missing values
na.omit(data)
## Date Petrol.Price.per.litre.in.INR
## 1 4/1/2014 64.07333
## 2 5/1/2014 64.21833
## 3 6/1/2014 64.36333
## 4 7/1/2014 64.50833
## 5 8/1/2014 64.65333
## 6 9/1/2014 64.79833
## 7 10/1/2014 64.94333
## 8 11/1/2014 65.08833
## 9 12/1/2014 65.23333
## 10 1/1/2015 65.33000
## 11 2/1/2015 65.62000
## 12 3/1/2015 65.62000
## 13 4/1/2015 66.10000
## 14 5/1/2015 66.40000
## 15 6/1/2015 66.70000
## 16 7/1/2015 67.00000
## 17 8/1/2015 67.30000
## 18 9/1/2015 67.60000
## 19 10/1/2015 67.90000
## 20 11/1/2015 68.20000
## 21 12/1/2015 68.50000
## 22 1/1/2016 68.75000
## 23 2/1/2016 69.20000
## 24 3/1/2016 69.35000
## 25 4/1/2016 74.72000
## 26 5/1/2016 74.78500
## 27 6/1/2016 74.85000
## 28 7/1/2016 74.91500
## 29 8/1/2016 74.98000
## 30 9/1/2016 75.04500
## 31 10/1/2016 75.11000
## 32 11/1/2016 75.17500
## 33 12/1/2016 75.65000
## 34 1/1/2017 74.80000
## 35 2/1/2017 75.15000
## 36 3/1/2017 75.75000
## 37 4/1/2017 78.94400
## 38 5/1/2017 79.18700
## 39 6/1/2017 79.43000
## 40 7/1/2017 79.67300
## 41 8/1/2017 79.91600
## 42 9/1/2017 80.15900
## 43 10/1/2017 80.40200
## 44 11/1/2017 80.64500
## 45 12/1/2017 81.15000
## 46 1/1/2018 80.80000
## 47 2/1/2018 81.25000
## 48 3/1/2018 81.81000
## 49 4/1/2018 84.69667
## 50 5/1/2018 85.24667
## 51 6/1/2018 85.79667
## 52 7/1/2018 86.34667
## 53 8/1/2018 86.89667
## 54 9/1/2018 87.44667
## 55 10/1/2018 87.99667
## 56 11/1/2018 88.54667
## 57 12/1/2018 89.09667
## 58 1/1/2019 89.80000
## 59 2/1/2019 89.89000
## 60 3/1/2019 90.90000
## 61 4/1/2019 95.67000
## 62 5/1/2019 95.59000
## 63 6/1/2019 95.51000
## 64 7/1/2019 95.43000
## 65 8/1/2019 95.35000
## 66 9/1/2019 95.27000
## 67 10/1/2019 95.19000
## 68 11/1/2019 95.11000
## 69 12/1/2019 95.55000
## 70 1/1/2020 94.67000
## 71 2/1/2020 93.87000
## 72 3/1/2020 95.55000
## 73 4/1/2020 96.64200
## 74 5/1/2020 96.84100
## 75 6/1/2020 97.04000
## 76 7/1/2020 97.23900
## 77 8/1/2020 97.43800
## 78 9/1/2020 97.63700
## 79 10/1/2020 97.83600
## 80 11/1/2020 98.03500
## 81 12/1/2020 98.65000
## 82 1/1/2021 97.75000
## 83 2/1/2021 98.75000
## 84 3/1/2021 98.98000
## Consumption.of.petrol...000.Metric.Tonnes.
## 1 11008
## 2 12710
## 3 12827
## 4 14487
## 5 13487
## 6 13673
## 7 12170
## 8 11826
## 9 12526
## 10 11440
## 11 12818
## 12 14561
## 13 13323
## 14 12173
## 15 13616
## 16 13551
## 17 13153
## 18 13130
## 19 12295
## 20 12942
## 21 13464
## 22 12575
## 23 13510
## 24 12685
## 25 16129
## 26 16284
## 27 16781
## 28 15848
## 29 16297
## 30 15791
## 31 16939
## 32 14224
## 33 14784
## 34 16077
## 35 14669
## 36 16571
## 37 16310
## 38 16767
## 39 16409
## 40 16849
## 41 16148
## 42 16738
## 43 16150
## 44 16176
## 45 16733
## 46 16456
## 47 16817
## 48 16297
## 49 17052
## 50 17274
## 51 17397
## 52 17183
## 53 17674
## 54 17973
## 55 17841
## 56 17109
## 57 17999
## 58 17532
## 59 17367
## 60 17534
## 61 17752
## 62 16505
## 63 16503
## 64 17491
## 65 16319
## 66 17883
## 67 17469
## 68 17573
## 69 17312
## 70 16025
## 71 17125
## 72 13084
## 73 10037
## 74 12482
## 75 11902
## 76 13298
## 77 15557
## 78 15414
## 79 12103
## 80 15975
## 81 15781
## 82 17460
## 83 12780
## 84 16972
## Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## 1 10699
## 2 9742
## 3 11489
## 4 11441
## 5 9864
## 6 10651
## 7 9662
## 8 11101
## 9 11407
## 10 9738
## 11 10181
## 12 11470
## 13 11382
## 14 10629
## 15 10659
## 16 10569
## 17 10503
## 18 10858
## 19 11391
## 20 10878
## 21 10873
## 22 11183
## 23 11179
## 24 10708
## 25 12398
## 26 12360
## 27 11922
## 28 11772
## 29 12043
## 30 12283
## 31 11861
## 32 12392
## 33 11930
## 34 12249
## 35 12289
## 36 11956
## 37 11794
## 38 11719
## 39 11905
## 40 12125
## 41 12344
## 42 12096
## 43 12283
## 44 12289
## 45 11975
## 46 11989
## 47 11977
## 48 11778
## 49 13389
## 50 12502
## 51 12755
## 52 13342
## 53 12563
## 54 13008
## 55 13458
## 56 13355
## 57 12626
## 58 12937
## 59 12987
## 60 13305
## 61 13093
## 62 13069
## 63 12929
## 64 13016
## 65 12987
## 66 12823
## 67 13301
## 68 13134
## 69 13341
## 70 13058
## 71 12925
## 72 13360
## 73 11572
## 74 11874
## 75 11937
## 76 11947
## 77 12249
## 78 11917
## 79 11919
## 80 11940
## 81 11714
## 82 11685
## 83 12164
## 84 11678
## Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.
## 1 17988
## 2 17518
## 3 17564
## 4 17760
## 5 18291
## 6 17921
## 7 18000
## 8 18341
## 9 18423
## 10 18262
## 11 17897
## 12 18452
## 13 19323
## 14 19193
## 15 19173
## 16 18589
## 17 18637
## 18 19365
## 19 19202
## 20 18617
## 21 19236
## 22 19202
## 23 19410
## 24 18692
## 25 19999
## 26 20105
## 27 20396
## 28 19847
## 29 20400
## 30 19546
## 31 20092
## 32 19741
## 33 20371
## 34 19588
## 35 20458
## 36 20063
## 37 20724
## 38 20903
## 39 20855
## 40 20799
## 41 20856
## 42 20560
## 43 20793
## 44 20729
## 45 20749
## 46 20772
## 47 20822
## 48 20731
## 49 21767
## 50 21733
## 51 21641
## 52 21675
## 53 21851
## 54 21823
## 55 21681
## 56 21872
## 57 21969
## 58 21826
## 59 21847
## 60 21723
## 61 21371
## 62 21065
## 63 21844
## 64 21710
## 65 21293
## 66 21219
## 67 21146
## 68 21934
## 69 20878
## 70 21286
## 71 21212
## 72 21142
## 73 20547
## 74 21400
## 75 21874
## 76 21101
## 77 22299
## 78 21508
## 79 21921
## 80 21935
## 81 20510
## 82 21859
## 83 21080
## 84 20947
## Imports.of.petroleum.products.to.India...000.Metric.Tonnes.
## 1 17378
## 2 19098
## 3 19146
## 4 16861
## 5 17952
## 6 17637
## 7 19086
## 8 16918
## 9 18329
## 10 17005
## 11 18559
## 12 18393
## 13 19262
## 14 18328
## 15 18161
## 16 19105
## 17 20677
## 18 20172
## 19 17423
## 20 19693
## 21 18142
## 22 19993
## 23 20218
## 24 19488
## 25 22398
## 26 22069
## 27 20549
## 28 22032
## 29 20815
## 30 21005
## 31 21791
## 32 21120
## 33 19358
## 34 22169
## 35 18414
## 36 19376
## 37 21056
## 38 21817
## 39 23196
## 40 18581
## 41 20564
## 42 21694
## 43 20051
## 44 21006
## 45 21836
## 46 22124
## 47 22436
## 48 23516
## 49 19308
## 50 23192
## 51 22910
## 52 19311
## 53 19661
## 54 22381
## 55 22200
## 56 20805
## 57 22231
## 58 20815
## 59 21303
## 60 19915
## 61 20858
## 62 23573
## 63 23986
## 64 23620
## 65 24615
## 66 23108
## 67 21836
## 68 24171
## 69 24617
## 70 21688
## 71 23473
## 72 21189
## 73 17828
## 74 18864
## 75 21146
## 76 18049
## 77 20839
## 78 18335
## 79 23083
## 80 20968
## 81 20653
## 82 21688
## 83 22421
## 84 24236
## Exports.of.petroleum.products.from.India...000.Metric.Tonnes.
## 1 4656
## 2 4982
## 3 4049
## 4 3864
## 5 3766
## 6 4605
## 7 4535
## 8 4248
## 9 4185
## 10 4725
## 11 4879
## 12 4914
## 13 4828
## 14 3852
## 15 5480
## 16 4270
## 17 4679
## 18 3807
## 19 5610
## 20 5113
## 21 4904
## 22 5320
## 23 5038
## 24 3874
## 25 4882
## 26 4596
## 27 5372
## 28 5365
## 29 6111
## 30 6042
## 31 6156
## 32 5334
## 33 5325
## 34 5194
## 35 4556
## 36 6582
## 37 6908
## 38 6609
## 39 6631
## 40 5799
## 41 6347
## 42 5348
## 43 5915
## 44 6598
## 45 6445
## 46 6345
## 47 5340
## 48 6590
## 49 5379
## 50 5840
## 51 5744
## 52 5790
## 53 5327
## 54 6030
## 55 5047
## 56 4778
## 57 5413
## 58 4708
## 59 5039
## 60 5485
## 61 5255
## 62 5197
## 63 6264
## 64 5082
## 65 6155
## 66 5864
## 67 6559
## 68 6365
## 69 6374
## 70 6412
## 71 5593
## 72 6474
## 73 6598
## 74 7021
## 75 5891
## 76 6853
## 77 6498
## 78 6928
## 79 6982
## 80 7084
## 81 7235
## 82 5900
## 83 6713
## 84 7093
## Dollar.Rupee.exchange.rate..in.INR.
## 1 66
## 2 63
## 3 67
## 4 65
## 5 63
## 6 63
## 7 65
## 8 63
## 9 66
## 10 65
## 11 63
## 12 67
## 13 63
## 14 64
## 15 65
## 16 66
## 17 65
## 18 63
## 19 64
## 20 66
## 21 66
## 22 63
## 23 64
## 24 64
## 25 67
## 26 67
## 27 65
## 28 66
## 29 65
## 30 63
## 31 65
## 32 63
## 33 67
## 34 65
## 35 63
## 36 64
## 37 63
## 38 63
## 39 63
## 40 66
## 41 67
## 42 63
## 43 66
## 44 64
## 45 64
## 46 65
## 47 64
## 48 65
## 49 63
## 50 66
## 51 65
## 52 67
## 53 63
## 54 67
## 55 67
## 56 64
## 57 66
## 58 67
## 59 65
## 60 66
## 61 74
## 62 68
## 63 71
## 64 70
## 65 76
## 66 72
## 67 69
## 68 69
## 69 73
## 70 77
## 71 77
## 72 72
## 73 75
## 74 74
## 75 74
## 76 74
## 77 74
## 78 74
## 79 74
## 80 73
## 81 76
## 82 75
## 83 76
## 84 73
Change date variable
rdate <-as.Date(data$Date,"%m/%d/%y")
plot(data$Petrol.Price.per.litre.in.INR~rdate,type="l", col="red", axes=T)
plot(data)
datalm1 <- lm(data = data, data$Petrol.Price.per.litre.in.INR ~ data$Consumption.of.petrol...000.Metric.Tonnes.+data$Production.of.petroleum.products.in.India...000.Metric.Tonnes.+data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.+data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes.+data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes.+data$Dollar.Rupee.exchange.rate..in.INR.)
summary(datalm1)
##
## Call:
## lm(formula = data$Petrol.Price.per.litre.in.INR ~ data$Consumption.of.petrol...000.Metric.Tonnes. +
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. +
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. +
## data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes. +
## data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. +
## data$Dollar.Rupee.exchange.rate..in.INR., data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.0444 -2.1711 -0.2794 1.8816 8.6667
##
## Coefficients:
## Estimate
## (Intercept) -1.223e+02
## data$Consumption.of.petrol...000.Metric.Tonnes. -1.318e-04
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 9.359e-04
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 5.070e-03
## data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes. 2.410e-04
## data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. 1.146e-03
## data$Dollar.Rupee.exchange.rate..in.INR. 1.187e+00
## Std. Error
## (Intercept) 6.603e+00
## data$Consumption.of.petrol...000.Metric.Tonnes. 2.821e-04
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 6.915e-04
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 5.435e-04
## data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes. 2.354e-04
## data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. 5.101e-04
## data$Dollar.Rupee.exchange.rate..in.INR. 1.037e-01
## t value
## (Intercept) -18.515
## data$Consumption.of.petrol...000.Metric.Tonnes. -0.467
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 1.353
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 9.327
## data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes. 1.024
## data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. 2.246
## data$Dollar.Rupee.exchange.rate..in.INR. 11.448
## Pr(>|t|)
## (Intercept) < 2e-16
## data$Consumption.of.petrol...000.Metric.Tonnes. 0.6418
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 0.1799
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 2.81e-14
## data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes. 0.3091
## data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. 0.0275
## data$Dollar.Rupee.exchange.rate..in.INR. < 2e-16
##
## (Intercept) ***
## data$Consumption.of.petrol...000.Metric.Tonnes.
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. ***
## data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes.
## data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. *
## data$Dollar.Rupee.exchange.rate..in.INR. ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.019 on 77 degrees of freedom
## Multiple R-squared: 0.9418, Adjusted R-squared: 0.9373
## F-statistic: 207.8 on 6 and 77 DF, p-value: < 2.2e-16
We find based on p value that there are three significant variables Production.of.petroleum.products.in.OPEC…000.Metric.Tonnes., Exports.of.petroleum.products.from.India…000.Metric.Tonnes. and Dollar.Rupee.exchange.rate..in.INR.
Which means that price of petrol is largely dependent on these variables
datalm <- lm(data$Petrol.Price.per.litre.in.INR ~ data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. + data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.+data$Dollar.Rupee.exchange.rate..in.INR.)
summary(datalm)
##
## Call:
## lm(formula = data$Petrol.Price.per.litre.in.INR ~ data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. +
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. +
## data$Dollar.Rupee.exchange.rate..in.INR.)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.3861 -2.1213 -0.0187 1.9399 8.5991
##
## Coefficients:
## Estimate
## (Intercept) -1.280e+02
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 6.474e-04
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 5.673e-03
## data$Dollar.Rupee.exchange.rate..in.INR. 1.280e+00
## Std. Error
## (Intercept) 6.151e+00
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 6.202e-04
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 4.722e-04
## data$Dollar.Rupee.exchange.rate..in.INR. 9.048e-02
## t value
## (Intercept) -20.816
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 1.044
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 12.013
## data$Dollar.Rupee.exchange.rate..in.INR. 14.153
## Pr(>|t|)
## (Intercept) <2e-16
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 0.3
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. <2e-16
## data$Dollar.Rupee.exchange.rate..in.INR. <2e-16
##
## (Intercept) ***
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. ***
## data$Dollar.Rupee.exchange.rate..in.INR. ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.09 on 80 degrees of freedom
## Multiple R-squared: 0.9367, Adjusted R-squared: 0.9343
## F-statistic: 394.5 on 3 and 80 DF, p-value: < 2.2e-16
Here we observe that the variables significantly affecting petrol price are production of petroleum products in India, production of petroleum products in OPEC and Dollar Rupee exchange rate. The coefficient of determination, R2 is only 0.9367 and the adjusted R2 is 0.9343, which is too low to arrive at reliable conclusions.
par(mfrow=c(2,2))
plot(datalm)
We will try with logistic regression model
datalm2 <- lm(data = data, log(data$Petrol.Price.per.litre.in.INR)~data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. + data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.+data$Dollar.Rupee.exchange.rate..in.INR.)
summary(datalm2)
##
## Call:
## lm(formula = log(data$Petrol.Price.per.litre.in.INR) ~ data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. +
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. +
## data$Dollar.Rupee.exchange.rate..in.INR., data = data)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.058568 -0.026026 -0.001896 0.022888 0.098259
##
## Coefficients:
## Estimate
## (Intercept) 1.795e+00
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 1.068e-05
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 7.355e-05
## data$Dollar.Rupee.exchange.rate..in.INR. 1.438e-02
## Std. Error
## (Intercept) 7.319e-02
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 7.379e-06
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 5.618e-06
## data$Dollar.Rupee.exchange.rate..in.INR. 1.076e-03
## t value
## (Intercept) 24.529
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 1.447
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 13.092
## data$Dollar.Rupee.exchange.rate..in.INR. 13.356
## Pr(>|t|)
## (Intercept) <2e-16
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 0.152
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. <2e-16
## data$Dollar.Rupee.exchange.rate..in.INR. <2e-16
##
## (Intercept) ***
## data$Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. ***
## data$Dollar.Rupee.exchange.rate..in.INR. ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.03676 on 80 degrees of freedom
## Multiple R-squared: 0.942, Adjusted R-squared: 0.9398
## F-statistic: 433.3 on 3 and 80 DF, p-value: < 2.2e-16
par(mfrow=c(2,2))
plot(datalm2)
So we compared the adjusted R square of both the models above and found the Model with logistic regression is better model compared to without it.
shapiro.test(data$Petrol.Price.per.litre.in.INR)
##
## Shapiro-Wilk normality test
##
## data: data$Petrol.Price.per.litre.in.INR
## W = 0.89992, p-value = 7.729e-06
We find that p value is low hence we fail to reject Null hypothesis which is data is normal
PriceTrans <- BoxCoxTrans(data$Petrol.Price.per.litre.in.INR)
PriceTrans
## Box-Cox Transformation
##
## 84 data points used to estimate Lambda
##
## Input data summary:
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 64.07 68.69 80.28 81.24 95.13 98.98
##
## Largest/Smallest: 1.54
## Sample Skewness: 0.0388
##
## Estimated Lambda: 0.4
We see lambda is 0.4
PriceNew = predict(PriceTrans, data$Petrol.Price.per.litre.in.INR)
head(PriceNew)
## [1] 10.70112 10.71307 10.72499 10.73690 10.74879 10.76067
Integration of PriceNew into dataset
newdata <- cbind(data, PriceNew)
head(newdata)
## Date Petrol.Price.per.litre.in.INR
## 1 4/1/2014 64.07333
## 2 5/1/2014 64.21833
## 3 6/1/2014 64.36333
## 4 7/1/2014 64.50833
## 5 8/1/2014 64.65333
## 6 9/1/2014 64.79833
## Consumption.of.petrol...000.Metric.Tonnes.
## 1 11008
## 2 12710
## 3 12827
## 4 14487
## 5 13487
## 6 13673
## Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## 1 10699
## 2 9742
## 3 11489
## 4 11441
## 5 9864
## 6 10651
## Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.
## 1 17988
## 2 17518
## 3 17564
## 4 17760
## 5 18291
## 6 17921
## Imports.of.petroleum.products.to.India...000.Metric.Tonnes.
## 1 17378
## 2 19098
## 3 19146
## 4 16861
## 5 17952
## 6 17637
## Exports.of.petroleum.products.from.India...000.Metric.Tonnes.
## 1 4656
## 2 4982
## 3 4049
## 4 3864
## 5 3766
## 6 4605
## Dollar.Rupee.exchange.rate..in.INR. PriceNew
## 1 66 10.70112
## 2 63 10.71307
## 3 67 10.72499
## 4 65 10.73690
## 5 63 10.74879
## 6 63 10.76067
Re-do the regression model with Box-Cox transformed dependent variable and original regressors
datalm3 <- lm(newdata$PriceNew ~ newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes. + newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes.+newdata$Dollar.Rupee.exchange.rate..in.INR.)
summary(datalm3)
##
## Call:
## lm(formula = newdata$PriceNew ~ newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes. +
## newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. +
## newdata$Dollar.Rupee.exchange.rate..in.INR.)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.35731 -0.15430 -0.00241 0.13822 0.58748
##
## Coefficients:
## Estimate
## (Intercept) -3.012e+00
## newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 5.573e-05
## newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 4.177e-04
## newdata$Dollar.Rupee.exchange.rate..in.INR. 8.659e-02
## Std. Error
## (Intercept) 4.295e-01
## newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 4.331e-05
## newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 3.297e-05
## newdata$Dollar.Rupee.exchange.rate..in.INR. 6.318e-03
## t value
## (Intercept) -7.011
## newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 1.287
## newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 12.669
## newdata$Dollar.Rupee.exchange.rate..in.INR. 13.705
## Pr(>|t|)
## (Intercept) 6.75e-10
## newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 0.202
## newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. < 2e-16
## newdata$Dollar.Rupee.exchange.rate..in.INR. < 2e-16
##
## (Intercept) ***
## newdata$Production.of.petroleum.products.in.India...000.Metric.Tonnes.
## newdata$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. ***
## newdata$Dollar.Rupee.exchange.rate..in.INR. ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.2158 on 80 degrees of freedom
## Multiple R-squared: 0.9401, Adjusted R-squared: 0.9378
## F-statistic: 418.3 on 3 and 80 DF, p-value: < 2.2e-16
We see that the adjusted R-square doesnt change much when we run the regression with the transformed values
plot(datalm3, 2)
plot(datalm, 2)
Notice that the it is following the normal QQ plot indicating normal data distribution
par(mfrow=c(2,2))
acf(data$Petrol.Price.per.litre.in.INR);pacf(data$Petrol.Price.per.litre.in.INR)
We see from the ACF and PACF plot that data is correlated.
ols_vif_tol(datalm1)
## Variables Tolerance
## 1 data$Consumption.of.petrol...000.Metric.Tonnes. 0.3165399
## 2 data$Production.of.petroleum.products.in.India...000.Metric.Tonnes. 0.2556025
## 3 data$Production.of.petroleum.products.in.OPEC...000.Metric.Tonnes. 0.2109089
## 4 data$Imports.of.petroleum.products.to.India...000.Metric.Tonnes. 0.4903499
## 5 data$Exports.of.petroleum.products.from.India...000.Metric.Tonnes. 0.5080415
## 6 data$Dollar.Rupee.exchange.rate..in.INR. 0.5590611
## VIF
## 1 3.159159
## 2 3.912324
## 3 4.741383
## 4 2.039360
## 5 1.968343
## 6 1.788713
We dont observe any high VIF values compared to other variables, then we can say that our model is appropriate and can be considered as final model.