Setting the working directory

setwd("D:/extras/Internship")

Reading the Dataset

airlines.df<-read.csv(paste("SixAirlinesData.csv",sep=""))

Viewing the Dataset

View(airlines.df)
summary(airlines.df)
##       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

Viewing its different parameters

library("psych", lib.loc="~/R/win-library/3.4")
attach(airlines.df)
describe(FlightDuration)
##    vars   n mean   sd median trimmed  mad  min   max range  skew kurtosis
## X1    1 458 7.58 3.54   7.79    7.57 4.81 1.25 14.66 13.41 -0.07    -1.12
##      se
## X1 0.17
describe(SeatsEconomy)
##    vars   n   mean    sd median trimmed   mad min max range skew kurtosis
## X1    1 458 202.31 76.37    185  194.64 85.99  78 389   311 0.72    -0.36
##      se
## X1 3.57
describe(SeatsPremium)
##    vars   n  mean    sd median trimmed   mad min max range skew kurtosis
## X1    1 458 33.65 13.26     36   33.35 11.86   8  66    58 0.23    -0.46
##      se
## X1 0.62
describe(PitchEconomy)
##    vars   n  mean   sd median trimmed mad min max range  skew kurtosis
## X1    1 458 31.22 0.66     31   31.26   0  30  33     3 -0.03    -0.35
##      se
## X1 0.03
describe(PitchPremium)
##    vars   n  mean   sd median trimmed mad min max range  skew kurtosis
## X1    1 458 37.91 1.31     38   38.05   0  34  40     6 -1.51     3.52
##      se
## X1 0.06
describe(WidthEconomy)
##    vars   n  mean   sd median trimmed mad min max range  skew kurtosis
## X1    1 458 17.84 0.56     18   17.81   0  17  19     2 -0.04    -0.08
##      se
## X1 0.03
describe(WidthPremium)
##    vars   n  mean  sd median trimmed mad min max range  skew kurtosis   se
## X1    1 458 19.47 1.1     19   19.53   0  17  21     4 -0.08    -0.31 0.05
describe(PriceEconomy)
##    vars   n    mean     sd median trimmed     mad min  max range skew
## X1    1 458 1327.08 988.27   1242  1244.4 1159.39  65 3593  3528 0.51
##    kurtosis    se
## X1    -0.88 46.18
describe(PricePremium)
##    vars   n    mean      sd median trimmed     mad min  max range skew
## X1    1 458 1845.26 1288.14   1737 1799.05 1845.84  86 7414  7328  0.5
##    kurtosis    se
## X1     0.43 60.19

Mean Premium and Economy Price for different airlines

aggregate(airlines.df$PricePremium~airlines.df$Airline, FUN=mean)
##   airlines.df$Airline airlines.df$PricePremium
## 1           AirFrance                3065.2162
## 2             British                1937.0286
## 3               Delta                 684.6739
## 4                 Jet                 483.3607
## 5           Singapore                1239.9250
## 6              Virgin                2721.6935
aggregate(airlines.df$PriceEconomy~airlines.df$Airline, FUN=mean)
##   airlines.df$Airline airlines.df$PriceEconomy
## 1           AirFrance                2769.7838
## 2             British                1293.4800
## 3               Delta                 560.9348
## 4                 Jet                 276.1639
## 5           Singapore                 860.2500
## 6              Virgin                1603.5323

Effect of Percentage of Premium Seats on Relative Prices

