Reading and Understanding the data

Read the data into R.

setwd("D:/manipal-year2/internship/IIML_dataAnalytics/Datasets")
air.df <- read.csv(paste("SixAirlinesDataV2.csv",sep=""))
View(air.df)
head(air.df)
##   Airline Aircraft FlightDuration TravelMonth IsInternational SeatsEconomy
## 1 British   Boeing          12.25         Jul   International          122
## 2 British   Boeing          12.25         Aug   International          122
## 3 British   Boeing          12.25         Sep   International          122
## 4 British   Boeing          12.25         Oct   International          122
## 5 British   Boeing           8.16         Aug   International          122
## 6 British   Boeing           8.16         Sep   International          122
##   SeatsPremium PitchEconomy PitchPremium WidthEconomy WidthPremium
## 1           40           31           38           18           19
## 2           40           31           38           18           19
## 3           40           31           38           18           19
## 4           40           31           38           18           19
## 5           40           31           38           18           19
## 6           40           31           38           18           19
##   PriceEconomy PricePremium PriceRelative SeatsTotal PitchDifference
## 1         2707         3725          0.38        162               7
## 2         2707         3725          0.38        162               7
## 3         2707         3725          0.38        162               7
## 4         2707         3725          0.38        162               7
## 5         1793         2999          0.67        162               7
## 6         1793         2999          0.67        162               7
##   WidthDifference PercentPremiumSeats
## 1               1               24.69
## 2               1               24.69
## 3               1               24.69
## 4               1               24.69
## 5               1               24.69
## 6               1               24.69

Summarize data

Summarize the data to understand the mean, median, standard deviation of each variable.

