setwd("E:/Internship/Tasks/Week 3/Week 3, Day 3 (Wed)")
airline <-read.csv(paste("SixAirlinesDataV2.csv",sep=""))
View(airline)
table(airline$Airline,airline$Aircraft)
##
## AirBus Boeing
## AirFrance 36 38
## British 47 128
## Delta 12 34
## Jet 7 54
## Singapore 16 24
## Virgin 33 29
summary(airline)
## Airline Aircraft FlightDuration TravelMonth
## AirFrance: 74 AirBus:151 Min. : 1.250 Aug:127
## British :175 Boeing:307 1st Qu.: 4.260 Jul: 75
## Delta : 46 Median : 7.790 Oct:127
## Jet : 61 Mean : 7.578 Sep:129
## Singapore: 40 3rd Qu.:10.620
## Virgin : 62 Max. :14.660
## IsInternational SeatsEconomy SeatsPremium PitchEconomy
## Domestic : 40 Min. : 78.0 Min. : 8.00 Min. :30.00
## International:418 1st Qu.:133.0 1st Qu.:21.00 1st Qu.:31.00
## Median :185.0 Median :36.00 Median :31.00
## Mean :202.3 Mean :33.65 Mean :31.22
## 3rd Qu.:243.0 3rd Qu.:40.00 3rd Qu.:32.00
## Max. :389.0 Max. :66.00 Max. :33.00
## PitchPremium WidthEconomy WidthPremium PriceEconomy
## Min. :34.00 Min. :17.00 Min. :17.00 Min. : 65
## 1st Qu.:38.00 1st Qu.:18.00 1st Qu.:19.00 1st Qu.: 413
## Median :38.00 Median :18.00 Median :19.00 Median :1242
## Mean :37.91 Mean :17.84 Mean :19.47 Mean :1327
## 3rd Qu.:38.00 3rd Qu.:18.00 3rd Qu.:21.00 3rd Qu.:1909
## Max. :40.00 Max. :19.00 Max. :21.00 Max. :3593
## PricePremium PriceRelative SeatsTotal PitchDifference
## Min. : 86.0 Min. :0.0200 Min. : 98 Min. : 2.000
## 1st Qu.: 528.8 1st Qu.:0.1000 1st Qu.:166 1st Qu.: 6.000
## Median :1737.0 Median :0.3650 Median :227 Median : 7.000
## Mean :1845.3 Mean :0.4872 Mean :236 Mean : 6.688
## 3rd Qu.:2989.0 3rd Qu.:0.7400 3rd Qu.:279 3rd Qu.: 7.000
## Max. :7414.0 Max. :1.8900 Max. :441 Max. :10.000
## WidthDifference PercentPremiumSeats
## Min. :0.000 Min. : 4.71
## 1st Qu.:1.000 1st Qu.:12.28
## Median :1.000 Median :13.21
## Mean :1.633 Mean :14.65
## 3rd Qu.:3.000 3rd Qu.:15.36
## Max. :4.000 Max. :24.69
library("psych", lib.loc="~/R/win-library/3.4")
describe(airline)
## vars n mean sd median trimmed mad min
## Airline* 1 458 3.01 1.65 2.00 2.89 1.48 1.00
## Aircraft* 2 458 1.67 0.47 2.00 1.71 0.00 1.00
## FlightDuration 3 458 7.58 3.54 7.79 7.57 4.81 1.25
## TravelMonth* 4 458 2.56 1.17 3.00 2.58 1.48 1.00
## IsInternational* 5 458 1.91 0.28 2.00 2.00 0.00 1.00
## SeatsEconomy 6 458 202.31 76.37 185.00 194.64 85.99 78.00
## SeatsPremium 7 458 33.65 13.26 36.00 33.35 11.86 8.00
## PitchEconomy 8 458 31.22 0.66 31.00 31.26 0.00 30.00
## PitchPremium 9 458 37.91 1.31 38.00 38.05 0.00 34.00
## WidthEconomy 10 458 17.84 0.56 18.00 17.81 0.00 17.00
## WidthPremium 11 458 19.47 1.10 19.00 19.53 0.00 17.00
## PriceEconomy 12 458 1327.08 988.27 1242.00 1244.40 1159.39 65.00
## PricePremium 13 458 1845.26 1288.14 1737.00 1799.05 1845.84 86.00
## PriceRelative 14 458 0.49 0.45 0.36 0.42 0.41 0.02
## SeatsTotal 15 458 235.96 85.29 227.00 228.73 90.44 98.00
## PitchDifference 16 458 6.69 1.76 7.00 6.76 0.00 2.00
## WidthDifference 17 458 1.63 1.19 1.00 1.53 0.00 0.00
## PercentPremiumSeats 18 458 14.65 4.84 13.21 14.31 2.68 4.71
## max range skew kurtosis se
## Airline* 6.00 5.00 0.61 -0.95 0.08
## Aircraft* 2.00 1.00 -0.72 -1.48 0.02
## FlightDuration 14.66 13.41 -0.07 -1.12 0.17
## TravelMonth* 4.00 3.00 -0.14 -1.46 0.05
## IsInternational* 2.00 1.00 -2.91 6.50 0.01
## SeatsEconomy 389.00 311.00 0.72 -0.36 3.57
## SeatsPremium 66.00 58.00 0.23 -0.46 0.62
## PitchEconomy 33.00 3.00 -0.03 -0.35 0.03
## PitchPremium 40.00 6.00 -1.51 3.52 0.06
## WidthEconomy 19.00 2.00 -0.04 -0.08 0.03
## WidthPremium 21.00 4.00 -0.08 -0.31 0.05
## PriceEconomy 3593.00 3528.00 0.51 -0.88 46.18
## PricePremium 7414.00 7328.00 0.50 0.43 60.19
## PriceRelative 1.89 1.87 1.17 0.72 0.02
## SeatsTotal 441.00 343.00 0.70 -0.53 3.99
## PitchDifference 10.00 8.00 -0.54 1.78 0.08
## WidthDifference 4.00 4.00 0.84 -0.53 0.06
## PercentPremiumSeats 24.69 19.98 0.71 0.28 0.23
boxplot(airline$PriceEconomy,airline$PricePremium,horizontal=TRUE,main="Boxplot of PriceEconomy and PricePremium",xlab="Price", Ylab="Airline 1= Premium Airline 2 = Economy")
boxplot(airline$PriceRelative,ylim=c(0,1),main="Boxplot for PriceRelative")
boxplot(airline$PitchPremium,airline$PitchEconomy,main="Boxplot for Pitch of Premium & Economy ",ylim=c(30,45))
boxplot(airline$WidthPremium,airline$WidthEconomy,main="Boxplot for Width of Premium & Economy ",ylim=c(15,25))
boxplot(airline$SeatsTotal,airline$SeatsPremium,airline$SeatsEconomy,ylim=c(10,350),main="Number of Seats total then premium and then Economy")
table(airline$TravelMonth)
##
## Aug Jul Oct Sep
## 127 75 127 129
plot(airline$PriceEconomy~airline$PitchEconomy)
plot(airline$PriceEconomy~airline$WidthEconomy)
plot(airline$PricePremium~airline$PitchPremium)
plot(airline$PricePremium~airline$WidthPremium)
plot(airline$PricePremium~airline$PitchDifference)
plot(airline$PricePremium~airline$WidthDifference)
plot(airline$PriceRelative~airline$PitchDifference)
plot(airline$PriceRelative~airline$WidthDifference)
plot(airline$PriceRelative~airline$PriceEconomy)
plot(airline$PriceRelative~airline$PricePremium)
cor.test(airline[,"PriceEconomy"],airline[,"PitchEconomy"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PriceEconomy"] and airline[, "PitchEconomy"]
## t = 8.469, df = 456, p-value = 3.428e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.2867196 0.4452479
## sample estimates:
## cor
## 0.3686612
cor.test(airline[,"PriceEconomy"],airline[,"WidthEconomy"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PriceEconomy"] and airline[, "WidthEconomy"]
## t = 1.4552, df = 456, p-value = 0.1463
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.02378438 0.15862920
## sample estimates:
## cor
## 0.06799061
cor.test(airline[,"PricePremium"],airline[,"WidthPremium"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PricePremium"] and airline[, "WidthPremium"]
## t = 1.3699, df = 456, p-value = 0.1714
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.02776966 0.15473916
## sample estimates:
## cor
## 0.06402004
cor.test(airline[,"PricePremium"],airline[,"WidthDifference"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PricePremium"] and airline[, "WidthDifference"]
## t = -0.24585, df = 456, p-value = 0.8059
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.10303032 0.08019923
## sample estimates:
## cor
## -0.01151218
cor.test(airline[,"PricePremium"],airline[,"PercentPremiumSeats"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PricePremium"] and airline[, "PercentPremiumSeats"]
## t = 2.5024, df = 456, p-value = 0.01268
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.0250311 0.2058228
## sample estimates:
## cor
## 0.116391
cor.test(airline[,"PriceRelative"],airline[,"PriceEconomy"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PriceRelative"] and airline[, "PriceEconomy"]
## t = -6.4359, df = 456, p-value = 3.112e-10
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.3704004 -0.2022889
## sample estimates:
## cor
## -0.2885671
cor.test(airline[,"PriceRelative"],airline[,"PricePremium"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PriceRelative"] and airline[, "PricePremium"]
## t = 0.6804, df = 456, p-value = 0.4966
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## -0.05995522 0.12311410
## sample estimates:
## cor
## 0.03184654
cor.test(airline[,"PriceRelative"],airline[,"WidthDifference"])
##
## Pearson's product-moment correlation
##
## data: airline[, "PriceRelative"] and airline[, "WidthDifference"]
## t = 11.869, df = 456, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
## 0.4125388 0.5528218
## sample estimates:
## cor
## 0.4858024
fit <-lm(PricePremium ~ PitchPremium + WidthPremium + PitchDifference + WidthDifference + PercentPremiumSeats, data=airline)
summary(fit)
##
## Call:
## lm(formula = PricePremium ~ PitchPremium + WidthPremium + PitchDifference +
## WidthDifference + PercentPremiumSeats, data = airline)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2201.6 -1022.2 -152.9 864.2 6221.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -44382.86 4808.47 -9.230 < 2e-16 ***
## PitchPremium 1347.23 153.29 8.789 < 2e-16 ***
## WidthPremium 47.34 119.95 0.395 0.693
## PitchDifference -1070.29 122.10 -8.766 < 2e-16 ***
## WidthDifference 191.48 117.13 1.635 0.103
## PercentPremiumSeats 73.96 13.00 5.687 2.32e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1172 on 452 degrees of freedom
## Multiple R-squared: 0.181, Adjusted R-squared: 0.172
## F-statistic: 19.98 on 5 and 452 DF, p-value: < 2.2e-16
residuals(fit)
## 1 2 3 4 5
## 1488.085677 1488.085677 1488.085677 1488.085677 762.085677
## 6 7 8 9 10
## 762.085677 762.085677 760.085677 760.085677 752.085677
## 11 12 13 14 15
## 752.085677 752.085677 752.085677 419.085677 419.085677
## 16 17 18 19 20
## 419.085677 267.085677 267.085677 267.085677 -41.914323
## 21 22 23 24 25
## -41.914323 -41.914323 -45.914323 -45.914323 -45.914323
## 26 27 28 29 30
## -152.914323 -152.914323 -152.914323 -416.914323 -416.914323
## 31 32 33 34 35
## -416.914323 -472.914323 -472.914323 -472.914323 -472.914323
## 36 37 38 39 40
## -688.914323 -688.914323 -688.914323 -724.914323 -724.914323
## 41 42 43 44 45
## -724.914323 -724.914323 -919.914323 -919.914323 -919.914323
## 46 47 48 49 50
## -1023.914323 -1023.914323 -1023.914323 -1463.914323 -1463.914323
## 51 52 53 54 55
## -1463.914323 848.839620 784.839620 784.839620 784.839620
## 56 57 58 59 60
## 46.839620 46.839620 46.839620 -889.160380 -889.160380
## 61 62 63 64 65
## -1330.160380 715.945063 715.945063 715.945063 715.945063
## 66 67 68 69 70
## 443.945063 443.945063 443.945063 443.945063 -3.054937
## 71 72 73 74 75
## -3.054937 -3.054937 -1818.054937 -400.784063 -369.784063
## 76 77 78 79 80
## -330.784063 -336.784063 -342.784063 -167.784063 -209.784063
## 81 82 83 84 85
## 22.215937 1185.896929 1185.896929 1185.896929 1185.896929
## 86 87 88 89 90
## 752.896929 752.896929 752.896929 751.896929 -1287.242722
## 91 92 93 94 95
## -1287.242722 -1287.242722 -1287.242722 -1195.242722 -1195.242722
## 96 97 98 99 100
## -1195.242722 -1195.242722 -807.584307 2016.147587 2016.147587
## 101 102 103 104 105
## 2016.147587 2016.147587 1989.147587 1989.147587 1989.147587
## 106 107 108 109 110
## 1989.147587 1045.147587 1045.147587 1045.147587 87.147587
## 111 112 113 114 115
## 87.147587 87.147587 -1060.852413 -1104.852413 -1104.852413
## 116 117 118 119 120
## -1139.852413 -1150.852413 -1150.852413 -1198.852413 -1223.852413
## 121 122 123 124 125
## -1227.852413 -1227.852413 -1240.852413 -1261.852413 -1268.852413
## 126 127 128 129 130
## -1270.852413 -1283.852413 -1299.852413 -1308.852413 -1309.852413
## 131 132 133 134 135
## -1309.852413 -1312.852413 -1335.852413 -1345.852413 -1348.852413
## 136 137 138 139 140
## -1371.852413 -1371.852413 -1374.852413 -1381.852413 -1390.852413
## 141 142 143 144 145
## -1390.852413 -1405.852413 -1405.852413 -1405.852413 -1415.852413
## 146 147 148 149 150
## -1421.852413 -1447.852413 -1447.852413 -1449.852413 -1422.486614
## 151 152 153 154 155
## -1460.852413 -1146.900164 -1016.900164 -956.900164 -726.900164
## 156 157 158 159 160
## -380.349100 -380.349100 -380.349100 -380.349100 964.650900
## 161 162 163 164 165
## 964.650900 964.650900 964.650900 1513.348981 1513.348981
## 166 167 168 169 170
## 1513.348981 1513.348981 1019.650900 1019.650900 1019.650900
## 171 172 173 174 175
## 1019.650900 1509.650900 -289.349100 1698.348981 1698.348981
## 176 177 178 179 180
## 1698.348981 1698.348981 -534.349100 1540.650900 531.650900
## 181 182 183 184 185
## 531.650900 531.650900 531.650900 -289.349100 662.612520
## 186 187 188 189 190
## 662.612520 839.612520 839.612520 839.612520 662.612520
## 191 192 193 194 195
## 1056.612520 1056.612520 1056.612520 1056.612520 1071.612520
## 196 197 198 199 200
## 1071.612520 1071.612520 1071.612520 1583.612520 1583.612520
## 201 202 203 204 205
## 1583.612520 1614.612520 1614.612520 573.612520 573.612520
## 206 207 208 209 210
## 573.612520 573.612520 483.612520 -1331.387480 -1331.387480
## 211 212 213 214 215
## -1331.387480 -794.613276 -794.613276 -794.613276 453.386724
## 216 217 218 219 220
## 453.386724 453.386724 453.386724 453.386724 453.386724
## 221 222 223 224 225
## 453.386724 453.386724 401.386724 401.386724 401.386724
## 226 227 228 229 230
## 657.386724 657.386724 381.386724 381.386724 381.386724
## 231 232 233 234 235
## 516.386724 869.386724 869.386724 869.386724 869.386724
## 236 237 238 239 240
## 869.386724 869.386724 869.386724 869.386724 2144.093171
## 241 242 243 244 245
## 2144.093171 2144.093171 1862.093171 1862.093171 1862.093171
## 246 247 248 249 250
## 1835.093171 1835.093171 1835.093171 1835.093171 1734.093171
## 251 252 253 254 255
## 1734.093171 1734.093171 1660.093171 1660.093171 1660.093171
## 256 257 258 259 260
## 1660.093171 1107.093171 1107.093171 1107.093171 1058.093171
## 261 262 263 264 265
## 927.093171 927.093171 927.093171 913.093171 913.093171
## 266 267 268 269 270
## 913.093171 684.093171 501.093171 501.093171 501.093171
## 271 272 273 274 275
## 419.093171 419.093171 419.093171 419.093171 238.093171
## 276 277 278 279 280
## 185.093171 -165.906829 -165.906829 -452.906829 -527.906829
## 281 282 283 284 285
## -684.696294 -684.696294 -604.696294 -604.696294 -604.696294
## 286 287 288 289 290
## 468.998981 468.998981 468.998981 -554.696294 -554.696294
## 291 292 293 294 295
## -632.696294 478.998981 -649.696294 -649.696294 -2201.593284
## 296 297 298 299 300
## -870.635568 -697.635568 -2120.593284 -2120.593284 -341.696294
## 301 302 303 304 305
## -2004.593284 -743.635568 -743.635568 -703.696294 -1722.593284
## 306 307 308 309 310
## -620.635568 -647.696294 -1564.613276 -1564.613276 -1564.613276
## 311 312 313 314 315
## -1616.613276 -1616.613276 -1477.613276 -1474.613276 -834.468479
## 316 317 318 319 320
## -1053.468479 -1053.468479 -1097.468479 -558.468479 -558.468479
## 321 322 323 324 325
## -558.468479 -1149.468479 -1605.468479 -1605.468479 -921.468479
## 326 327 328 329 330
## -921.468479 -921.468479 -1098.468479 -1098.468479 -1098.468479
## 331 332 333 334 335
## -1886.468479 -1886.468479 -1886.468479 -1886.468479 -941.468479
## 336 337 338 339 340
## -941.468479 -941.468479 -941.468479 1391.178915 1391.178915
## 341 342 343 344 345
## 1391.178915 200.178915 482.178915 645.178915 645.178915
## 346 347 348 349 350
## 645.178915 586.178915 586.178915 586.178915 943.178915
## 351 352 353 354 355
## 943.178915 943.178915 943.178915 756.012774 756.012774
## 356 357 358 359 360
## 756.012774 756.012774 1008.178915 1008.178915 1008.178915
## 361 362 363 364 365
## 1133.012774 1133.012774 662.178915 662.178915 662.178915
## 366 367 368 369 370
## 662.178915 6221.423745 6221.423745 6221.423745 1277.423745
## 371 372 373 374 375
## 1277.423745 1277.423745 -40.576255 -339.576255 -339.576255
## 376 377 378 379 380
## -366.576255 -395.576255 -395.576255 -925.891511 -925.891511
## 381 382 383 384 385
## -925.891511 -1010.891511 -1010.891511 -888.891511 -874.891511
## 386 387 388 389 390
## -1090.891511 -1141.891511 -1141.891511 -1141.891511 -1180.891511
## 391 392 393 394 395
## -1180.891511 -1180.891511 -788.891511 -925.891511 -1090.891511
## 396 397 398 399 400
## -1090.891511 -788.891511 -1141.891511 -1180.891511 -1141.891511
## 401 402 403 404 405
## -1141.891511 -1141.891511 -1141.891511 -925.891511 -712.891511
## 406 407 408 409 410
## -702.188592 -702.188592 -702.188592 -702.188592 -1246.300891
## 411 412 413 414 415
## -1246.300891 -1246.300891 -1246.300891 -1246.300891 -1246.300891
## 416 417 418 419 420
## -1246.300891 -1246.300891 -1140.300891 -1140.300891 -1140.300891
## 421 422 423 424 425
## -1140.300891 -1140.300891 -1140.300891 -1140.300891 -1140.300891
## 426 427 428 429 430
## 1149.648555 1149.648555 641.648555 641.648555 1056.648555
## 431 432 433 434 435
## 1056.648555 1056.648555 948.648555 948.648555 948.648555
## 436 437 438 439 440
## 948.648555 1562.648555 1562.648555 1149.648555 -366.869428
## 441 442 443 444 445
## -514.869428 -514.869428 -481.869428 -481.869428 -481.869428
## 446 447 448 449 450
## -481.869428 -366.869428 -428.869428 -607.869428 -607.869428
## 451 452 453 454 455
## -607.869428 -428.869428 -460.869428 -447.869428 -361.869428
## 456 457 458
## -361.869428 -215.869428 -342.869428
plot(fit)
## The above model is not suiting very appropropiately because residuals are quite significant but main significatnt variable from this model by p-values are PitchEconomy,PitchDiffernce and PercentPremiumSeats
fit <-lm(PricePremium ~ PitchPremium + PitchDifference + PercentPremiumSeats, data=airline)
summary(fit)
##
## Call:
## lm(formula = PricePremium ~ PitchPremium + PitchDifference +
## PercentPremiumSeats, data = airline)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2075.3 -1005.8 -106.7 852.6 5981.5
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -41543.46 4746.87 -8.752 < 2e-16 ***
## PitchPremium 1280.67 141.20 9.070 < 2e-16 ***
## PitchDifference -905.53 104.13 -8.696 < 2e-16 ***
## PercentPremiumSeats 61.42 11.95 5.142 4.06e-07 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1181 on 454 degrees of freedom
## Multiple R-squared: 0.1649, Adjusted R-squared: 0.1594
## F-statistic: 29.88 on 3 and 454 DF, p-value: < 2.2e-16
residuals(fit)
## 1 2 3 4 5
## 1425.304500 1425.304500 1425.304500 1425.304500 699.304500
## 6 7 8 9 10
## 699.304500 699.304500 697.304500 697.304500 689.304500
## 11 12 13 14 15
## 689.304500 689.304500 689.304500 356.304500 356.304500
## 16 17 18 19 20
## 356.304500 204.304500 204.304500 204.304500 -104.695500
## 21 22 23 24 25
## -104.695500 -104.695500 -108.695500 -108.695500 -108.695500
## 26 27 28 29 30
## -215.695500 -215.695500 -215.695500 -479.695500 -479.695500
## 31 32 33 34 35
## -479.695500 -535.695500 -535.695500 -535.695500 -535.695500
## 36 37 38 39 40
## -751.695500 -751.695500 -751.695500 -787.695500 -787.695500
## 41 42 43 44 45
## -787.695500 -787.695500 -982.695500 -982.695500 -982.695500
## 46 47 48 49 50
## -1086.695500 -1086.695500 -1086.695500 -1526.695500 -1526.695500
## 51 52 53 54 55
## -1526.695500 771.007628 707.007628 707.007628 707.007628
## 56 57 58 59 60
## -30.992372 -30.992372 -30.992372 -966.992372 -966.992372
## 61 62 63 64 65
## -1407.992372 1079.509328 1079.509328 1079.509328 1079.509328
## 66 67 68 69 70
## 807.509328 807.509328 807.509328 807.509328 360.509328
## 71 72 73 74 75
## 360.509328 360.509328 -1454.490672 -363.262633 -332.262633
## 76 77 78 79 80
## -293.262633 -299.262633 -305.262633 -130.262633 -172.262633
## 81 82 83 84 85
## 59.737367 1048.363369 1048.363369 1048.363369 1048.363369
## 86 87 88 89 90
## 615.363369 615.363369 615.363369 614.363369 -1140.146805
## 91 92 93 94 95
## -1140.146805 -1140.146805 -1140.146805 -1048.146805 -1048.146805
## 96 97 98 99 100
## -1048.146805 -1048.146805 -702.185671 1836.346320 1836.346320
## 101 102 103 104 105
## 1836.346320 1836.346320 1809.346320 1809.346320 1809.346320
## 106 107 108 109 110
## 1809.346320 865.346320 865.346320 865.346320 -92.653680
## 111 112 113 114 115
## -92.653680 -92.653680 -1240.653680 -1284.653680 -1284.653680
## 116 117 118 119 120
## -1319.653680 -1330.653680 -1330.653680 -1378.653680 -1403.653680
## 121 122 123 124 125
## -1407.653680 -1407.653680 -1420.653680 -1441.653680 -1448.653680
## 126 127 128 129 130
## -1450.653680 -1463.653680 -1479.653680 -1488.653680 -1489.653680
## 131 132 133 134 135
## -1489.653680 -1492.653680 -1515.653680 -1525.653680 -1528.653680
## 136 137 138 139 140
## -1551.653680 -1551.653680 -1554.653680 -1561.653680 -1570.653680
## 141 142 143 144 145
## -1570.653680 -1585.653680 -1585.653680 -1585.653680 -1595.653680
## 146 147 148 149 150
## -1601.653680 -1627.653680 -1627.653680 -1629.653680 -1606.928549
## 151 152 153 154 155
## -1640.653680 -1116.943489 -986.943489 -926.943489 -696.943489
## 156 157 158 159 160
## -86.771127 -86.771127 -86.771127 -86.771127 1258.228873
## 161 162 163 164 165
## 1258.228873 1258.228873 1258.228873 1806.299836 1806.299836
## 166 167 168 169 170
## 1806.299836 1806.299836 1313.228873 1313.228873 1313.228873
## 171 172 173 174 175
## 1313.228873 1803.228873 4.228873 1991.299836 1991.299836
## 176 177 178 179 180
## 1991.299836 1991.299836 -240.771127 1834.228873 825.228873
## 181 182 183 184 185
## 825.228873 825.228873 825.228873 4.228873 943.648146
## 186 187 188 189 190
## 943.648146 1120.648146 1120.648146 1120.648146 943.648146
## 191 192 193 194 195
## 1337.648146 1337.648146 1337.648146 1337.648146 1352.648146
## 196 197 198 199 200
## 1352.648146 1352.648146 1352.648146 1864.648146 1864.648146
## 201 202 203 204 205
## 1864.648146 1895.648146 1895.648146 854.648146 854.648146
## 206 207 208 209 210
## 854.648146 854.648146 764.648146 -1050.351854 -1050.351854
## 211 212 213 214 215
## -1050.351854 -845.523726 -845.523726 -845.523726 402.476274
## 216 217 218 219 220
## 402.476274 402.476274 402.476274 402.476274 402.476274
## 221 222 223 224 225
## 402.476274 402.476274 350.476274 350.476274 350.476274
## 226 227 228 229 230
## 606.476274 606.476274 330.476274 330.476274 330.476274
## 231 232 233 234 235
## 465.476274 818.476274 818.476274 818.476274 818.476274
## 236 237 238 239 240
## 818.476274 818.476274 818.476274 818.476274 1933.437732
## 241 242 243 244 245
## 1933.437732 1933.437732 1651.437732 1651.437732 1651.437732
## 246 247 248 249 250
## 1624.437732 1624.437732 1624.437732 1624.437732 1523.437732
## 251 252 253 254 255
## 1523.437732 1523.437732 1449.437732 1449.437732 1449.437732
## 256 257 258 259 260
## 1449.437732 896.437732 896.437732 896.437732 847.437732
## 261 262 263 264 265
## 716.437732 716.437732 716.437732 702.437732 702.437732
## 266 267 268 269 270
## 702.437732 473.437732 290.437732 290.437732 290.437732
## 271 272 273 274 275
## 208.437732 208.437732 208.437732 208.437732 27.437732
## 276 277 278 279 280
## -25.562268 -376.562268 -376.562268 -663.562268 -738.562268
## 281 282 283 284 285
## -628.965349 -628.965349 -548.965349 -548.965349 -548.965349
## 286 287 288 289 290
## 367.869676 367.869676 367.869676 -498.965349 -498.965349
## 291 292 293 294 295
## -576.965349 377.869676 -593.965349 -593.965349 -2075.288277
## 296 297 298 299 300
## -808.131756 -635.131756 -1994.288277 -1994.288277 -285.965349
## 301 302 303 304 305
## -1878.288277 -681.131756 -681.131756 -647.965349 -1596.288277
## 306 307 308 309 310
## -558.131756 -591.965349 -1615.523726 -1615.523726 -1615.523726
## 311 312 313 314 315
## -1667.523726 -1667.523726 -1528.523726 -1525.523726 -829.131410
## 316 317 318 319 320
## -1048.131410 -1048.131410 -1092.131410 -553.131410 -553.131410
## 321 322 323 324 325
## -553.131410 -1144.131410 -1600.131410 -1600.131410 -916.131410
## 326 327 328 329 330
## -916.131410 -916.131410 -1093.131410 -1093.131410 -1093.131410
## 331 332 333 334 335
## -1881.131410 -1881.131410 -1881.131410 -1881.131410 -936.131410
## 336 337 338 339 340
## -936.131410 -936.131410 -936.131410 1528.988514 1528.988514
## 341 342 343 344 345
## 1528.988514 337.988514 619.988514 782.988514 782.988514
## 346 347 348 349 350
## 782.988514 723.988514 723.988514 723.988514 1080.988514
## 351 352 353 354 355
## 1080.988514 1080.988514 1080.988514 891.815598 891.815598
## 356 357 358 359 360
## 891.815598 891.815598 1145.988514 1145.988514 1145.988514
## 361 362 363 364 365
## 1268.815598 1268.815598 799.988514 799.988514 799.988514
## 366 367 368 369 370
## 799.988514 5981.544639 5981.544639 5981.544639 1037.544639
## 371 372 373 374 375
## 1037.544639 1037.544639 -280.455361 -579.455361 -579.455361
## 376 377 378 379 380
## -606.455361 -635.455361 -635.455361 -847.025958 -847.025958
## 381 382 383 384 385
## -847.025958 -932.025958 -932.025958 -810.025958 -796.025958
## 386 387 388 389 390
## -1012.025958 -1063.025958 -1063.025958 -1063.025958 -1102.025958
## 391 392 393 394 395
## -1102.025958 -1102.025958 -710.025958 -847.025958 -1012.025958
## 396 397 398 399 400
## -1012.025958 -710.025958 -1063.025958 -1102.025958 -1063.025958
## 401 402 403 404 405
## -1063.025958 -1063.025958 -1063.025958 -847.025958 -634.025958
## 406 407 408 409 410
## -592.975543 -592.975543 -592.975543 -592.975543 -1284.234917
## 411 412 413 414 415
## -1284.234917 -1284.234917 -1284.234917 -1284.234917 -1284.234917
## 416 417 418 419 420
## -1284.234917 -1284.234917 -1178.234917 -1178.234917 -1178.234917
## 421 422 423 424 425
## -1178.234917 -1178.234917 -1178.234917 -1178.234917 -1178.234917
## 426 427 428 429 430
## 1053.585658 1053.585658 545.585658 545.585658 960.585658
## 431 432 433 434 435
## 960.585658 960.585658 852.585658 852.585658 852.585658
## 436 437 438 439 440
## 852.585658 1466.585658 1466.585658 1053.585658 -372.288442
## 441 442 443 444 445
## -520.288442 -520.288442 -487.288442 -487.288442 -487.288442
## 446 447 448 449 450
## -487.288442 -372.288442 -434.288442 -613.288442 -613.288442
## 451 452 453 454 455
## -613.288442 -434.288442 -466.288442 -453.288442 -367.288442
## 456 457 458
## -367.288442 -221.288442 -348.288442
plot(fit)
fit <-lm(PriceRelative ~ PitchPremium + WidthPremium + PitchDifference, data=airline)
summary(fit)
##
## Call:
## lm(formula = PriceRelative ~ PitchPremium + WidthPremium + PitchDifference,
## data = airline)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.79298 -0.27258 -0.09128 0.15439 1.33742
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.70237 1.46917 1.159 0.24717
## PitchPremium -0.13686 0.04421 -3.096 0.00208 **
## WidthPremium 0.15466 0.02529 6.115 2.09e-09 ***
## PitchDifference 0.14370 0.03355 4.283 2.25e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3818 on 454 degrees of freedom
## Multiple R-squared: 0.2866, Adjusted R-squared: 0.2819
## F-statistic: 60.8 on 3 and 454 DF, p-value: < 2.2e-16
residuals(fit)
## 1 2 3 4 5
## -0.0662804656 -0.0662804656 -0.0662804656 -0.0662804656 0.2237195344
## 6 7 8 9 10
## 0.2237195344 0.2237195344 0.5837195344 0.5837195344 0.3037195344
## 11 12 13 14 15
## 0.3037195344 0.1137195344 -0.1862804656 0.0737195344 0.0737195344
## 16 17 18 19 20
## 0.0737195344 -0.0662804656 -0.0662804656 -0.0662804656 -0.1062804656
## 21 22 23 24 25
## -0.1062804656 -0.1062804656 -0.1162804656 -0.1162804656 -0.1162804656
## 26 27 28 29 30
## -0.0962804656 -0.1162804656 -0.1162804656 -0.1062804656 -0.1062804656
## 31 32 33 34 35
## -0.1062804656 -0.0262804656 -0.0262804656 -0.0262804656 -0.0262804656
## 36 37 38 39 40
## 0.2037195344 0.2037195344 0.2037195344 -0.2062804656 -0.2062804656
## 41 42 43 44 45
## -0.2062804656 -0.2062804656 -0.2762804656 -0.2762804656 -0.2762804656
## 46 47 48 49 50
## -0.3662804656 -0.3662804656 -0.3662804656 0.0737195344 0.0737195344
## 51 52 53 54 55
## 0.0737195344 0.5837195344 -0.0862804656 -0.0862804656 -0.0862804656
## 56 57 58 59 60
## -0.1062804656 -0.1062804656 -0.1062804656 -0.2362804656 -0.2362804656
## 61 62 63 64 65
## 0.1637195344 -0.0256079909 -0.0256079909 -0.0256079909 -0.0256079909
## 66 67 68 69 70
## -0.3656079909 -0.3656079909 -0.3656079909 -0.3656079909 -0.4956079909
## 71 72 73 74 75
## -0.4956079909 -0.4956079909 -0.6556079909 -0.1742579619 -0.1842579619
## 76 77 78 79 80
## -0.1942579619 -0.1942579619 -0.1942579619 -0.2242579619 -0.2242579619
## 81 82 83 84 85
## -0.2342579619 0.6237195344 0.6237195344 0.6237195344 0.6237195344
## 86 87 88 89 90
## -0.0462804656 -0.0462804656 -0.0462804656 -0.0462804656 -0.4329845566
## 91 92 93 94 95
## -0.4329845566 -0.4329845566 -0.4329845566 -0.5829845566 -0.5829845566
## 96 97 98 99 100
## -0.5829845566 -0.6529845566 0.1241029959 0.0437195344 0.0437195344
## 101 102 103 104 105
## 0.0437195344 0.0437195344 0.4637195344 0.4637195344 0.4637195344
## 106 107 108 109 110
## 0.4637195344 0.0237195344 0.0237195344 0.0237195344 0.8237195344
## 111 112 113 114 115
## 0.8237195344 -0.0862804656 -0.3862804656 -0.3462804656 -0.3462804656
## 116 117 118 119 120
## -0.4062804656 -0.3362804656 -0.3362804656 -0.3662804656 -0.3562804656
## 121 122 123 124 125
## -0.3962804656 -0.3962804656 -0.3362804656 -0.3062804656 -0.2762804656
## 126 127 128 129 130
## -0.2862804656 -0.2962804656 -0.3762804656 -0.2762804656 -0.2662804656
## 131 132 133 134 135
## -0.3062804656 -0.3162804656 -0.2862804656 -0.2662804656 -0.2662804656
## 136 137 138 139 140
## -0.1962804656 -0.2462804656 -0.1862804656 -0.2562804656 -0.2162804656
## 141 142 143 144 145
## -0.2162804656 -0.1462804656 -0.1462804656 -0.1462804656 -0.1962804656
## 146 147 148 149 150
## -0.1562804656 -0.1562804656 -0.1562804656 -0.0462804656 -0.1362804656
## 151 152 153 154 155
## -0.1162804656 0.0025995480 -0.0274004520 -0.0374004520 -0.0674004520
## 156 157 158 159 160
## 1.0643920091 1.0643920091 1.0643920091 1.0643920091 0.9743920091
## 161 162 163 164 165
## 0.9743920091 0.9743920091 0.6243920091 0.2143920091 0.2143920091
## 166 167 168 169 170
## 0.2143920091 0.2143920091 0.1543920091 0.1543920091 0.1543920091
## 171 172 173 174 175
## 0.1543920091 0.0843920091 -0.1956079909 -0.2456079909 -0.2456079909
## 176 177 178 179 180
## -0.2456079909 -0.2456079909 -0.2556079909 -0.2656079909 -0.3556079909
## 181 182 183 184 185
## -0.3556079909 -0.3556079909 -0.3556079909 -0.4956079909 -0.2956079909
## 186 187 188 189 190
## -0.2956079909 -0.3756079909 -0.3756079909 -0.3756079909 -0.4556079909
## 191 192 193 194 195
## 0.3243920091 0.3243920091 0.3243920091 0.3243920091 0.2743920091
## 196 197 198 199 200
## 0.2743920091 0.2743920091 0.2743920091 0.0843920091 0.0843920091
## 201 202 203 204 205
## 0.0843920091 -0.2656079909 -0.2656079909 -0.3456079909 -0.3456079909
## 206 207 208 209 210
## -0.3456079909 -0.3456079909 -0.4956079909 -0.6556079909 -0.6556079909
## 211 212 213 214 215
## -0.6556079909 1.2574167295 0.8674167295 0.3274167295 -0.2225832705
## 216 217 218 219 220
## -0.2225832705 -0.2225832705 -0.2225832705 -0.2225832705 -0.2225832705
## 221 222 223 224 225
## -0.2225832705 -0.2225832705 -0.2225832705 -0.2225832705 -0.2225832705
## 226 227 228 229 230
## -0.2325832705 -0.2325832705 -0.2325832705 -0.2325832705 -0.2325832705
## 231 232 233 234 235
## -0.2625832705 -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705
## 236 237 238 239 240
## -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705 0.6837195344
## 241 242 243 244 245
## 0.6837195344 -0.1862804656 0.0037195344 0.0037195344 0.0037195344
## 246 247 248 249 250
## -0.0862804656 -0.0862804656 -0.0862804656 -0.0862804656 0.5337195344
## 251 252 253 254 255
## 0.5337195344 0.5337195344 -0.1162804656 -0.1162804656 -0.1162804656
## 256 257 258 259 260
## -0.1162804656 -0.0862804656 -0.0862804656 -0.0862804656 0.6837195344
## 261 262 263 264 265
## -0.0262804656 -0.0262804656 -0.0262804656 -0.0462804656 -0.0462804656
## 266 267 268 269 270
## -0.0462804656 0.3537195344 -0.3762804656 -0.3762804656 -0.3762804656
## 271 272 273 274 275
## 0.6637195344 0.6637195344 0.4637195344 -0.2462804656 0.3537195344
## 276 277 278 279 280
## -0.2762804656 -0.2762804656 -0.2762804656 -0.2362804656 0.1237195344
## 281 282 283 284 285
## 0.1741029959 0.1741029959 0.1541029959 0.1541029959 0.1541029959
## 286 287 288 289 290
## 0.0004058007 0.0004058007 0.0004058007 0.1441029959 0.1441029959
## 291 292 293 294 295
## 0.1441029959 -0.0095941993 0.1341029959 0.1341029959 0.2609605058
## 296 297 298 299 300
## 0.1241029959 0.1141029959 0.2509605058 0.2509605058 0.1041029959
## 301 302 303 304 305
## 0.2409605058 0.0841029959 0.0841029959 0.0841029959 0.2109605058
## 306 307 308 309 310
## 0.0741029959 0.0741029959 1.1974167295 0.6574167295 0.5174167295
## 311 312 313 314 315
## 0.1174167295 0.1174167295 0.0974167295 0.0774167295 0.6527529669
## 316 317 318 319 320
## 0.3727529669 0.3727529669 0.3127529669 0.1427529669 0.1427529669
## 321 322 323 324 325
## 0.1427529669 0.0927529669 0.0227529669 0.0227529669 -0.3272470331
## 326 327 328 329 330
## -0.3272470331 -0.3272470331 -0.3272470331 -0.3272470331 -0.3272470331
## 331 332 333 334 335
## -0.3572470331 -0.3572470331 -0.3572470331 -0.3572470331 -0.3672470331
## 336 337 338 339 340
## -0.3672470331 -0.3672470331 -0.3672470331 0.0574167295 0.0574167295
## 341 342 343 344 345
## 0.0574167295 -0.2225832705 -0.2325832705 -0.2325832705 -0.2325832705
## 346 347 348 349 350
## -0.2325832705 -0.2625832705 -0.2625832705 -0.2625832705 -0.2725832705
## 351 352 353 354 355
## -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705
## 356 357 358 359 360
## -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705
## 361 362 363 364 365
## -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705 -0.2725832705
## 366 367 368 369 370
## -0.2725832705 0.9437195344 0.9437195344 0.9437195344 -0.3062804656
## 371 372 373 374 375
## -0.3062804656 -0.3062804656 0.3237195344 0.0337195344 0.0337195344
## 376 377 378 379 380
## -0.4062804656 0.0737195344 -0.0762804656 0.9770154434 0.9770154434
## 381 382 383 384 385
## 0.9770154434 0.9570154434 0.7570154434 0.7270154434 0.6170154434
## 386 387 388 389 390
## 0.3770154434 0.3470154434 0.3470154434 0.3470154434 0.1970154434
## 391 392 393 394 395
## 0.1970154434 0.1970154434 0.1770154434 0.1470154434 0.1270154434
## 396 397 398 399 400
## 0.1270154434 -0.0029845566 -0.1029845566 -0.1229845566 -0.1729845566
## 401 402 403 404 405
## -0.1729845566 -0.1729845566 -0.1729845566 -0.4129845566 -0.7429845566
## 406 407 408 409 410
## 1.3374167295 1.3374167295 1.1374167295 0.2574167295 0.5327529669
## 411 412 413 414 415
## 0.5327529669 0.5327529669 0.5327529669 0.5327529669 0.5327529669
## 416 417 418 419 420
## 0.5327529669 0.5327529669 0.1527529669 0.1527529669 0.1527529669
## 421 422 423 424 425
## 0.1527529669 0.1527529669 0.1527529669 0.1527529669 0.1527529669
## 426 427 428 429 430
## 0.8574167295 0.8574167295 -0.2225832705 -0.2225832705 -0.2325832705
## 431 432 433 434 435
## -0.2325832705 -0.2325832705 -0.2625832705 -0.2625832705 -0.2625832705
## 436 437 438 439 440
## -0.2625832705 -0.2725832705 -0.2725832705 -0.2825832705 0.7970154434
## 441 442 443 444 445
## 0.7670154434 0.7670154434 0.3870154434 0.3870154434 0.3870154434
## 446 447 448 449 450
## 0.3870154434 0.3070154434 0.1570154434 -0.1429845566 -0.1429845566
## 451 452 453 454 455
## -0.1429845566 -0.2629845566 -0.3129845566 -0.3329845566 -0.4629845566
## 456 457 458
## -0.4629845566 -0.5329845566 -0.7929845566
plot(fit)
## The value of residuals have decreased in magnitudes but still residuals are quite significant so model cant be relied much but this is the best we could find