aggregate(airlines.df$PriceRelative~airlines.df$PercentPremiumSeats, FUN=mean)
##    airlines.df$PercentPremiumSeats airlines.df$PriceRelative
## 1                             4.71                0.95263158
## 2                             8.90                0.20928571
## 3                             9.76                0.80000000
## 4                            10.00                1.32000000
## 5                            10.57                0.60416667
## 6                            11.43                1.15370370
## 7                            12.12                0.03000000
## 8                            12.28                0.08590909
## 9                            12.50                0.23125000
## 10                           12.82                0.07200000
## 11                           12.90                0.50414634
## 12                           13.04                0.06200000
## 13                           13.13                0.10750000
## 14                           13.21                0.34958333
## 15                           14.02                0.61111111
## 16                           14.50                0.09500000
## 17                           14.97                0.74000000
## 18                           14.99                0.31000000
## 19                           15.02                1.03523810
## 20                           15.36                0.32211538
## 21                           16.46                0.09000000
## 22                           16.87                0.39625000
## 23                           18.73                0.73500000
## 24                           20.41                0.06125000
## 25                           20.60                0.44666667
## 26                           23.49                0.41600000
## 27                           24.69                0.42254902

Effect of Width Difference on Relative Pricing

aggregate(airlines.df$PriceRelative~airlines.df$WidthDifference, FUN=mean)
##   airlines.df$WidthDifference airlines.df$PriceRelative
## 1                           0                 0.0847500
## 2                           1                 0.4184091
## 3                           2                 0.2296875
## 4                           3                 0.7282353
## 5                           4                 0.9707407

Monthly Analysis of Seats

library("car", lib.loc="~/R/win-library/3.4")
## 
## Attaching package: 'car'
## The following object is masked from 'package:psych':
## 
##     logit
par(mfrow=c(1, 2))
scatterplot( TravelMonth,SeatsEconomy)
scatterplot( TravelMonth,SeatsPremium)

## [1] "165" "175" "164" "174" "166" "176"
cor(SeatsPremium,SeatsEconomy)
## [1] 0.6250566

Usage of different types of Flights during different Months

mytable <- xtabs(~ TravelMonth+Airline+Aircraft, data=airlines.df)
ftable(mytable)
##                       Aircraft AirBus Boeing
## TravelMonth Airline                         
## Aug         AirFrance               9     11
##             British                13     39
##             Delta                   2     10
##             Jet                     2     14
##             Singapore               4      7
##             Virgin                  9      7
## Jul         AirFrance               6      6
##             British                 6     10
##             Delta                   0     10
##             Jet                     1     14
##             Singapore               4      4
##             Virgin                  8      6
## Oct         AirFrance               9     11
##             British                14     39
##             Delta                   5      8
##             Jet                     2     13
##             Singapore               4      6
##             Virgin                  7      9
## Sep         AirFrance              12     10
##             British                14     40
##             Delta                   5      6
##             Jet                     2     13
##             Singapore               4      7
##             Virgin                  9      7

Type of Journey available with different Airlines on a Monthly basis

mytable <- xtabs(~ Airline+TravelMonth+IsInternational, data=airlines.df)
ftable(mytable)
##                       IsInternational Domestic International
## Airline   TravelMonth                                       
## AirFrance Aug                                0            20
##           Jul                                0            12
##           Oct                                0            20
##           Sep                                0            22
## British   Aug                                0            52
##           Jul                                0            16
##           Oct                                0            53
##           Sep                                0            54
## Delta     Aug                               10             2
##           Jul                               10             0
##           Oct                               11             2
##           Sep                                9             2
## Jet       Aug                                0            16
##           Jul                                0            15
##           Oct                                0            15
##           Sep                                0            15
## Singapore Aug                                0            11
##           Jul                                0             8
##           Oct                                0            10
##           Sep                                0            11
## Virgin    Aug                                0            16
##           Jul                                0            14
##           Oct                                0            16
##           Sep                                0            16

Analysis of Data of each Airline seperately