summary(air.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
library(psych)
describe(air.df)
##                     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
str(air.df)
## '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 ...
dim(air.df)
## [1] 458  18
colnames(air.df)
##  [1] "Airline"             "Aircraft"            "FlightDuration"     
##  [4] "TravelMonth"         "IsInternational"     "SeatsEconomy"       
##  [7] "SeatsPremium"        "PitchEconomy"        "PitchPremium"       
## [10] "WidthEconomy"        "WidthPremium"        "PriceEconomy"       
## [13] "PricePremium"        "PriceRelative"       "SeatsTotal"         
## [16] "PitchDifference"     "WidthDifference"     "PercentPremiumSeats"

Describe per airline data

describe(air.df[which(air.df$Airline=="Virgin"),][c(3,6:18)],skew =FALSE)
##                     vars  n    mean     sd    min     max   range     se
## FlightDuration         1 62    9.25   1.94   6.58   12.58    6.00   0.25
## SeatsEconomy           2 62  230.18  59.26 185.00  375.00  190.00   7.53
## SeatsPremium           3 62   42.53  10.23  35.00   66.00   31.00   1.30
## PitchEconomy           4 62   31.00   0.00  31.00   31.00    0.00   0.00
## PitchPremium           5 62   38.00   0.00  38.00   38.00    0.00   0.00
## WidthEconomy           6 62   18.00   0.00  18.00   18.00    0.00   0.00
## WidthPremium           7 62   21.00   0.00  21.00   21.00    0.00   0.00
## PriceEconomy           8 62 1603.53 532.90 540.00 2445.00 1905.00  67.68
## PricePremium           9 62 2721.69 809.55 594.00 3694.00 3100.00 102.81
## PriceRelative         10 62    0.76   0.48   0.10    1.82    1.72   0.06
## SeatsTotal            11 62  272.71  67.59 233.00  441.00  208.00   8.58
## PitchDifference       12 62    7.00   0.00   7.00    7.00    0.00   0.00
## WidthDifference       13 62    3.00   0.00   3.00    3.00    0.00   0.00
## PercentPremiumSeats   14 62   15.75   2.43  14.02   20.60    6.58   0.31
describe(air.df[which(air.df$Airline=="British"),][c(3,6:18)],skew =
           FALSE)
##                     vars   n    mean      sd    min     max   range     se
## FlightDuration         1 175    7.85    3.68   1.25   13.83   12.58   0.28
## SeatsEconomy           2 175  216.59   74.68 122.00  312.00  190.00   5.65
## SeatsPremium           3 175   43.18    9.57  24.00   56.00   32.00   0.72
## PitchEconomy           4 175   31.00    0.00  31.00   31.00    0.00   0.00
## PitchPremium           5 175   38.00    0.00  38.00   38.00    0.00   0.00
## WidthEconomy           6 175   18.00    0.00  18.00   18.00    0.00   0.00
## WidthPremium           7 175   19.00    0.00  19.00   19.00    0.00   0.00
## PriceEconomy           8 175 1293.48  781.46  65.00 3102.00 3037.00  59.07
## PricePremium           9 175 1937.03 1340.31  86.00 7414.00 7328.00 101.32
## PriceRelative         10 175    0.44    0.32   0.04    1.39    1.35   0.02
## SeatsTotal            11 175  259.77   80.55 162.00  367.00  205.00   6.09
## PitchDifference       12 175    7.00    0.00   7.00    7.00    0.00   0.00
## WidthDifference       13 175    1.00    0.00   1.00    1.00    0.00   0.00
## PercentPremiumSeats   14 175   17.79    5.19  10.57   24.69   14.12   0.39
describe(air.df[which(air.df$Airline=="Jet"),][c(3,6:18)],skew =
           FALSE)
##                     vars  n   mean     sd    min    max  range    se
## FlightDuration         1 61   4.14   2.07   2.50   9.50   7.00  0.26
## SeatsEconomy           2 61 140.31  16.57 124.00 162.00  38.00  2.12
## SeatsPremium           3 61  15.66   6.50   8.00  28.00  20.00  0.83
## PitchEconomy           4 61  30.23   0.64  30.00  32.00   2.00  0.08
## PitchPremium           5 61  39.77   0.64  38.00  40.00   2.00  0.08
## WidthEconomy           6 61  17.11   0.32  17.00  18.00   1.00  0.04
## WidthPremium           7 61  20.77   0.64  19.00  21.00   2.00  0.08
## PriceEconomy           8 61 276.16 154.52 108.00 676.00 568.00 19.78
## PricePremium           9 61 483.36 185.17 228.00 931.00 703.00 23.71
## PriceRelative         10 61   0.94   0.49   0.12   1.89   1.77  0.06
## SeatsTotal            11 61 155.97  14.40 140.00 170.00  30.00  1.84
## PitchDifference       12 61   9.54   1.29   6.00  10.00   4.00  0.16
## WidthDifference       13 61   3.66   0.96   1.00   4.00   3.00  0.12
## PercentPremiumSeats   14 61  10.17   4.10   4.71  16.87  12.16  0.52
describe(air.df[which(air.df$Airline=="AirFrance"),][c(3,6:18)],skew =
           FALSE)
##                     vars  n    mean     sd     min     max   range    se
## FlightDuration         1 74    8.99   1.62    6.83   13.00    6.17  0.19
## SeatsEconomy           2 74  214.46  88.24  147.00  389.00  242.00 10.26
## SeatsPremium           3 74   26.70   6.20   21.00   38.00   17.00  0.72
## PitchEconomy           4 74   32.00   0.00   32.00   32.00    0.00  0.00
## PitchPremium           5 74   38.00   0.00   38.00   38.00    0.00  0.00
## WidthEconomy           6 74   17.57   0.50   17.00   18.00    1.00  0.06
## WidthPremium           7 74   19.00   0.00   19.00   19.00    0.00  0.00
## PriceEconomy           8 74 2769.78 749.67  630.00 3593.00 2963.00 87.15
## PricePremium           9 74 3065.22 543.21 1611.00 3972.00 2361.00 63.15
## PriceRelative         10 74    0.20   0.41    0.02    1.64    1.62  0.05
## SeatsTotal            11 74  241.16  94.24  168.00  427.00  259.00 10.96
## PitchDifference       12 74    6.00   0.00    6.00    6.00    0.00  0.00
## WidthDifference       13 74    1.43   0.50    1.00    2.00    1.00  0.06
## PercentPremiumSeats   14 74   11.59   1.42    8.90   12.50    3.60  0.16
describe(air.df[which(air.df$Airline=="Delta"),][c(3,6:18)],skew =FALSE)
##                     vars  n   mean     sd    min     max   range     se
## FlightDuration         1 46   4.03   2.24   1.57    9.50    7.93   0.33
## SeatsEconomy           2 46 137.22  44.93  78.00  233.00  155.00   6.62
## SeatsPremium           3 46  22.57   6.79  18.00   38.00   20.00   1.00
## PitchEconomy           4 46  31.72   0.66  31.00   33.00    2.00   0.10
## PitchPremium           5 46  34.72   1.34  34.00   38.00    4.00   0.20
## WidthEconomy           6 46  17.39   0.49  17.00   18.00    1.00   0.07
## WidthPremium           7 46  17.78   1.33  17.00   21.00    4.00   0.20
## PriceEconomy           8 46 560.93 547.65 158.00 1999.00 1841.00  80.75
## PricePremium           9 46 684.67 790.56 173.00 2765.00 2592.00 116.56
## PriceRelative         10 46   0.12   0.11   0.03    0.46    0.43   0.02
## SeatsTotal            11 46 159.78  50.97  98.00  271.00  173.00   7.52
## PitchDifference       12 46   3.00   1.63   2.00    7.00    5.00   0.24
## WidthDifference       13 46   0.39   1.02   0.00    3.00    3.00   0.15
## PercentPremiumSeats   14 46  14.48   2.86  12.50   20.41    7.91   0.42
describe(air.df[which(air.df$Airline=="Singapore"),][c(3,6:18)],skew =FALSE)
##                     vars  n    mean     sd    min     max   range    se
## FlightDuration         1 40   10.48   3.58   3.83   14.66   10.83  0.57
## SeatsEconomy           2 40  243.60  73.92 184.00  333.00  149.00 11.69
## SeatsPremium           3 40   31.20   3.97  28.00   36.00    8.00  0.63
## PitchEconomy           4 40   32.00   0.00  32.00   32.00    0.00  0.00
## PitchPremium           5 40   38.00   0.00  38.00   38.00    0.00  0.00
## WidthEconomy           6 40   19.00   0.00  19.00   19.00    0.00  0.00
## WidthPremium           7 40   20.00   0.00  20.00   20.00    0.00  0.00
## PriceEconomy           8 40  860.25 349.42 505.00 1431.00  926.00 55.25
## PricePremium           9 40 1239.92 359.13 619.00 1947.00 1328.00 56.78
## PriceRelative         10 40    0.53   0.35   0.09    1.11    1.02  0.06
## SeatsTotal            11 40  274.80  77.89 212.00  369.00  157.00 12.32
## PitchDifference       12 40    6.00   0.00   6.00    6.00    0.00  0.00
## WidthDifference       13 40    1.00   0.00   1.00    1.00    0.00  0.00
## PercentPremiumSeats   14 40   11.83   1.71   9.76   13.21    3.45  0.27

Aggregating prices

Find the mean prices for economy and premium classes for each of the airlines.

aggregate(air.df$PricePremium,by=list(airline=air.df$Airline),mean)
##     airline         x
## 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(air.df$PriceEconomy,by=list(airline=air.df$Airline),mean)
##     airline         x
## 1 AirFrance 2769.7838
## 2   British 1293.4800
## 3     Delta  560.9348
## 4       Jet  276.1639
## 5 Singapore  860.2500
## 6    Virgin 1603.5323

Summary of certain important columns

Find the summary for economy and premium classes for each of the airlines.

summary(air.df$SeatsEconomy)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    78.0   133.0   185.0   202.3   243.0   389.0
summary(air.df$SeatsPremium)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    8.00   21.00   36.00   33.65   40.00   66.00
summary(air.df$SeatsTotal)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      98     166     227     236     279     441
summary(air.df$PriceEconomy)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##      65     413    1242    1327    1909    3593
summary(air.df$PricePremium)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##    86.0   528.8  1737.0  1845.3  2989.0  7414.0
summary(air.df$PitchDifference)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   2.000   6.000   7.000   6.688   7.000  10.000
summary(air.df$WidthDifference)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
##   0.000   1.000   1.000   1.633   3.000   4.000

Creating Histograms

hist(air.df$SeatsEconomy, breaks = 5)

hist(air.df$SeatsPremium, breaks = 5)

hist(air.df$SeatsTotal, breaks = 5)

hist(air.df$FlightDuration, breaks = 5)

hist(air.df$PitchEconomy, breaks = 5)

hist(air.df$PitchPremium, breaks = 5)

hist(air.df$PitchDifference, breaks = 5)

hist(air.df$WidthEconomy, breaks = 5)

hist(air.df$WidthPremium, breaks = 5)

hist(air.df$WidthDifference, breaks = 5)

hist(air.df$PriceEconomy, breaks = 5)

hist(air.df$PricePremium, breaks = 5)

hist(air.df$PriceRelative, breaks = 5)

hist(air.df$PercentPremiumSeats, breaks = 5)

Creating Box Plots

boxplot(air.df$SeatsEconomy, horizontal = T)

boxplot(air.df$SeatsPremium, horizontal = T)

boxplot(air.df$SeatsTotal,horizontal = T)

boxplot(air.df$FlightDuration, horizontal = T)

boxplot(air.df$PitchEconomy, horizontal = T)

boxplot(air.df$PitchPremium, horizontal = T)

boxplot(air.df$PitchDifference, horizontal = T)

boxplot(air.df$WidthEconomy, horizontal = T)

boxplot(air.df$WidthPremium, horizontal = T)

boxplot(air.df$WidthDifference, horizontal = T)

boxplot(air.df$PriceEconomy, horizontal = T)

boxplot(air.df$PricePremium, horizontal = T)

boxplot(air.df$PriceRelative, horizontal = T)

boxplot(air.df$PercentPremiumSeats, horizontal = T)

Finding some statistics about the data

aggregate(air.df$PriceRelative, by = list(air.df$Airline), mean)
##     Group.1         x
## 1 AirFrance 0.2047297
## 2   British 0.4375429
## 3     Delta 0.1250000
## 4       Jet 0.9396721
## 5 Singapore 0.5297500
## 6    Virgin 0.7606452
aggregate(air.df$WidthDifference, by = list(air.df$Airline), mean)
##     Group.1         x
## 1 AirFrance 1.4324324
## 2   British 1.0000000
## 3     Delta 0.3913043
## 4       Jet 3.6557377
## 5 Singapore 1.0000000
## 6    Virgin 3.0000000
aggregate(air.df$PitchDifference, by = list(air.df$Airline), mean)
##     Group.1        x
## 1 AirFrance 6.000000
## 2   British 7.000000
## 3     Delta 3.000000
## 4       Jet 9.540984
## 5 Singapore 6.000000
## 6    Virgin 7.000000

Getting some statistics about Categorical Variables

table(air.df$Airline)
## 
## AirFrance   British     Delta       Jet Singapore    Virgin 
##        74       175        46        61        40        62
table(air.df$Aircraft)
## 
## AirBus Boeing 
##    151    307
table(air.df$TravelMonth)
## 
## Aug Jul Oct Sep 
## 127  75 127 129
table(air.df$IsInternational)
## 
##      Domestic International 
##            40           418
table(air.df$TravelMonth)
## 
## Aug Jul Oct Sep 
## 127  75 127 129

Finding some relations

xtabs(~air.df$Airline+air.df$TravelMonth)
##               air.df$TravelMonth
## air.df$Airline Aug Jul Oct Sep
##      AirFrance  20  12  20  22
##      British    52  16  53  54
##      Delta      12  10  13  11
##      Jet        16  15  15  15
##      Singapore  11   8  10  11
##      Virgin     16  14  16  16
xtabs(~air.df$Airline+air.df$PitchDifference)
##               air.df$PitchDifference
## air.df$Airline   2   3   6   7  10
##      AirFrance   0   0  74   0   0
##      British     0   0   0 175   0
##      Delta      24  16   0   6   0
##      Jet         0   0   7   0  54
##      Singapore   0   0  40   0   0
##      Virgin      0   0   0  62   0
xtabs(~air.df$Airline+air.df$WidthDifference)
##               air.df$WidthDifference
## air.df$Airline   0   1   2   3   4
##      AirFrance   0  42  32   0   0
##      British     0 175   0   0   0
##      Delta      40   0   0   6   0
##      Jet         0   7   0   0  54
##      Singapore   0  40   0   0   0
##      Virgin      0   0   0  62   0

Drawing Scatterplots and other graphs

attach(air.df)
pairs(formula = ~ Aircraft + Airline+ PricePremium + PercentPremiumSeats )

pairs(formula = ~ PriceEconomy + PitchEconomy + WidthEconomy)

pairs(formula = ~ PricePremium + PitchPremium + WidthPremium)

pairs(formula = ~ PriceRelative + WidthDifference + PitchDifference)

library(car)
scatterplot(PriceRelative, WidthDifference)

scatterplot(PriceRelative, PitchDifference)

scatterplot(PriceRelative, FlightDuration)

scatterplot(PriceRelative, SeatsEconomy)

scatterplot(PriceRelative, SeatsPremium)

airPricePitch <- table(PriceRelative, PitchDifference)
barplot(airPricePitch, main = "Price Difference With Respect to Legspace Difference", xlab = "Amount of Legspace", ylab = "Price Difference")

airPriceWidth <- table(PriceRelative, WidthDifference)
barplot(airPriceWidth, main = "Price Difference With Respect to Width Difference", xlab = "Amount of Width", ylab = "Price Difference")

library(lattice)
bwplot(Airline ~ PriceRelative, horizontal=TRUE)

Finding Correlation and covariance Matrix

cor(air.df[,c(3,6:17)])
##                 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
##                 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
##                 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
##                 WidthDifference
## FlightDuration      -0.11856070
## SeatsEconomy        -0.08067015
## SeatsPremium        -0.21616867
## PitchEconomy        -0.63557430
## PitchPremium         0.70328180
## WidthEconomy        -0.39320512
## WidthPremium         0.88414965
## PriceEconomy        -0.08449975
## PricePremium        -0.01151218
## PriceRelative        0.48580244
## SeatsTotal          -0.10584398
## PitchDifference      0.76089108
## WidthDifference      1.00000000
cov(air.df[,c(3,6:17)])
##                 FlightDuration  SeatsEconomy  SeatsPremium PitchEconomy
## FlightDuration      12.5462183    52.9194291    7.57372426    0.6817421
## SeatsEconomy        52.9194291  5832.9154300  633.07060954    7.2117665
## SeatsPremium         7.5737243   633.0706095  175.86521648   -0.2972586
## PitchEconomy         0.6817421     7.2117665   -0.29725856    0.4292471
## PitchPremium         0.4477835    11.9637325    0.08508595   -0.4739855
## WidthEconomy         0.9014224    15.9105138    3.36977440    0.1075650
## WidthPremium         0.4019845     8.5832800   -0.03954019   -0.3876621
## PriceEconomy      1983.5401655  9673.7944684 1489.38359627  238.7031905
## PricePremium      2959.9783043 17413.2541733 3717.36428960  190.8517195
## PriceRelative        0.1932368     0.1361699   -0.58078765   -0.1248808
## SeatsTotal          60.4931534  6465.9860396  808.93582602    6.9145079
## PitchDifference     -0.2339587     4.7519660    0.38234451   -0.9032326
## WidthDifference     -0.4994380    -7.3272338   -3.40931459   -0.4952271
##                 PitchPremium WidthEconomy WidthPremium  PriceEconomy
## FlightDuration    0.44778348   0.90142242   0.40198446    1983.54017
## SeatsEconomy     11.96373253  15.91051379   8.58327998    9673.79447
## SeatsPremium      0.08508595   3.36977440  -0.03954019    1489.38360
## PitchEconomy     -0.47398546   0.10756500  -0.38766208     238.70319
## PitchPremium      1.72639580  -0.01739081   1.08157435      65.42513
## WidthEconomy     -0.01739081   0.31081765   0.05010845      37.46095
## WidthPremium      1.08157435   0.05010845   1.20378776     -61.85450
## PriceEconomy     65.42513354  37.46095191 -61.85450011  976684.06198
## PricePremium    149.85356368 108.11611707  90.47997668 1147494.76801
## PriceRelative     0.24719874  -0.01104335   0.24928593    -128.49992
## SeatsTotal       12.04881848  19.28028819   8.54373979   11163.17806
## PitchDifference   2.20038126  -0.12495581   1.46923643    -173.27806
## WidthDifference   1.09896515  -0.26070920   1.15367930     -99.31545
##                  PricePremium PriceRelative    SeatsTotal PitchDifference
## FlightDuration     2959.97830    0.19323683    60.4931534      -0.2339587
## SeatsEconomy      17413.25417    0.13616991  6465.9860396       4.7519660
## SeatsPremium       3717.36429   -0.58078765   808.9358260       0.3823445
## PitchEconomy        190.85172   -0.12488080     6.9145079      -0.9032326
## PitchPremium        149.85356    0.24719874    12.0488185       2.2003813
## WidthEconomy        108.11612   -0.01104335    19.2802882      -0.1249558
## WidthPremium         90.47998    0.24928593     8.5437398       1.4692364
## PriceEconomy    1147494.76801 -128.49991725 11163.1780647    -173.2780570
## PricePremium    1659293.11947   18.48428836 21130.6184629     -40.9981558
## PriceRelative        18.48429    0.20302893    -0.4446177       0.3720795
## SeatsTotal        21130.61846   -0.44461774  7274.9218656       5.1343105
## PitchDifference     -40.99816    0.37207954     5.1343105       3.1036138
## WidthDifference     -17.63614    0.26032928   -10.7365484       1.5941922
##                 WidthDifference
## FlightDuration       -0.4994380
## SeatsEconomy         -7.3272338
## SeatsPremium         -3.4093146
## PitchEconomy         -0.4952271
## PitchPremium          1.0989652
## WidthEconomy         -0.2607092
## WidthPremium          1.1536793
## PriceEconomy        -99.3154520
## PricePremium        -17.6361404
## PriceRelative         0.2603293
## SeatsTotal          -10.7365484
## PitchDifference       1.5941922
## WidthDifference       1.4143885
round(cor(air.df[,c(3,6:17)]),2)
##                 FlightDuration SeatsEconomy SeatsPremium PitchEconomy
## FlightDuration            1.00         0.20         0.16         0.29
## SeatsEconomy              0.20         1.00         0.63         0.14
## SeatsPremium              0.16         0.63         1.00        -0.03
## PitchEconomy              0.29         0.14        -0.03         1.00
## PitchPremium              0.10         0.12         0.00        -0.55
## WidthEconomy              0.46         0.37         0.46         0.29
## WidthPremium              0.10         0.10         0.00        -0.54
## PriceEconomy              0.57         0.13         0.11         0.37
## PricePremium              0.65         0.18         0.22         0.23
## PriceRelative             0.12         0.00        -0.10        -0.42
## SeatsTotal                0.20         0.99         0.72         0.12
## PitchDifference          -0.04         0.04         0.02        -0.78
## WidthDifference          -0.12        -0.08        -0.22        -0.64
##                 PitchPremium WidthEconomy WidthPremium PriceEconomy
## FlightDuration          0.10         0.46         0.10         0.57
## SeatsEconomy            0.12         0.37         0.10         0.13
## SeatsPremium            0.00         0.46         0.00         0.11
## PitchEconomy           -0.55         0.29        -0.54         0.37
## PitchPremium            1.00        -0.02         0.75         0.05
## WidthEconomy           -0.02         1.00         0.08         0.07
## WidthPremium            0.75         0.08         1.00        -0.06
## PriceEconomy            0.05         0.07        -0.06         1.00
## PricePremium            0.09         0.15         0.06         0.90
## PriceRelative           0.42        -0.04         0.50        -0.29
## SeatsTotal              0.11         0.41         0.09         0.13
## PitchDifference         0.95        -0.13         0.76        -0.10
## WidthDifference         0.70        -0.39         0.88        -0.08
##                 PricePremium PriceRelative SeatsTotal PitchDifference
## FlightDuration          0.65          0.12       0.20           -0.04
## SeatsEconomy            0.18          0.00       0.99            0.04
## SeatsPremium            0.22         -0.10       0.72            0.02
## PitchEconomy            0.23         -0.42       0.12           -0.78
## PitchPremium            0.09          0.42       0.11            0.95
## WidthEconomy            0.15         -0.04       0.41           -0.13
## WidthPremium            0.06          0.50       0.09            0.76
## PriceEconomy            0.90         -0.29       0.13           -0.10
## PricePremium            1.00          0.03       0.19           -0.02
## PriceRelative           0.03          1.00      -0.01            0.47
## SeatsTotal              0.19         -0.01       1.00            0.03
## PitchDifference        -0.02          0.47       0.03            1.00
## WidthDifference        -0.01          0.49      -0.11            0.76
##                 WidthDifference
## FlightDuration            -0.12
## SeatsEconomy              -0.08
## SeatsPremium              -0.22
## PitchEconomy              -0.64
## PitchPremium               0.70
## WidthEconomy              -0.39
## WidthPremium               0.88
## PriceEconomy              -0.08
## PricePremium              -0.01
## PriceRelative              0.49
## SeatsTotal                -0.11
## PitchDifference            0.76
## WidthDifference            1.00

Plots to find changes with flight durations

plot(FlightDuration,PriceEconomy,
     main="Flight duration vs Economy Price",
     xlab="flight duration",
     ylab = "Economy Price")
abline(lm(PriceEconomy~FlightDuration),
       col="blue")

plot(FlightDuration,PricePremium,
     main="Flight duration vs Premium Price",
     xlab="flight duration",
     ylab = "Economy Price")
abline(lm(PricePremium~FlightDuration),
       col="blue")

plot(PitchDifference,PriceRelative,main = "Analysis of Pitch with price Difference")
abline(lm(PriceRelative~PitchDifference),col="blue")

plot(WidthDifference,PriceRelative,main = "Analysis of width with price Difference")
abline(lm(PriceRelative~WidthDifference),col="blue")

Drawing Corrgram

library(corrgram)
corrgram(air.df, order=TRUE, lower.panel=panel.shade,
         upper.panel=panel.pie, text.panel=panel.txt,
         main="Corrgram of airlines data")

Finding Correlations

cor(PriceRelative,FlightDuration)
## [1] 0.121075
cor(PriceRelative,SeatsEconomy)
## [1] 0.003956939
cor(PriceRelative,SeatsPremium)
## [1] -0.09719601
cor(PriceRelative,WidthEconomy)
## [1] -0.04396116
cor(PriceRelative,WidthPremium)
## [1] 0.5042476
cor(PriceRelative,PitchEconomy)
## [1] -0.423022
cor(PriceRelative,PitchPremium)
## [1] 0.4175391

Insights and formulation of Hypothesis

We can observe the following insights -

The flight prices are related directly with flight duration and timing.

The width and pitch is higher in the premium aircrafts as compared to the economy ones, providing more comfort.

There are a large number of economy seats, accounting to about 90 percent of the total seats.

Prices are directly correlated with pitch difference and width difference.

More the number of economy seats, lesser is the percentage premium seats.

The graph clearly represents high correlation between the above discussed variables which were further investigated using regression

Hypothesis -

The prices of premium and economy seats are positively increase with flight duration, increase in width diference and pitch difference as well as depending on whether the flight is international or domestic.

The relative prices of premium and economy class are directly correlated with the pitch difference and width difference.

Running T-Tests

cor.test(PriceRelative,PitchDifference)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and PitchDifference
## t = 11.331, df = 456, p-value < 2.2e-16
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.3940262 0.5372817
## sample estimates:
##       cor 
## 0.4687302
cor.test(PriceRelative,WidthDifference)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and 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
cor.test(PriceRelative,FlightDuration)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and FlightDuration
## t = 2.6046, df = 456, p-value = 0.009498
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  0.02977856 0.21036806
## sample estimates:
##      cor 
## 0.121075
cor.test(PriceRelative,SeatsTotal)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and SeatsTotal
## t = -0.24706, df = 456, p-value = 0.805
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.10308648  0.08014282
## sample estimates:
##         cor 
## -0.01156894
cor.test(PriceRelative,SeatsEconomy)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and SeatsEconomy
## t = 0.084498, df = 456, p-value = 0.9327
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.08770167  0.09554911
## sample estimates:
##         cor 
## 0.003956939
cor.test(PriceRelative,SeatsPremium)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and SeatsPremium
## t = -2.0854, df = 456, p-value = 0.03759
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.18715605 -0.00561924
## sample estimates:
##         cor 
## -0.09719601
cor.test(PriceRelative,PercentPremiumSeats)
## 
##  Pearson's product-moment correlation
## 
## data:  PriceRelative and PercentPremiumSeats
## t = -3.496, df = 456, p-value = 0.0005185
## alternative hypothesis: true correlation is not equal to 0
## 95 percent confidence interval:
##  -0.24949885 -0.07098966
## sample estimates:
##        cor 
## -0.1615656
corr.test(air.df[,c(3,6:18)])
## Call:corr.test(x = air.df[, c(3, 6:18)])
## Correlation matrix 
##                     FlightDuration SeatsEconomy SeatsPremium PitchEconomy
## FlightDuration                1.00         0.20         0.16         0.29
## SeatsEconomy                  0.20         1.00         0.63         0.14
## SeatsPremium                  0.16         0.63         1.00        -0.03
## PitchEconomy                  0.29         0.14        -0.03         1.00
## PitchPremium                  0.10         0.12         0.00        -0.55
## WidthEconomy                  0.46         0.37         0.46         0.29
## WidthPremium                  0.10         0.10         0.00        -0.54
## PriceEconomy                  0.57         0.13         0.11         0.37
## PricePremium                  0.65         0.18         0.22         0.23
## PriceRelative                 0.12         0.00        -0.10        -0.42
## SeatsTotal                    0.20         0.99         0.72         0.12
## PitchDifference              -0.04         0.04         0.02        -0.78
## WidthDifference              -0.12        -0.08        -0.22        -0.64
## PercentPremiumSeats           0.06        -0.33         0.49        -0.10
##                     PitchPremium WidthEconomy WidthPremium PriceEconomy
## FlightDuration              0.10         0.46         0.10         0.57
## SeatsEconomy                0.12         0.37         0.10         0.13
## SeatsPremium                0.00         0.46         0.00         0.11
## PitchEconomy               -0.55         0.29        -0.54         0.37
## PitchPremium                1.00        -0.02         0.75         0.05
## WidthEconomy               -0.02         1.00         0.08         0.07
## WidthPremium                0.75         0.08         1.00        -0.06
## PriceEconomy                0.05         0.07        -0.06         1.00
## PricePremium                0.09         0.15         0.06         0.90
## PriceRelative               0.42        -0.04         0.50        -0.29
## SeatsTotal                  0.11         0.41         0.09         0.13
## PitchDifference             0.95        -0.13         0.76        -0.10
## WidthDifference             0.70        -0.39         0.88        -0.08
## PercentPremiumSeats        -0.18         0.23        -0.18         0.07
##                     PricePremium PriceRelative SeatsTotal PitchDifference
## FlightDuration              0.65          0.12       0.20           -0.04
## SeatsEconomy                0.18          0.00       0.99            0.04
## SeatsPremium                0.22         -0.10       0.72            0.02
## PitchEconomy                0.23         -0.42       0.12           -0.78
## PitchPremium                0.09          0.42       0.11            0.95
## WidthEconomy                0.15         -0.04       0.41           -0.13
## WidthPremium                0.06          0.50       0.09            0.76
## PriceEconomy                0.90         -0.29       0.13           -0.10
## PricePremium                1.00          0.03       0.19           -0.02
## PriceRelative               0.03          1.00      -0.01            0.47
## SeatsTotal                  0.19         -0.01       1.00            0.03
## PitchDifference            -0.02          0.47       0.03            1.00
## WidthDifference            -0.01          0.49      -0.11            0.76
## PercentPremiumSeats         0.12         -0.16      -0.22           -0.09
##                     WidthDifference PercentPremiumSeats
## FlightDuration                -0.12                0.06
## SeatsEconomy                  -0.08               -0.33
## SeatsPremium                  -0.22                0.49
## PitchEconomy                  -0.64               -0.10
## PitchPremium                   0.70               -0.18
## WidthEconomy                  -0.39                0.23
## WidthPremium                   0.88               -0.18
## PriceEconomy                  -0.08                0.07
## PricePremium                  -0.01                0.12
## PriceRelative                  0.49               -0.16
## SeatsTotal                    -0.11               -0.22
## PitchDifference                0.76               -0.09
## WidthDifference                1.00               -0.28
## PercentPremiumSeats           -0.28                1.00
## Sample Size 
## [1] 458
## Probability values (Entries above the diagonal are adjusted for multiple tests.) 
##                     FlightDuration SeatsEconomy SeatsPremium PitchEconomy
## FlightDuration                0.00         0.00         0.02         0.00
## SeatsEconomy                  0.00         0.00         0.00         0.09
## SeatsPremium                  0.00         0.00         0.00         1.00
## PitchEconomy                  0.00         0.00         0.47         0.00
## PitchPremium                  0.04         0.01         0.92         0.00
## WidthEconomy                  0.00         0.00         0.00         0.00
## WidthPremium                  0.03         0.03         0.95         0.00
## PriceEconomy                  0.00         0.01         0.01         0.00
## PricePremium                  0.00         0.00         0.00         0.00
## PriceRelative                 0.01         0.93         0.04         0.00
## SeatsTotal                    0.00         0.00         0.00         0.01
## PitchDifference               0.42         0.45         0.73         0.00
## WidthDifference               0.01         0.08         0.00         0.00
## PercentPremiumSeats           0.20         0.00         0.00         0.03
##                     PitchPremium WidthEconomy WidthPremium PriceEconomy
## FlightDuration              1.00         0.00         0.86         0.00
## SeatsEconomy                0.41         0.00         0.86         0.25
## SeatsPremium                1.00         0.00         1.00         0.52
## PitchEconomy                0.00         0.00         0.00         0.00
## PitchPremium                0.00         1.00         0.00         1.00
## WidthEconomy                0.61         0.00         1.00         1.00
## WidthPremium                0.00         0.08         0.00         1.00
## PriceEconomy                0.28         0.15         0.22         0.00
## PricePremium                0.06         0.00         0.17         0.00
## PriceRelative               0.00         0.35         0.00         0.00
## SeatsTotal                  0.02         0.00         0.05         0.00
## PitchDifference             0.00         0.01         0.00         0.03
## WidthDifference             0.00         0.00         0.00         0.07
## PercentPremiumSeats         0.00         0.00         0.00         0.16
##                     PricePremium PriceRelative SeatsTotal PitchDifference
## FlightDuration              0.00          0.37       0.00            1.00
## SeatsEconomy                0.01          1.00       0.00            1.00
## SeatsPremium                0.00          1.00       0.00            1.00
## PitchEconomy                0.00          0.00       0.32            0.00
## PitchPremium                1.00          0.00       0.73            0.00
## WidthEconomy                0.06          1.00       0.00            0.26
## WidthPremium                1.00          0.00       1.00            0.00
## PriceEconomy                0.00          0.00       0.19            0.96
## PricePremium                0.00          1.00       0.00            1.00
## PriceRelative               0.50          0.00       1.00            0.00
## SeatsTotal                  0.00          0.80       0.00            1.00
## PitchDifference             0.70          0.00       0.47            0.00
## WidthDifference             0.81          0.00       0.02            0.00
## PercentPremiumSeats         0.01          0.00       0.00            0.05
##                     WidthDifference PercentPremiumSeats
## FlightDuration                 0.41                1.00
## SeatsEconomy                   1.00                0.00
## SeatsPremium                   0.00                0.00
## PitchEconomy                   0.00                0.86
## PitchPremium                   0.00                0.01
## WidthEconomy                   0.00                0.00
## WidthPremium                   0.00                0.00
## PriceEconomy                   1.00                1.00
## PricePremium                   1.00                0.46
## PriceRelative                  0.00                0.02
## SeatsTotal                     0.78                0.00
## PitchDifference                0.00                1.00
## WidthDifference                0.00                0.00
## PercentPremiumSeats            0.00                0.00
## 
##  To see confidence intervals of the correlations, print with the short=FALSE option

These tests, using the p-values, show that the relative prices of the Premium and Economy flight are related by difference in pitch and width as well as flight duration, rejecting the null hypothesis. There is also a positive relation between percent premium seats and the prices.

Formulating a Regression Model

Dependent variable - PriceRelative Independent cariables - PitchDifference, WidthDifference, PercentPremiumSeats and Flight Duration

Fiting the linear model using all variables

fitt <- lm(formula = air.df$PriceRelative~., data = air.df)
summary(fitt)
## 
## Call:
## lm(formula = air.df$PriceRelative ~ ., data = air.df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.76373 -0.08269  0.00438  0.08002  0.84672 
## 
## Coefficients: (3 not defined because of singularities)
##                                Estimate Std. Error t value Pr(>|t|)    
## (Intercept)                  -3.993e-01  2.948e+00  -0.135 0.892302    
## AirlineBritish               -3.971e-01  1.107e-01  -3.586 0.000373 ***
## AirlineDelta                 -3.865e-01  2.203e-01  -1.755 0.080020 .  
## AirlineJet                   -2.584e-01  9.594e-02  -2.693 0.007354 ** 
## AirlineSingapore             -3.535e-01  1.297e-01  -2.725 0.006685 ** 
## AirlineVirgin                -3.575e-01  2.031e-01  -1.761 0.078997 .  
## AircraftBoeing                4.003e-02  2.968e-02   1.349 0.178089    
## FlightDuration                2.613e-02  4.727e-03   5.526 5.63e-08 ***
## TravelMonthJul                2.111e-02  3.145e-02   0.671 0.502475    
## TravelMonthOct                2.778e-02  2.670e-02   1.041 0.298619    
## TravelMonthSep               -6.617e-03  2.664e-02  -0.248 0.803924    
## IsInternationalInternational  2.785e-02  2.502e-01   0.111 0.911400    
## SeatsEconomy                  8.090e-04  5.462e-04   1.481 0.139313    
## SeatsPremium                 -7.374e-03  3.615e-03  -2.040 0.041967 *  
## PitchEconomy                 -1.756e-02  7.994e-02  -0.220 0.826207    
## PitchPremium                  5.960e-02  9.165e-02   0.650 0.515823    
## WidthEconomy                 -9.207e-02  5.266e-02  -1.748 0.081085 .  
## WidthPremium                  4.904e-02  1.365e-01   0.359 0.719527    
## PriceEconomy                 -9.325e-04  3.318e-05 -28.105  < 2e-16 ***
## PricePremium                  5.781e-04  2.294e-05  25.197  < 2e-16 ***
## SeatsTotal                           NA         NA      NA       NA    
## PitchDifference                      NA         NA      NA       NA    
## WidthDifference                      NA         NA      NA       NA    
## PercentPremiumSeats           1.114e-02  7.653e-03   1.456 0.146197    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.2123 on 437 degrees of freedom
## Multiple R-squared:  0.7878, Adjusted R-squared:  0.7781 
## F-statistic: 81.12 on 20 and 437 DF,  p-value: < 2.2e-16

Fiting linear model according to our requirement

fitt <- lm(formula = air.df$PriceRelative~ PitchDifference+WidthDifference+FlightDuration+PercentPremiumSeats, data = air.df)
summary(fitt)
## 
## Call:
## lm(formula = air.df$PriceRelative ~ PitchDifference + WidthDifference + 
##     FlightDuration + PercentPremiumSeats, data = air.df)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.79439 -0.29424 -0.03427  0.16197  1.13688 
## 
## Coefficients:
##                      Estimate Std. Error t value Pr(>|t|)    
## (Intercept)         -0.179033   0.101492  -1.764  0.07840 .  
## PitchDifference      0.059311   0.015921   3.725  0.00022 ***
## WidthDifference      0.118140   0.024555   4.811 2.05e-06 ***
## FlightDuration       0.021707   0.005085   4.269 2.39e-05 ***
## PercentPremiumSeats -0.005999   0.003898  -1.539  0.12454    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.381 on 453 degrees of freedom
## Multiple R-squared:  0.2913, Adjusted R-squared:  0.285 
## F-statistic: 46.54 on 4 and 453 DF,  p-value: < 2.2e-16
coefficients(fitt)
##         (Intercept)     PitchDifference     WidthDifference 
##        -0.179033482         0.059310975         0.118140211 
##      FlightDuration PercentPremiumSeats 
##         0.021707245        -0.005999062
confint(fitt)
##                           2.5 %      97.5 %
## (Intercept)         -0.37848675 0.020419787
## PitchDifference      0.02802222 0.090599731
## WidthDifference      0.06988357 0.166396852
## FlightDuration       0.01171405 0.031700439
## PercentPremiumSeats -0.01366032 0.001662193
fitted(fitt)
##            1            2            3            4            5 
##  0.472080459  0.472080459  0.472080459  0.472080459  0.383297829 
##            6            7            8            9           10 
##  0.383297829  0.383297829  0.347263803  0.347263803  0.455800026 
##           11           12           13           14           15 
##  0.455800026  0.455800026  0.455800026  0.457536605  0.457536605 
##           16           17           18           19           20 
##  0.457536605  0.405005073  0.405005073  0.405005073  0.352690614 
##           21           22           23           24           25 
##  0.352690614  0.352690614  0.350736962  0.350736962  0.350736962 
##           26           27           28           29           30 
##  0.396105103  0.396105103  0.396105103  0.312749284  0.312749284 
##           31           32           33           34           35 
##  0.312749284  0.289305460  0.289305460  0.289305460  0.289305460 
##           36           37           38           39           40 
##  0.499214515  0.499214515  0.499214515  0.289305460  0.289305460 
##           41           42           43           44           45 
##  0.289305460  0.289305460  0.323602906  0.323602906  0.323602906 
##           46           47           48           49           50 
##  0.385251481  0.385251481  0.385251481  0.482934081  0.482934081 
##           51           52           53           54           55 
##  0.482934081  0.354462677  0.453881857  0.453881857  0.453881857 
##           56           57           58           59           60 
##  0.345345635  0.345345635  0.345345635  0.484706145  0.474937885 
##           61           62           63           64           65 
##  0.484706145  0.640641256  0.640641256  0.640641256  0.640641256 
##           66           67           68           69           70 
##  0.658658269  0.658658269  0.658658269  0.658658269  0.620670591 
##           71           72           73           74           75 
##  0.620670591  0.620670591  0.635214445 -0.078824489 -0.072963533 
##           76           77           78           79           80 
## -0.078824489 -0.079909852 -0.072963533 -0.085553735 -0.073614751 
##           81           82           83           84           85 
## -0.073614751  0.390181604  0.390181604  0.390181604  0.390181604 
##           86           87           88           89           90 
##  0.406462037  0.406462037  0.406462037  0.406462037  0.852291252 
##           91           92           93           94           95 
##  0.852291252  0.852291252  0.852291252  0.852291252  0.852291252 
##           96           97           98           99          100 
##  0.852291252  0.852291252 -0.066683231  0.504390812  0.504390812 
##          101          102          103          104          105 
##  0.504390812  0.504390812  0.490064030  0.490064030  0.490064030 
##          106          107          108          109          110 
##  0.490064030  0.546068721  0.546068721  0.546068721  0.504390812 
##          111          112          113          114          115 
##  0.504390812  0.504390812  0.350703520  0.339849898  0.339849898 
##          116          117          118          119          120 
##  0.314452422  0.332686507  0.332686507  0.339849898  0.319879233 
##          121          122          123          124          125 
##  0.314452422  0.314452422  0.314452422  0.332686507  0.301862220 
##          126          127          128          129          130 
##  0.339849898  0.359820563  0.314452422  0.359820563  0.301862220 
##          131          132          133          134          135 
##  0.314452422  0.339849898  0.350703520  0.323569465  0.359820563 
##          136          137          138          139          140 
##  0.289272018  0.350703520  0.289272018  0.314452422  0.301862220 
##          141          142          143          144          145 
##  0.301862220  0.289272018  0.289272018  0.289272018  0.339849898 
##          146          147          148          149          150 
##  0.323569465  0.291008598  0.291008598  0.289272018  0.316672075 
##          151          152          153          154          155 
##  0.291008598  0.005905413  0.009812717  0.005905413  0.009812717 
##          156          157          158          159          160 
##  0.744664568  0.744664568  0.744664568  0.744664568  0.762681581 
##          161          162          163          164          165 
##  0.762681581  0.762681581  0.762681581  0.715876813  0.715876813 
##          166          167          168          169          170 
##  0.715876813  0.715876813  0.735547525  0.735547525  0.735547525 
##          171          172          173          174          175 
##  0.735547525  0.726430482  0.773535203  0.734110898  0.734110898 
##          176          177          178          179          180 
##  0.734110898  0.734110898  0.773535203  0.746401147  0.666735560 
##          181          182          183          184          185 
##  0.666735560  0.666735560  0.666735560  0.773535203  0.687278476 
##          186          187          188          189          190 
##  0.687278476  0.712675952  0.712675952  0.712675952  0.687278476 
##          191          192          193          194          195 
##  0.656454188  0.656454188  0.656454188  0.656454188  0.649290798 
##          196          197          198          199          200 
##  0.649290798  0.649290798  0.649290798  0.732429544  0.732429544 
##          201          202          203          204          205 
##  0.732429544  0.752400209  0.752400209  0.667307811  0.667307811 
##          206          207          208          209          210 
##  0.667307811  0.667307811  0.660144420  0.674688274  0.674688274 
##          211          212          213          214          215 
##  0.674688274  0.426203128  0.426203128  0.426203128  0.400805652 
##          216          217          218          219          220 
##  0.400805652  0.400805652  0.400805652  0.400805652  0.400805652 
##          221          222          223          224          225 
##  0.400805652  0.400805652  0.379098407  0.379098407  0.379098407 
##          226          227          228          229          230 
##  0.368244785  0.368244785  0.413395854  0.413395854  0.413395854 
##          231          232          233          234          235 
##  0.395378841  0.419256810  0.419256810  0.420776317  0.420776317 
##          236          237          238          239          240 
##  0.418822665  0.418822665  0.420776317  0.420776317  0.502868071 
##          241          242          243          244          245 
##  0.502868071  0.502868071  0.515675345  0.515675345  0.515675345 
##          246          247          248          249          250 
##  0.492014449  0.492014449  0.492014449  0.492014449  0.463143813 
##          251          252          253          254          255 
##  0.463143813  0.463143813  0.524575315  0.524575315  0.524575315 
##          256          257          258          259          260 
##  0.524575315  0.479424247  0.479424247  0.479424247  0.470307204 
##          261          262          263          264          265 
##  0.464880393  0.464880393  0.464880393  0.434273178  0.434273178 
##          266          267          268          269          270 
##  0.434273178  0.470307204  0.430582947  0.430582947  0.430582947 
##          271          272          273          274          275 
##  0.524575315  0.524575315  0.524575315  0.524575315  0.470307204 
##          276          277          278          279          280 
##  0.517411925  0.517411925  0.517411925  0.430582947  0.517411925 
##          281          282          283          284          285 
## -0.042492801 -0.043144018 -0.034895265 -0.034461120 -0.034244048 
##          286          287          288          289          290 
##  0.022155808  0.022155808  0.022155808 -0.040756221 -0.043144018 
##          291          292          293          294          295 
## -0.039236714  0.022155808 -0.042926946 -0.039887931 -0.095858670 
##          296          297          298          299          300 
## -0.096310174 -0.089580928 -0.081966034 -0.081966034 -0.034895265 
##          301          302          303          304          305 
## -0.075236788 -0.099349188 -0.098915043 -0.101319433 -0.083051396 
##          306          307          308          309          310 
## -0.099566261 -0.101319433  0.426203128  0.426203128  0.426203128 
##          311          312          313          314          315 
##  0.413395854  0.413395854  0.426203128  0.413395854  0.517672742 
##          316          317          318          319          320 
##  0.517672742  0.517672742  0.517672742  0.485111876  0.485111876 
##          321          322          323          324          325 
##  0.485111876  0.450814429  0.450814429  0.450814429  0.533953176 
##          326          327          328          329          330 
##  0.533953176  0.533953176  0.425416953  0.425416953  0.425416953 
##          331          332          333          334          335 
##  0.298863717  0.298863717  0.298863717  0.298863717  0.492492339 
##          336          337          338          339          340 
##  0.492492339  0.492492339  0.492492339  0.520265657  0.520265657 
##          341          342          343          344          345 
##  0.520265657  0.502248644  0.487704790  0.529382700  0.529382700 
##          346          347          348          349          350 
##  0.529382700  0.505721803  0.487704790  0.487704790  0.545663133 
##          351          352          353          354          355 
##  0.545663133  0.545663133  0.545663133  0.508635305  0.508635305 
##          356          357          358          359          360 
##  0.508635305  0.510371885  0.543709481  0.543709481  0.543709481 
##          361          362          363          364          365 
##  0.595464283  0.595464283  0.597977593  0.597977593  0.597977593 
##          366          367          368          369          370 
##  0.597977593  0.591084662  0.591084662  0.591084662  0.580231040 
##          371          372          373          374          375 
##  0.580231040  0.580231040  0.484285019  0.484285019  0.484285019 
##          376          377          378          379          380 
##  0.498828873  0.498828873  0.498828873  0.888616381  0.888616381 
##          381          382          383          384          385 
##  0.888616381  0.888616381  0.888616381  0.908369974  0.908369974 
##          386          387          388          389          390 
##  0.906633394  0.872335948  0.872335948  0.872335948  0.875809107 
##          391          392          393          394          395 
##  0.875809107  0.875809107  0.908369974  0.888616381  0.906633394 
##          396          397          398          399          400 
##  0.908369974  0.908369974  0.872335948  0.875809107  0.912060205 
##          401          402          403          404          405 
##  0.912060205  0.912060205  0.912060205  0.888616381  0.888616381 
##          406          407          408          409          410 
##  0.503119231  0.503119231  0.503119231  0.503119231  0.525779305 
##          411          412          413          414          415 
##  0.525779305  0.525779305  0.525779305  0.370138361  0.370138361 
##          416          417          418          419          420 
##  0.370138361  0.370138361  0.511235451  0.511235451  0.511235451 
##          421          422          423          424          425 
##  0.511235451  0.377518824  0.377518824  0.377518824  0.377518824 
##          426          427          428          429          430 
##  0.523775107  0.523775107  0.404385262  0.404385262  0.472980155 
##          431          432          433          434          435 
##  0.472980155  0.472980155  0.424138855  0.426092507  0.426092507 
##          436          437          438          439          440 
##  0.426092507  0.491214241  0.491214241  0.523775107  0.981244537 
##          441          442          443          444          445 
##  0.926976426  0.926976426  0.981244537  0.981244537  0.981244537 
##          446          447          448          449          450 
##  0.981244537  0.981244537  0.926976426  0.914386224  0.914386224 
##          451          452          453          454          455 
##  0.914386224  0.926976426  0.914386224  0.914386224  0.914386224 
##          456          457          458 
##  0.914386224  0.928930078  0.914386224

Since the p-value<2.2e-16,it is safe to reject the null hypothesis and it can be observed that the variables are related.

The model can be written as - PriceRelative = 0.059311PitchDifference + 0.118140WidthDifference + 0.021707FlightDuration + -0.005999PercentPremiumSeats + intercept

Result and Conclusion

The difference in prices of premium and economy airline tickets depends on the factors width and pitch of the seats of the airlines, as well as the flight duration and percentage of premium seats.

The price increases with increase in width, pitch and flight duration. The price decreases with increase in percentage of premium seats.