setwd("C:/Users/Taiyyab Ali/Desktop/R language")
Airlines <- read.csv(paste("SixAirlinesDataV2.csv",sep=""))
#View(Airlines)
str(Airlines)
## 'data.frame': 458 obs. of 18 variables:
## $ Airline : Factor w/ 6 levels "AirFrance","British",..: 2 2 2 2 2 2 2 2 2 2 ...
## $ Aircraft : Factor w/ 2 levels "AirBus","Boeing": 2 2 2 2 2 2 2 2 2 2 ...
## $ FlightDuration : num 12.25 12.25 12.25 12.25 8.16 ...
## $ TravelMonth : Factor w/ 4 levels "Aug","Jul","Oct",..: 2 1 4 3 1 4 3 1 4 4 ...
## $ IsInternational : Factor w/ 2 levels "Domestic","International": 2 2 2 2 2 2 2 2 2 2 ...
## $ SeatsEconomy : int 122 122 122 122 122 122 122 122 122 122 ...
## $ SeatsPremium : int 40 40 40 40 40 40 40 40 40 40 ...
## $ PitchEconomy : int 31 31 31 31 31 31 31 31 31 31 ...
## $ PitchPremium : int 38 38 38 38 38 38 38 38 38 38 ...
## $ WidthEconomy : int 18 18 18 18 18 18 18 18 18 18 ...
## $ WidthPremium : int 19 19 19 19 19 19 19 19 19 19 ...
## $ PriceEconomy : int 2707 2707 2707 2707 1793 1793 1793 1476 1476 1705 ...
## $ PricePremium : int 3725 3725 3725 3725 2999 2999 2999 2997 2997 2989 ...
## $ PriceRelative : num 0.38 0.38 0.38 0.38 0.67 0.67 0.67 1.03 1.03 0.75 ...
## $ SeatsTotal : int 162 162 162 162 162 162 162 162 162 162 ...
## $ PitchDifference : int 7 7 7 7 7 7 7 7 7 7 ...
## $ WidthDifference : int 1 1 1 1 1 1 1 1 1 1 ...
## $ PercentPremiumSeats: num 24.7 24.7 24.7 24.7 24.7 ...
summary(Airlines)
## 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
dim(Airlines)
## [1] 458 18
library(psych)
describe(Airlines[ ,c(3,6:18)])[c(3,4,5,7,8,9)]
## mean sd median mad min max
## FlightDuration 7.58 3.54 7.79 4.81 1.25 14.66
## SeatsEconomy 202.31 76.37 185.00 85.99 78.00 389.00
## SeatsPremium 33.65 13.26 36.00 11.86 8.00 66.00
## PitchEconomy 31.22 0.66 31.00 0.00 30.00 33.00
## PitchPremium 37.91 1.31 38.00 0.00 34.00 40.00
## WidthEconomy 17.84 0.56 18.00 0.00 17.00 19.00
## WidthPremium 19.47 1.10 19.00 0.00 17.00 21.00
## PriceEconomy 1327.08 988.27 1242.00 1159.39 65.00 3593.00
## PricePremium 1845.26 1288.14 1737.00 1845.84 86.00 7414.00
## PriceRelative 0.49 0.45 0.36 0.41 0.02 1.89
## SeatsTotal 235.96 85.29 227.00 90.44 98.00 441.00
## PitchDifference 6.69 1.76 7.00 0.00 2.00 10.00
## WidthDifference 1.63 1.19 1.00 0.00 0.00 4.00
## PercentPremiumSeats 14.65 4.84 13.21 2.68 4.71 24.69
count<-table(Airlines$Airline)
count
##
## AirFrance British Delta Jet Singapore Virgin
## 74 175 46 61 40 62
plot(count)
set<-table(Airlines$Aircraft,Airlines$Airline)
set
##
## AirFrance British Delta Jet Singapore Virgin
## AirBus 36 47 12 7 16 33
## Boeing 38 128 34 54 24 29
library(RColorBrewer)
myColors <- brewer.pal(6,"Set1")
plot(set,color=myColors)
mytable1<-table(Airlines$FlightDuration)
plot(mytable1)
boxplot(Airlines$FlightDuration,horizontal=TRUE,main = "Flight Duration's distribution")
table(Airlines$TravelMonth)
##
## Aug Jul Oct Sep
## 127 75 127 129
plot(Airlines$TravelMonth,col= "lightblue",main = "Frequecy of flights in travel months")
mytable2<-xtabs(~IsInternational+Airline,data=Airlines)
addmargins(mytable2)
## Airline
## IsInternational AirFrance British Delta Jet Singapore Virgin Sum
## Domestic 0 0 40 0 0 0 40
## International 74 175 6 61 40 62 418
## Sum 74 175 46 61 40 62 458
boxplot(Airlines$SeatsEconomy,horizontal = TRUE,main = "no. of economy class seat distribution")
Inside box, maximum no of seats in economy class are 122 with 51 airline and outside the box maximum seat in economy class are 303 with 52 airline.
mytable3<-table(Airlines$SeatsPremium)
plot(mytable3,col="red",xlab = "unique no. of seats in airlines",ylab = "frequecy in data",main = "Premium economy seat distribution")
boxplot(Airlines$SeatsPremium,horizontal = TRUE)
mytable4 <- table(Airlines$PitchEconomy,Airlines$Airline)
addmargins(mytable4)
##
## AirFrance British Delta Jet Singapore Virgin Sum
## 30 0 0 0 54 0 0 54
## 31 0 175 18 0 0 62 255
## 32 74 0 23 7 40 0 144
## 33 0 0 5 0 0 0 5
## Sum 74 175 46 61 40 62 458
library(lattice)
histogram(~PitchEconomy|Airline,data = Airlines,type = "count")
mytable4 <- xtabs(~Airline+PitchPremium,data = Airlines)
addmargins(mytable4)
## PitchPremium
## Airline 34 35 38 40 Sum
## AirFrance 0 0 74 0 74
## British 0 0 175 0 175
## Delta 31 9 6 0 46
## Jet 0 0 7 54 61
## Singapore 0 0 40 0 40
## Virgin 0 0 62 0 62
## Sum 31 9 364 54 458
library(lattice)
histogram(~PitchPremium|Airline,data = Airlines,type = "count")
table(Airlines$WidthEconomy)
##
## 17 18 19
## 114 304 40
median(Airlines$WidthEconomy)
## [1] 18
library(lattice)
histogram(~WidthEconomy|Airline,data = Airlines,type = "count")
table(Airlines$WidthPremium)
##
## 17 18 19 20 21
## 28 12 256 40 122
median(Airlines$WidthPremium)
## [1] 19
histogram(~WidthPremium|Airline, data = Airlines)
boxplot(Airlines$PriceEconomy,horizontal = TRUE, xlab = "Price of economy class",main = "distribution of price in economy class")
boxplot(PriceEconomy~Airline, data = Airlines,horizontal = TRUE,col= c("red","blue","yellow"), yaxt="n",xlab = "Price in USD", main= "Airline-wise Economy class-price distribution")
axis(side=2,at=c(1:6),labels = c("Aif","Bts","Delt","Jet","Sigp","Vg"))
boxplot(Airlines$PricePremium,horizontal = TRUE, xlab = "Price of Premiumeconomy class",main = "distribution of price in Premiumeconomy class")
boxplot(PricePremium~Airline, data = Airlines,horizontal = TRUE,col= c("red","blue","yellow"), yaxt="n",xlab = "Price in USD", main= "Airline-wise PremiumEconomy class-price distribution")
axis(side=2,at=c(1:6),labels = c("Aif","Bts","Delt","Jet","Sigp","Vg"))
boxplot(Airlines$SeatsTotal,horizontal = TRUE, main = "Total no. of seats in airlines" )
boxplot(Airlines$PriceRelative,horizontal = TRUE,main="relative price in USD")
boxplot(PriceRelative~Airline, data = Airlines,horizontal = TRUE,col= c("red","blue","yellow"), yaxt="n",xlab = "Price in USD", main= "Airline-wise relative price distribution")
axis(side=2,at=c(1:6),labels = c("Aif","Bts","Delt","Jet","Sigp","Vg"))
mytable6<-table(Airlines$PitchDifference,Airlines$Airline)
addmargins(mytable6)
##
## AirFrance British Delta Jet Singapore Virgin Sum
## 2 0 0 24 0 0 0 24
## 3 0 0 16 0 0 0 16
## 6 74 0 0 7 40 0 121
## 7 0 175 6 0 0 62 243
## 10 0 0 0 54 0 0 54
## Sum 74 175 46 61 40 62 458
histogram(~PitchDifference|Airline, data=Airlines,type = "count")
table(Airlines$WidthDifference)
##
## 0 1 2 3 4
## 40 264 32 68 54
histogram(~WidthDifference|Airline, data=Airlines,type = "count")
boxplot(Airlines$PercentPremiumSeats,horizontal = TRUE)
plot(Airlines$PitchEconomy,Airlines$PriceEconomy)
plot(Airlines$Airline,Airlines$PriceRelative,horizontal=TRUE,yaxt="n", col=c("red","blue","yellow"))
axis(side=2,at=c(1:6),labels = c("Aif","Bts","Delt","Jet","Sigp","Vg"))
library(car)
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
scatterplotMatrix(~Airline+WidthEconomy+WidthPremium+PitchEconomy+PitchPremium+SeatsEconomy+SeatsPremium+SeatsTotal,data=Airlines,cex=0.6)
## Warning in smoother(x, y, col = col[2], log.x = FALSE, log.y = FALSE,
## spread = spread, : could not fit smooth
## Warning in smoother(x, y, col = col[2], log.x = FALSE, log.y = FALSE,
## spread = spread, : could not fit negative part of the spread
## Warning in smoother(x, y, col = col[2], log.x = FALSE, log.y = FALSE,
## spread = spread, : could not fit negative part of the spread
## Warning in smoother(x, y, col = col[2], log.x = FALSE, log.y = FALSE,
## spread = spread, : could not fit smooth
library(corrgram)
library(ellipse)
##
## Attaching package: 'ellipse'
## The following object is masked from 'package:car':
##
## ellipse
corrgram(Airlines, upper.panel=panel.pie,main= "Corrgram of store variables" )
cor(Airlines[ ,c(3,6:18)])
## FlightDuration SeatsEconomy SeatsPremium PitchEconomy
## FlightDuration 1.00000000 0.195621187 0.161236400 0.29377174
## SeatsEconomy 0.19562119 1.000000000 0.625056587 0.14412692
## SeatsPremium 0.16123640 0.625056587 1.000000000 -0.03421296
## PitchEconomy 0.29377174 0.144126924 -0.034212963 1.00000000
## PitchPremium 0.09621471 0.119221250 0.004883123 -0.55060624
## WidthEconomy 0.45647720 0.373670252 0.455782883 0.29448586
## WidthPremium 0.10343747 0.102431959 -0.002717527 -0.53929285
## PriceEconomy 0.56664039 0.128167220 0.113642176 0.36866123
## PricePremium 0.64873981 0.177000928 0.217612376 0.22614179
## PriceRelative 0.12107501 0.003956939 -0.097196009 -0.42302204
## SeatsTotal 0.20023299 0.992607966 0.715171053 0.12373524
## PitchDifference -0.03749288 0.035318044 0.016365566 -0.78254993
## WidthDifference -0.11856070 -0.080670148 -0.216168666 -0.63557430
## PercentPremiumSeats 0.06051625 -0.330935223 0.485029771 -0.10280880
## PitchPremium WidthEconomy WidthPremium PriceEconomy
## FlightDuration 0.096214708 0.45647720 0.103437469 0.56664039
## SeatsEconomy 0.119221250 0.37367025 0.102431959 0.12816722
## SeatsPremium 0.004883123 0.45578288 -0.002717527 0.11364218
## PitchEconomy -0.550606241 0.29448586 -0.539292852 0.36866123
## PitchPremium 1.000000000 -0.02374087 0.750259029 0.05038455
## WidthEconomy -0.023740873 1.00000000 0.081918728 0.06799061
## WidthPremium 0.750259029 0.08191873 1.000000000 -0.05704522
## PriceEconomy 0.050384550 0.06799061 -0.057045224 1.00000000
## PricePremium 0.088539147 0.15054837 0.064020043 0.90138870
## PriceRelative 0.417539056 -0.04396116 0.504247591 -0.28856711
## SeatsTotal 0.107512784 0.40545860 0.091297500 0.13243313
## PitchDifference 0.950591466 -0.12722421 0.760121272 -0.09952511
## WidthDifference 0.703281797 -0.39320512 0.884149655 -0.08449975
## PercentPremiumSeats -0.175487414 0.22714172 -0.183312058 0.06532232
## PricePremium PriceRelative SeatsTotal PitchDifference
## FlightDuration 0.64873981 0.121075014 0.20023299 -0.03749288
## SeatsEconomy 0.17700093 0.003956939 0.99260797 0.03531804
## SeatsPremium 0.21761238 -0.097196009 0.71517105 0.01636557
## PitchEconomy 0.22614179 -0.423022038 0.12373524 -0.78254993
## PitchPremium 0.08853915 0.417539056 0.10751278 0.95059147
## WidthEconomy 0.15054837 -0.043961160 0.40545860 -0.12722421
## WidthPremium 0.06402004 0.504247591 0.09129750 0.76012127
## PriceEconomy 0.90138870 -0.288567110 0.13243313 -0.09952511
## PricePremium 1.00000000 0.031846537 0.19232533 -0.01806629
## PriceRelative 0.03184654 1.000000000 -0.01156894 0.46873025
## SeatsTotal 0.19232533 -0.011568942 1.00000000 0.03416915
## PitchDifference -0.01806629 0.468730249 0.03416915 1.00000000
## WidthDifference -0.01151218 0.485802437 -0.10584398 0.76089108
## PercentPremiumSeats 0.11639097 -0.161565556 -0.22091465 -0.09264869
## WidthDifference PercentPremiumSeats
## FlightDuration -0.11856070 0.06051625
## SeatsEconomy -0.08067015 -0.33093522
## SeatsPremium -0.21616867 0.48502977
## PitchEconomy -0.63557430 -0.10280880
## PitchPremium 0.70328180 -0.17548741
## WidthEconomy -0.39320512 0.22714172
## WidthPremium 0.88414965 -0.18331206
## PriceEconomy -0.08449975 0.06532232
## PricePremium -0.01151218 0.11639097
## PriceRelative 0.48580244 -0.16156556
## SeatsTotal -0.10584398 -0.22091465
## PitchDifference 0.76089108 -0.09264869
## WidthDifference 1.00000000 -0.27559416
## PercentPremiumSeats -0.27559416 1.00000000
cov(Airlines[ ,c(3,6:18)])
## FlightDuration SeatsEconomy SeatsPremium
## FlightDuration 12.5462183 52.9194291 7.57372426
## SeatsEconomy 52.9194291 5832.9154300 633.07060954
## SeatsPremium 7.5737243 633.0706095 175.86521648
## PitchEconomy 0.6817421 7.2117665 -0.29725856
## PitchPremium 0.4477835 11.9637325 0.08508595
## WidthEconomy 0.9014224 15.9105138 3.36977440
## WidthPremium 0.4019845 8.5832800 -0.03954019
## PriceEconomy 1983.5401655 9673.7944684 1489.38359627
## PricePremium 2959.9783043 17413.2541733 3717.36428960
## PriceRelative 0.1932368 0.1361699 -0.58078765
## SeatsTotal 60.4931534 6465.9860396 808.93582602
## PitchDifference -0.2339587 4.7519660 0.38234451
## WidthDifference -0.4994380 -7.3272338 -3.40931459
## PercentPremiumSeats 1.0379912 -122.3914537 31.14753127
## PitchEconomy PitchPremium WidthEconomy WidthPremium
## FlightDuration 0.6817421 0.44778348 0.90142242 0.40198446
## SeatsEconomy 7.2117665 11.96373253 15.91051379 8.58327998
## SeatsPremium -0.2972586 0.08508595 3.36977440 -0.03954019
## PitchEconomy 0.4292471 -0.47398546 0.10756500 -0.38766208
## PitchPremium -0.4739855 1.72639580 -0.01739081 1.08157435
## WidthEconomy 0.1075650 -0.01739081 0.31081765 0.05010845
## WidthPremium -0.3876621 1.08157435 0.05010845 1.20378776
## PriceEconomy 238.7031905 65.42513354 37.46095191 -61.85450011
## PricePremium 190.8517195 149.85356368 108.11611707 90.47997668
## PriceRelative -0.1248808 0.24719874 -0.01104335 0.24928593
## SeatsTotal 6.9145079 12.04881848 19.28028819 8.54373979
## PitchDifference -0.9032326 2.20038126 -0.12495581 1.46923643
## WidthDifference -0.4952271 1.09896515 -0.26070920 1.15367930
## PercentPremiumSeats -0.3261739 -1.11655834 0.61321816 -0.97393787
## PriceEconomy PricePremium PriceRelative
## FlightDuration 1983.54017 2959.97830 0.19323683
## SeatsEconomy 9673.79447 17413.25417 0.13616991
## SeatsPremium 1489.38360 3717.36429 -0.58078765
## PitchEconomy 238.70319 190.85172 -0.12488080
## PitchPremium 65.42513 149.85356 0.24719874
## WidthEconomy 37.46095 108.11612 -0.01104335
## WidthPremium -61.85450 90.47998 0.24928593
## PriceEconomy 976684.06198 1147494.76801 -128.49991725
## PricePremium 1147494.76801 1659293.11947 18.48428836
## PriceRelative -128.49992 18.48429 0.20302893
## SeatsTotal 11163.17806 21130.61846 -0.44461774
## PitchDifference -173.27806 -40.99816 0.37207954
## WidthDifference -99.31545 -17.63614 0.26032928
## PercentPremiumSeats 312.61077 726.01582 -0.35252750
## SeatsTotal PitchDifference WidthDifference
## FlightDuration 60.4931534 -0.2339587 -0.4994380
## SeatsEconomy 6465.9860396 4.7519660 -7.3272338
## SeatsPremium 808.9358260 0.3823445 -3.4093146
## PitchEconomy 6.9145079 -0.9032326 -0.4952271
## PitchPremium 12.0488185 2.2003813 1.0989652
## WidthEconomy 19.2802882 -0.1249558 -0.2607092
## WidthPremium 8.5437398 1.4692364 1.1536793
## PriceEconomy 11163.1780647 -173.2780570 -99.3154520
## PricePremium 21130.6184629 -40.9981558 -17.6361404
## PriceRelative -0.4446177 0.3720795 0.2603293
## SeatsTotal 7274.9218656 5.1343105 -10.7365484
## PitchDifference 5.1343105 3.1036138 1.5941922
## WidthDifference -10.7365484 1.5941922 1.4143885
## PercentPremiumSeats -91.2439224 -0.7903844 -1.5871560
## PercentPremiumSeats
## FlightDuration 1.0379912
## SeatsEconomy -122.3914537
## SeatsPremium 31.1475313
## PitchEconomy -0.3261739
## PitchPremium -1.1165583
## WidthEconomy 0.6132182
## WidthPremium -0.9739379
## PriceEconomy 312.6107669
## PricePremium 726.0158229
## PriceRelative -0.3525275
## SeatsTotal -91.2439224
## PitchDifference -0.7903844
## WidthDifference -1.5871560
## PercentPremiumSeats 23.4493343
Britishairways <- Airlines[which(Airlines$Airline=="British"),]
View(Britishairways)
fit <- lm(PriceEconomy~WidthEconomy+PitchEconomy+TravelMonth+FlightDuration+Aircraft+SeatsEconomy,data=Britishairways)
summary(fit)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + TravelMonth +
## FlightDuration + Aircraft + SeatsEconomy, data = Britishairways)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1543.90 -286.68 56.45 340.33 1087.57
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 191.7574 272.9826 0.702 0.4834
## WidthEconomy NA NA NA NA
## PitchEconomy NA NA NA NA
## TravelMonthJul 240.9518 157.4555 1.530 0.1278
## TravelMonthOct -65.8724 107.1421 -0.615 0.5395
## TravelMonthSep 0.4950 106.6531 0.005 0.9963
## FlightDuration 124.1934 12.3685 10.041 <2e-16 ***
## AircraftBoeing 352.6527 136.2346 2.589 0.0105 *
## SeatsEconomy -0.6186 0.7884 -0.785 0.4338
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 548.9 on 168 degrees of freedom
## Multiple R-squared: 0.5237, Adjusted R-squared: 0.5067
## F-statistic: 30.79 on 6 and 168 DF, p-value: < 2.2e-16
Airfrance <- Airlines[which(Airlines$Airline=="AirFrance"),]
model <- lm(PriceEconomy~WidthEconomy+PitchEconomy+TravelMonth+FlightDuration+Aircraft+SeatsEconomy,data=Airfrance)
summary(model)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + TravelMonth +
## FlightDuration + Aircraft + SeatsEconomy, data = Airfrance)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1999.00 -31.15 188.87 421.55 712.66
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6733.767 7278.745 -0.925 0.3583
## WidthEconomy 489.737 414.926 1.180 0.2421
## PitchEconomy NA NA NA NA
## TravelMonthJul 138.990 272.623 0.510 0.6119
## TravelMonthOct -149.180 235.937 -0.632 0.5294
## TravelMonthSep -56.372 229.178 -0.246 0.8065
## FlightDuration 94.981 58.059 1.636 0.1066
## AircraftBoeing 765.273 408.974 1.871 0.0658 .
## SeatsEconomy -1.455 1.255 -1.160 0.2503
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 737.2 on 66 degrees of freedom
## Multiple R-squared: 0.1258, Adjusted R-squared: 0.03306
## F-statistic: 1.357 on 7 and 66 DF, p-value: 0.2386
Delta <- Airlines[which(Airlines$Airline=="Delta"),]
model1 <- lm(PriceEconomy~WidthEconomy+PitchEconomy+TravelMonth+FlightDuration+Aircraft+SeatsEconomy,data=Delta)
summary(model1)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + TravelMonth +
## FlightDuration + Aircraft + SeatsEconomy, data = Delta)
##
## Residuals:
## Min 1Q Median 3Q Max
## -352.03 -78.85 -21.92 92.57 365.29
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1869.365 2940.172 -0.636 0.528819
## WidthEconomy 171.853 71.732 2.396 0.021758 *
## PitchEconomy -35.754 66.068 -0.541 0.591639
## TravelMonthJul 158.611 74.474 2.130 0.039908 *
## TravelMonthOct -28.649 73.659 -0.389 0.699552
## TravelMonthSep -50.231 79.468 -0.632 0.531214
## FlightDuration 143.263 34.161 4.194 0.000164 ***
## AircraftBoeing -383.143 84.959 -4.510 6.34e-05 ***
## SeatsEconomy 1.947 1.800 1.082 0.286374
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 170.1 on 37 degrees of freedom
## Multiple R-squared: 0.9207, Adjusted R-squared: 0.9035
## F-statistic: 53.69 on 8 and 37 DF, p-value: < 2.2e-16
Jet <- Airlines[which(Airlines$Airline=="Jet"),]
model2 <- lm(PriceEconomy~WidthEconomy+PitchEconomy+TravelMonth+FlightDuration+Aircraft+SeatsEconomy,data=Jet)
summary(model2)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + TravelMonth +
## FlightDuration + Aircraft + SeatsEconomy, data = Jet)
##
## Residuals:
## Min 1Q Median 3Q Max
## -179.78 -87.99 -30.03 73.55 339.25
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -7375.3950 1852.4467 -3.981 0.000206 ***
## WidthEconomy 438.5707 111.3965 3.937 0.000238 ***
## PitchEconomy NA NA NA NA
## TravelMonthJul 37.9981 44.0750 0.862 0.392432
## TravelMonthOct -37.7187 43.9830 -0.858 0.394919
## TravelMonthSep 18.1947 43.9877 0.414 0.680782
## FlightDuration -28.7435 17.4256 -1.649 0.104851
## AircraftBoeing NA NA NA NA
## SeatsEconomy 1.8537 0.9751 1.901 0.062628 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 122.2 on 54 degrees of freedom
## Multiple R-squared: 0.4375, Adjusted R-squared: 0.375
## F-statistic: 6.999 on 6 and 54 DF, p-value: 1.529e-05
Singapore <- Airlines[which(Airlines$Airline=="Singapore"),]
model3 <- lm(PriceEconomy~WidthEconomy+PitchEconomy+TravelMonth+FlightDuration+Aircraft+SeatsEconomy,data=Singapore)
summary(model3)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + TravelMonth +
## FlightDuration + Aircraft + SeatsEconomy, data = Singapore)
##
## Residuals:
## Min 1Q Median 3Q Max
## -416.66 -214.39 31.11 209.34 382.63
##
## Coefficients: (3 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 2.508e+02 1.481e+02 1.693 0.09964 .
## WidthEconomy NA NA NA NA
## PitchEconomy NA NA NA NA
## TravelMonthJul -4.642e+01 1.201e+02 -0.386 0.70164
## TravelMonthOct 4.167e+01 1.124e+02 0.371 0.71319
## TravelMonthSep -1.195e-13 1.097e+02 0.000 1.00000
## FlightDuration 3.601e+01 1.173e+01 3.071 0.00418 **
## AircraftBoeing 3.849e+02 8.492e+01 4.533 6.87e-05 ***
## SeatsEconomy NA NA NA NA
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 257.2 on 34 degrees of freedom
## Multiple R-squared: 0.5278, Adjusted R-squared: 0.4583
## F-statistic: 7.599 on 5 and 34 DF, p-value: 6.991e-05
Virgin <- Airlines[which(Airlines$Airline=="Virgin"),]
model4 <- lm(PriceEconomy~WidthEconomy+PitchEconomy+TravelMonth+FlightDuration+Aircraft+SeatsEconomy,data=Virgin)
summary(model4)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + TravelMonth +
## FlightDuration + Aircraft + SeatsEconomy, data = Virgin)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1199.1 -262.9 125.8 402.9 960.5
##
## Coefficients: (2 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 784.911 504.113 1.557 0.12520
## WidthEconomy NA NA NA NA
## PitchEconomy NA NA NA NA
## TravelMonthJul -35.824 189.780 -0.189 0.85097
## TravelMonthOct 28.172 184.053 0.153 0.87891
## TravelMonthSep 5.480 182.475 0.030 0.97615
## FlightDuration 11.558 47.790 0.242 0.80980
## AircraftBoeing -246.385 190.636 -1.292 0.20161
## SeatsEconomy 3.590 1.167 3.076 0.00327 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 516 on 55 degrees of freedom
## Multiple R-squared: 0.1546, Adjusted R-squared: 0.06234
## F-statistic: 1.676 on 6 and 55 DF, p-value: 0.1443
table(Airlines$IsInternational)
##
## Domestic International
## 40 418
model5 <- lm(PriceRelative ~ WidthDifference + PitchDifference + IsInternational + Airline + SeatsTotal + PercentPremiumSeats, data = Airlines)
summary(model5)
##
## Call:
## lm(formula = PriceRelative ~ WidthDifference + PitchDifference +
## IsInternational + Airline + SeatsTotal + PercentPremiumSeats,
## data = Airlines)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.94187 -0.20225 -0.05734 0.11501 1.38928
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 0.1749001 0.2696423 0.649 0.516906
## WidthDifference 0.0270691 0.0774293 0.350 0.726805
## PitchDifference 0.0365747 0.0634478 0.576 0.564599
## IsInternationalInternational 0.1149537 0.2334593 0.492 0.622683
## AirlineBritish 0.3348407 0.1099740 3.045 0.002466 **
## AirlineDelta 0.1709651 0.1769791 0.966 0.334557
## AirlineJet 0.4746211 0.1436209 3.305 0.001027 **
## AirlineSingapore 0.3586353 0.0798399 4.492 9.00e-06 ***
## AirlineVirgin 0.5719661 0.1076120 5.315 1.69e-07 ***
## SeatsTotal -0.0005150 0.0003017 -1.707 0.088506 .
## PercentPremiumSeats -0.0189117 0.0056374 -3.355 0.000862 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3685 on 447 degrees of freedom
## Multiple R-squared: 0.3459, Adjusted R-squared: 0.3312
## F-statistic: 23.63 on 10 and 447 DF, p-value: < 2.2e-16
model6 <- lm(PriceRelative ~ PercentPremiumSeats + WidthDifference + PitchDifference + IsInternational, data = Airlines)
summary(model6)
##
## Call:
## lm(formula = PriceRelative ~ PercentPremiumSeats + WidthDifference +
## PitchDifference + IsInternational, data = Airlines)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.91971 -0.28760 -0.05318 0.20534 1.19107
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -0.037996 0.097299 -0.391 0.696342
## PercentPremiumSeats -0.005733 0.003969 -1.445 0.149278
## WidthDifference 0.093953 0.026269 3.577 0.000386 ***
## PitchDifference 0.085906 0.023499 3.656 0.000286 ***
## IsInternationalInternational -0.130161 0.104195 -1.249 0.212235
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 0.3879 on 453 degrees of freedom
## Multiple R-squared: 0.2653, Adjusted R-squared: 0.2588
## F-statistic: 40.89 on 4 and 453 DF, p-value: < 2.2e-16
model7 <- lm(PriceEconomy ~ WidthEconomy + PitchEconomy + SeatsEconomy + SeatsPremium,data = Airlines)
summary(model7)
##
## Call:
## lm(formula = PriceEconomy ~ WidthEconomy + PitchEconomy + SeatsEconomy +
## SeatsPremium, data = Airlines)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2298.01 -729.33 -25.68 665.18 2091.50
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1.428e+04 2.228e+03 -6.411 3.64e-10 ***
## WidthEconomy -2.534e+02 9.132e+01 -2.775 0.00575 **
## PitchEconomy 6.293e+02 7.024e+01 8.958 < 2e-16 ***
## SeatsEconomy 1.663e-02 7.291e-01 0.023 0.98181
## SeatsPremium 1.433e+01 4.461e+00 3.212 0.00141 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 906.5 on 453 degrees of freedom
## Multiple R-squared: 0.1661, Adjusted R-squared: 0.1587
## F-statistic: 22.56 on 4 and 453 DF, p-value: < 2.2e-16
model8 <- lm(PriceEconomy ~ WidthPremium + PitchPremium + SeatsPremium + SeatsEconomy , data = Airlines)
summary(model8)
##
## Call:
## lm(formula = PriceEconomy ~ WidthPremium + PitchPremium + SeatsPremium +
## SeatsEconomy, data = Airlines)
##
## Residuals:
## Min 1Q Median 3Q Max
## -1578.0 -782.2 -122.1 763.0 2231.4
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -1009.1466 1349.9841 -0.748 0.45513
## WidthPremium -197.2073 62.7312 -3.144 0.00178 **
## PitchPremium 152.9595 52.4996 2.914 0.00375 **
## SeatsPremium 4.0458 4.4129 0.917 0.35972
## SeatsEconomy 1.1958 0.7719 1.549 0.12201
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 972.2 on 453 degrees of freedom
## Multiple R-squared: 0.04075, Adjusted R-squared: 0.03228
## F-statistic: 4.811 on 4 and 453 DF, p-value: 0.0008269
The difference in price of economy and premium economy class dependence on Type of airline,flightduration,width of seat , Pitch of seat and no. of seats present in airline.