British <- airlines.df[ which(airlines.df$Airline=='British'), ]
summary(British)
##       Airline      Aircraft   FlightDuration   TravelMonth
##  AirFrance:  0   AirBus: 47   Min.   : 1.250   Aug:52     
##  British  :175   Boeing:128   1st Qu.: 4.290   Jul:16     
##  Delta    :  0                Median : 8.580   Oct:53     
##  Jet      :  0                Mean   : 7.855   Sep:54     
##  Singapore:  0                3rd Qu.:11.120              
##  Virgin   :  0                Max.   :13.830              
##       IsInternational  SeatsEconomy    SeatsPremium    PitchEconomy
##  Domestic     :  0    Min.   :122.0   Min.   :24.00   Min.   :31   
##  International:175    1st Qu.:122.0   1st Qu.:36.00   1st Qu.:31   
##                       Median :243.0   Median :40.00   Median :31   
##                       Mean   :216.6   Mean   :43.18   Mean   :31   
##                       3rd Qu.:303.0   3rd Qu.:55.00   3rd Qu.:31   
##                       Max.   :312.0   Max.   :56.00   Max.   :31   
##   PitchPremium  WidthEconomy  WidthPremium  PriceEconomy   
##  Min.   :38    Min.   :18    Min.   :19    Min.   :  65.0  
##  1st Qu.:38    1st Qu.:18    1st Qu.:19    1st Qu.: 528.5  
##  Median :38    Median :18    Median :19    Median :1444.0  
##  Mean   :38    Mean   :18    Mean   :19    Mean   :1293.5  
##  3rd Qu.:38    3rd Qu.:18    3rd Qu.:19    3rd Qu.:1813.0  
##  Max.   :38    Max.   :18    Max.   :19    Max.   :3102.0  
##   PricePremium    PriceRelative      SeatsTotal    PitchDifference
##  Min.   :  86.0   Min.   :0.0400   Min.   :162.0   Min.   :7      
##  1st Qu.: 807.5   1st Qu.:0.2100   1st Qu.:162.0   1st Qu.:7      
##  Median :2049.0   Median :0.3600   Median :279.0   Median :7      
##  Mean   :1937.0   Mean   :0.4375   Mean   :259.8   Mean   :7      
##  3rd Qu.:2982.0   3rd Qu.:0.5200   3rd Qu.:358.0   3rd Qu.:7      
##  Max.   :7414.0   Max.   :1.3900   Max.   :367.0   Max.   :7      
##  WidthDifference PercentPremiumSeats
##  Min.   :1       Min.   :10.57      
##  1st Qu.:1       1st Qu.:12.90      
##  Median :1       Median :15.36      
##  Mean   :1       Mean   :17.79      
##  3rd Qu.:1       3rd Qu.:24.69      
##  Max.   :1       Max.   :24.69
AirFrance <- airlines.df[ which(airlines.df$Airline=='AirFrance'), ]
summary(AirFrance)
##       Airline     Aircraft  FlightDuration   TravelMonth
##  AirFrance:74   AirBus:36   Min.   : 6.830   Aug:20     
##  British  : 0   Boeing:38   1st Qu.: 7.770   Jul:12     
##  Delta    : 0               Median : 8.750   Oct:20     
##  Jet      : 0               Mean   : 8.989   Sep:22     
##  Singapore: 0               3rd Qu.: 9.500              
##  Virgin   : 0               Max.   :13.000              
##       IsInternational  SeatsEconomy    SeatsPremium   PitchEconomy
##  Domestic     : 0     Min.   :147.0   Min.   :21.0   Min.   :32   
##  International:74     1st Qu.:147.0   1st Qu.:21.0   1st Qu.:32   
##                       Median :200.0   Median :24.0   Median :32   
##                       Mean   :214.5   Mean   :26.7   Mean   :32   
##                       3rd Qu.:200.0   3rd Qu.:28.0   3rd Qu.:32   
##                       Max.   :389.0   Max.   :38.0   Max.   :32   
##   PitchPremium  WidthEconomy    WidthPremium  PriceEconomy   PricePremium 
##  Min.   :38    Min.   :17.00   Min.   :19    Min.   : 630   Min.   :1611  
##  1st Qu.:38    1st Qu.:17.00   1st Qu.:19    1st Qu.:2659   1st Qu.:2859  
##  Median :38    Median :18.00   Median :19    Median :2988   Median :3196  
##  Mean   :38    Mean   :17.57   Mean   :19    Mean   :2770   Mean   :3065  
##  3rd Qu.:38    3rd Qu.:18.00   3rd Qu.:19    3rd Qu.:3165   3rd Qu.:3289  
##  Max.   :38    Max.   :18.00   Max.   :19    Max.   :3593   Max.   :3972  
##  PriceRelative      SeatsTotal    PitchDifference WidthDifference
##  Min.   :0.0200   Min.   :168.0   Min.   :6       Min.   :1.000  
##  1st Qu.:0.0300   1st Qu.:168.0   1st Qu.:6       1st Qu.:1.000  
##  Median :0.0700   Median :228.0   Median :6       Median :1.000  
##  Mean   :0.2047   Mean   :241.2   Mean   :6       Mean   :1.432  
##  3rd Qu.:0.0800   3rd Qu.:228.0   3rd Qu.:6       3rd Qu.:2.000  
##  Max.   :1.6400   Max.   :427.0   Max.   :6       Max.   :2.000  
##  PercentPremiumSeats
##  Min.   : 8.90      
##  1st Qu.:12.12      
##  Median :12.28      
##  Mean   :11.59      
##  3rd Qu.:12.50      
##  Max.   :12.50
Delta <- airlines.df[ which(airlines.df$Airline=='Delta'), ]
summary(Delta)
##       Airline     Aircraft  FlightDuration  TravelMonth
##  AirFrance: 0   AirBus:12   Min.   :1.570   Aug:12     
##  British  : 0   Boeing:34   1st Qu.:2.270   Jul:10     
##  Delta    :46               Median :4.260   Oct:13     
##  Jet      : 0               Mean   :4.029   Sep:11     
##  Singapore: 0               3rd Qu.:4.645              
##  Virgin   : 0               Max.   :9.500              
##       IsInternational  SeatsEconomy    SeatsPremium    PitchEconomy  
##  Domestic     :40     Min.   : 78.0   Min.   :18.00   Min.   :31.00  
##  International: 6     1st Qu.:120.0   1st Qu.:18.00   1st Qu.:31.00  
##                       Median :126.0   Median :20.00   Median :32.00  
##                       Mean   :137.2   Mean   :22.57   Mean   :31.72  
##                       3rd Qu.:139.0   3rd Qu.:21.00   3rd Qu.:32.00  
##                       Max.   :233.0   Max.   :38.00   Max.   :33.00  
##   PitchPremium    WidthEconomy    WidthPremium    PriceEconomy   
##  Min.   :34.00   Min.   :17.00   Min.   :17.00   Min.   : 158.0  
##  1st Qu.:34.00   1st Qu.:17.00   1st Qu.:17.00   1st Qu.: 293.0  
##  Median :34.00   Median :17.00   Median :17.00   Median : 363.0  
##  Mean   :34.72   Mean   :17.39   Mean   :17.78   Mean   : 560.9  
##  3rd Qu.:35.00   3rd Qu.:18.00   3rd Qu.:18.00   3rd Qu.: 449.2  
##  Max.   :38.00   Max.   :18.00   Max.   :21.00   Max.   :1999.0  
##   PricePremium    PriceRelative      SeatsTotal    PitchDifference
##  Min.   : 173.0   Min.   :0.0300   Min.   : 98.0   Min.   :2      
##  1st Qu.: 312.8   1st Qu.:0.0700   1st Qu.:138.0   1st Qu.:2      
##  Median : 406.5   Median :0.0900   Median :144.0   Median :2      
##  Mean   : 684.7   Mean   :0.1250   Mean   :159.8   Mean   :3      
##  3rd Qu.: 489.5   3rd Qu.:0.1175   3rd Qu.:160.0   3rd Qu.:3      
##  Max.   :2765.0   Max.   :0.4600   Max.   :271.0   Max.   :7      
##  WidthDifference  PercentPremiumSeats
##  Min.   :0.0000   Min.   :12.50      
##  1st Qu.:0.0000   1st Qu.:12.50      
##  Median :0.0000   Median :13.09      
##  Mean   :0.3913   Mean   :14.48      
##  3rd Qu.:0.0000   3rd Qu.:14.50      
##  Max.   :3.0000   Max.   :20.41
Singapore <- airlines.df[ which(airlines.df$Airline=='Singapore'), ]
summary(Singapore)
##       Airline     Aircraft  FlightDuration  TravelMonth
##  AirFrance: 0   AirBus:16   Min.   : 3.83   Aug:11     
##  British  : 0   Boeing:24   1st Qu.: 6.50   Jul: 8     
##  Delta    : 0               Median :12.41   Oct:10     
##  Jet      : 0               Mean   :10.48   Sep:11     
##  Singapore:40               3rd Qu.:13.33              
##  Virgin   : 0               Max.   :14.66              
##       IsInternational  SeatsEconomy    SeatsPremium   PitchEconomy
##  Domestic     : 0     Min.   :184.0   Min.   :28.0   Min.   :32   
##  International:40     1st Qu.:184.0   1st Qu.:28.0   1st Qu.:32   
##                       Median :184.0   Median :28.0   Median :32   
##                       Mean   :243.6   Mean   :31.2   Mean   :32   
##                       3rd Qu.:333.0   3rd Qu.:36.0   3rd Qu.:32   
##                       Max.   :333.0   Max.   :36.0   Max.   :32   
##   PitchPremium  WidthEconomy  WidthPremium  PriceEconomy     PricePremium 
##  Min.   :38    Min.   :19    Min.   :20    Min.   : 505.0   Min.   : 619  
##  1st Qu.:38    1st Qu.:19    1st Qu.:20    1st Qu.: 563.0   1st Qu.:1004  
##  Median :38    Median :19    Median :20    Median : 690.0   Median :1110  
##  Mean   :38    Mean   :19    Mean   :20    Mean   : 860.2   Mean   :1240  
##  3rd Qu.:38    3rd Qu.:19    3rd Qu.:20    3rd Qu.:1223.0   3rd Qu.:1564  
##  Max.   :38    Max.   :19    Max.   :20    Max.   :1431.0   Max.   :1947  
##  PriceRelative      SeatsTotal    PitchDifference WidthDifference
##  Min.   :0.0900   Min.   :212.0   Min.   :6       Min.   :1      
##  1st Qu.:0.1300   1st Qu.:212.0   1st Qu.:6       1st Qu.:1      
##  Median :0.6050   Median :212.0   Median :6       Median :1      
##  Mean   :0.5298   Mean   :274.8   Mean   :6       Mean   :1      
##  3rd Qu.:0.8300   3rd Qu.:369.0   3rd Qu.:6       3rd Qu.:1      
##  Max.   :1.1100   Max.   :369.0   Max.   :6       Max.   :1      
##  PercentPremiumSeats
##  Min.   : 9.76      
##  1st Qu.: 9.76      
##  Median :13.21      
##  Mean   :11.83      
##  3rd Qu.:13.21      
##  Max.   :13.21
Virgin <- airlines.df[ which(airlines.df$Airline=='Virgin'), ]
summary(Virgin)
##       Airline     Aircraft  FlightDuration   TravelMonth
##  AirFrance: 0   AirBus:33   Min.   : 6.580   Aug:16     
##  British  : 0   Boeing:29   1st Qu.: 7.473   Jul:14     
##  Delta    : 0               Median : 8.830   Oct:16     
##  Jet      : 0               Mean   : 9.250   Sep:16     
##  Singapore: 0               3rd Qu.:10.830              
##  Virgin   :62               Max.   :12.580              
##       IsInternational  SeatsEconomy    SeatsPremium    PitchEconomy
##  Domestic     : 0     Min.   :185.0   Min.   :35.00   Min.   :31   
##  International:62     1st Qu.:198.0   1st Qu.:35.00   1st Qu.:31   
##                       Median :198.0   Median :38.00   Median :31   
##                       Mean   :230.2   Mean   :42.53   Mean   :31   
##                       3rd Qu.:233.0   3rd Qu.:48.00   3rd Qu.:31   
##                       Max.   :375.0   Max.   :66.00   Max.   :31   
##   PitchPremium  WidthEconomy  WidthPremium  PriceEconomy   PricePremium 
##  Min.   :38    Min.   :18    Min.   :21    Min.   : 540   Min.   : 594  
##  1st Qu.:38    1st Qu.:18    1st Qu.:21    1st Qu.:1434   1st Qu.:2499  
##  Median :38    Median :18    Median :21    Median :1774   Median :2973  
##  Mean   :38    Mean   :18    Mean   :21    Mean   :1604   Mean   :2722  
##  3rd Qu.:38    3rd Qu.:18    3rd Qu.:21    3rd Qu.:1903   3rd Qu.:3128  
##  Max.   :38    Max.   :18    Max.   :21    Max.   :2445   Max.   :3694  
##  PriceRelative      SeatsTotal    PitchDifference WidthDifference
##  Min.   :0.1000   Min.   :233.0   Min.   :7       Min.   :3      
##  1st Qu.:0.4000   1st Qu.:233.0   1st Qu.:7       1st Qu.:3      
##  Median :0.7300   Median :233.0   Median :7       Median :3      
##  Mean   :0.7606   Mean   :272.7   Mean   :7       Mean   :3      
##  3rd Qu.:1.0150   3rd Qu.:271.0   3rd Qu.:7       3rd Qu.:3      
##  Max.   :1.8200   Max.   :441.0   Max.   :7       Max.   :3      
##  PercentPremiumSeats
##  Min.   :14.02      
##  1st Qu.:14.02      
##  Median :15.02      
##  Mean   :15.75      
##  3rd Qu.:15.02      
##  Max.   :20.60
Jet <- airlines.df[ which(airlines.df$Airline=='Jet'), ]
summary(Jet)
##       Airline     Aircraft  FlightDuration  TravelMonth
##  AirFrance: 0   AirBus: 7   Min.   :2.500   Aug:16     
##  British  : 0   Boeing:54   1st Qu.:2.660   Jul:15     
##  Delta    : 0               Median :3.250   Oct:15     
##  Jet      :61               Mean   :4.144   Sep:15     
##  Singapore: 0               3rd Qu.:4.330              
##  Virgin   : 0               Max.   :9.500              
##       IsInternational  SeatsEconomy    SeatsPremium    PitchEconomy  
##  Domestic     : 0     Min.   :124.0   Min.   : 8.00   Min.   :30.00  
##  International:61     1st Qu.:124.0   1st Qu.: 8.00   1st Qu.:30.00  
##                       Median :138.0   Median :16.00   Median :30.00  
##                       Mean   :140.3   Mean   :15.66   Mean   :30.23  
##                       3rd Qu.:162.0   3rd Qu.:16.00   3rd Qu.:30.00  
##                       Max.   :162.0   Max.   :28.00   Max.   :32.00  
##   PitchPremium    WidthEconomy    WidthPremium    PriceEconomy  
##  Min.   :38.00   Min.   :17.00   Min.   :19.00   Min.   :108.0  
##  1st Qu.:40.00   1st Qu.:17.00   1st Qu.:21.00   1st Qu.:154.0  
##  Median :40.00   Median :17.00   Median :21.00   Median :201.0  
##  Mean   :39.77   Mean   :17.11   Mean   :20.77   Mean   :276.2  
##  3rd Qu.:40.00   3rd Qu.:17.00   3rd Qu.:21.00   3rd Qu.:354.0  
##  Max.   :40.00   Max.   :18.00   Max.   :21.00   Max.   :676.0  
##   PricePremium   PriceRelative      SeatsTotal  PitchDifference 
##  Min.   :228.0   Min.   :0.1200   Min.   :140   Min.   : 6.000  
##  1st Qu.:318.0   1st Qu.:0.4800   1st Qu.:140   1st Qu.:10.000  
##  Median :483.0   Median :0.8200   Median :166   Median :10.000  
##  Mean   :483.4   Mean   :0.9397   Mean   :156   Mean   : 9.541  
##  3rd Qu.:569.0   3rd Qu.:1.2900   3rd Qu.:170   3rd Qu.:10.000  
##  Max.   :931.0   Max.   :1.8900   Max.   :170   Max.   :10.000  
##  WidthDifference PercentPremiumSeats
##  Min.   :1.000   Min.   : 4.71      
##  1st Qu.:4.000   1st Qu.: 4.71      
##  Median :4.000   Median :11.43      
##  Mean   :3.656   Mean   :10.17      
##  3rd Qu.:4.000   3rd Qu.:11.43      
##  Max.   :4.000   Max.   :16.87

Plot of Premium Ticket Prices versus Economy Ticket Prices

plot(~PriceEconomy + PricePremium, main="Premium Economy Price vs Economy Price")

## Scatter Plot of Premium Ticket Prices versus Economy Ticket Prices

scatterplotMatrix(~PricePremium+PriceEconomy+PitchDifference+WidthDifference, data=airlines.df,
main="Premium Ticket Prices vs Economy Ticket Prices")

## Relative Pricing of both kinds of flights for various months,airlines & aircrafts

library("lattice", lib.loc="~/R/win-library/3.4")
bwplot(PriceRelative~Airline|IsInternational, data=airlines.df)

bwplot(PriceRelative~Aircraft|IsInternational, data=airlines.df)

bwplot(PriceRelative~TravelMonth|IsInternational, data=airlines.df)

## Tests to check the effects of various Flight Parameters on Pricing Strategies

pairs(formula=~PriceRelative+PitchDifference, data=airlines.df)

library("corrgram", lib.loc="~/R/win-library/3.4")
corrgram(airlines.df,lower.panel=panel.shade, upper.panel=NULL)

t.test(PricePremium,PriceEconomy)
## 
##  Welch Two Sample t-test
## 
## data:  PricePremium and PriceEconomy
## t = 6.8304, df = 856.56, p-value = 1.605e-11
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  369.2793 667.0831
## sample estimates:
## mean of x mean of y 
##  1845.258  1327.076
t.test(PriceRelative,WidthDifference)
## 
##  Welch Two Sample t-test
## 
## data:  PriceRelative and WidthDifference
## t = -19.284, df = 585.55, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -1.262697 -1.029268
## sample estimates:
## mean of x mean of y 
## 0.4872052 1.6331878
t.test(PriceRelative,PitchDifference)
## 
##  Welch Two Sample t-test
## 
## data:  PriceRelative and PitchDifference
## t = -72.974, df = 516.54, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -6.367495 -6.033640
## sample estimates:
## mean of x mean of y 
## 0.4872052 6.6877729
t.test(PriceRelative,PercentPremiumSeats)
## 
##  Welch Two Sample t-test
## 
## data:  PriceRelative and PercentPremiumSeats
## t = -62.302, df = 464.91, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -14.60477 -13.71164
## sample estimates:
##  mean of x  mean of y 
##  0.4872052 14.6454148

Regression Models to evaluate Premium Ticket Prices as a function of various other factors

fit1<-lm(PriceRelative~WidthDifference+PitchDifference+IsInternational+Aircraft+Airline+PercentPremiumSeats, data=airlines.df)
summary(fit1) ## Very weak model since it can explain only 35% of the variation
## 
## Call:
## lm(formula = PriceRelative ~ WidthDifference + PitchDifference + 
##     IsInternational + Aircraft + Airline + PercentPremiumSeats, 
##     data = airlines.df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.92920 -0.21430 -0.06758  0.11411  1.41175 
## 
## Coefficients:
##                               Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -0.189710   0.285841  -0.664 0.507230    
## WidthDifference              -0.031802   0.082394  -0.386 0.699699    
## PitchDifference               0.052158   0.063768   0.818 0.413829    
## IsInternationalInternational  0.248939   0.243519   1.022 0.307211    
## AircraftBoeing                0.109465   0.044146   2.480 0.013520 *  
## AirlineBritish                0.238393   0.111512   2.138 0.033073 *  
## AirlineDelta                  0.279896   0.185227   1.511 0.131469    
## AirlineJet                    0.558526   0.141688   3.942 9.38e-05 ***
## AirlineSingapore              0.305527   0.081038   3.770 0.000185 ***
## AirlineVirgin                 0.622672   0.110779   5.621 3.35e-08 ***
## PercentPremiumSeats          -0.015370   0.004589  -3.349 0.000879 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3672 on 447 degrees of freedom
## Multiple R-squared:  0.3505, Adjusted R-squared:  0.336 
## F-statistic: 24.12 on 10 and 447 DF,  p-value: < 2.2e-16
fit2<-lm(PricePremium~PriceEconomy+WidthDifference+PitchDifference+IsInternational+Aircraft+Airline+PercentPremiumSeats, data=airlines.df)
summary(fit2) ## Can explain 88% of the variation,making it to be a good fit
## 
## Call:
## lm(formula = PricePremium ~ PriceEconomy + WidthDifference + 
##     PitchDifference + IsInternational + Aircraft + Airline + 
##     PercentPremiumSeats, data = airlines.df)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -764.25 -273.97  -48.45  113.47 2992.49 
## 
## Coefficients:
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -907.41964  356.28049  -2.547 0.011203 *  
## PriceEconomy                    1.28330    0.03705  34.635  < 2e-16 ***
## WidthDifference              -111.26957  102.88310  -1.082 0.280053    
## PitchDifference                32.44698   79.48605   0.408 0.683316    
## IsInternationalInternational  545.24275  320.37657   1.702 0.089475 .  
## AircraftBoeing                106.07548   57.76813   1.836 0.066989 .  
## AirlineBritish                778.75194  151.98215   5.124 4.46e-07 ***
## AirlineDelta                  939.92534  231.05147   4.068 5.61e-05 ***
## AirlineJet                    684.79734  192.31458   3.561 0.000409 ***
## AirlineSingapore              572.45834  125.92648   4.546 7.05e-06 ***
## AirlineVirgin                1377.93939  141.56578   9.734  < 2e-16 ***
## PercentPremiumSeats           -18.71280    5.72975  -3.266 0.001175 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 457.5 on 446 degrees of freedom
## Multiple R-squared:  0.8769, Adjusted R-squared:  0.8739 
## F-statistic: 288.8 on 11 and 446 DF,  p-value: < 2.2e-16
fit3<-lm(PricePremium~PriceEconomy+WidthDifference+PitchDifference, data=airlines.df)
summary(fit3) ## If less factors are used,the regression model can predict only 82% variation in Premium Ticket Prices
## 
## Call:
## lm(formula = PricePremium ~ PriceEconomy + WidthDifference + 
##     PitchDifference, data = airlines.df)
## 
## Residuals:
##    Min     1Q Median     3Q    Max 
## -809.9 -325.8  -97.1  176.3 3470.6 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     -33.37619  125.69676  -0.266   0.7907    
## PriceEconomy      1.18456    0.02623  45.152   <2e-16 ***
## WidthDifference  26.25535   33.43032   0.785   0.4326    
## PitchDifference  39.43892   22.59939   1.745   0.0816 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 551.5 on 454 degrees of freedom
## Multiple R-squared:  0.8179, Adjusted R-squared:  0.8167 
## F-statistic: 679.9 on 3 and 454 DF,  p-value: < 2.2e-16