Basic Analysis

airline = read.csv(paste("SixAirlinesDataV2.csv", sep=""))
attach(airline)
head(airline)
##   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
str(airline)
## 'data.frame':    458 obs. of  18 variables:
##  $ Airline            : Factor w/ 6 levels "AirFrance","British",..: 2 2 2 2 2 2 2 2 2 2 ...
##  $ Aircraft           : Factor w/ 2 levels "AirBus","Boeing": 2 2 2 2 2 2 2 2 2 2 ...
##  $ FlightDuration     : num  12.25 12.25 12.25 12.25 8.16 ...
##  $ TravelMonth        : Factor w/ 4 levels "Aug","Jul","Oct",..: 2 1 4 3 1 4 3 1 4 4 ...
##  $ IsInternational    : Factor w/ 2 levels "Domestic","International": 2 2 2 2 2 2 2 2 2 2 ...
##  $ SeatsEconomy       : int  122 122 122 122 122 122 122 122 122 122 ...
##  $ SeatsPremium       : int  40 40 40 40 40 40 40 40 40 40 ...
##  $ PitchEconomy       : int  31 31 31 31 31 31 31 31 31 31 ...
##  $ PitchPremium       : int  38 38 38 38 38 38 38 38 38 38 ...
##  $ WidthEconomy       : int  18 18 18 18 18 18 18 18 18 18 ...
##  $ WidthPremium       : int  19 19 19 19 19 19 19 19 19 19 ...
##  $ PriceEconomy       : int  2707 2707 2707 2707 1793 1793 1793 1476 1476 1705 ...
##  $ PricePremium       : int  3725 3725 3725 3725 2999 2999 2999 2997 2997 2989 ...
##  $ PriceRelative      : num  0.38 0.38 0.38 0.38 0.67 0.67 0.67 1.03 1.03 0.75 ...
##  $ SeatsTotal         : int  162 162 162 162 162 162 162 162 162 162 ...
##  $ PitchDifference    : int  7 7 7 7 7 7 7 7 7 7 ...
##  $ WidthDifference    : int  1 1 1 1 1 1 1 1 1 1 ...
##  $ PercentPremiumSeats: num  24.7 24.7 24.7 24.7 24.7 ...
summary(airline)
##       Airline      Aircraft   FlightDuration   TravelMonth
##  AirFrance: 74   AirBus:151   Min.   : 1.250   Aug:127    
##  British  :175   Boeing:307   1st Qu.: 4.260   Jul: 75    
##  Delta    : 46                Median : 7.790   Oct:127    
##  Jet      : 61                Mean   : 7.578   Sep:129    
##  Singapore: 40                3rd Qu.:10.620              
##  Virgin   : 62                Max.   :14.660              
##       IsInternational  SeatsEconomy    SeatsPremium    PitchEconomy  
##  Domestic     : 40    Min.   : 78.0   Min.   : 8.00   Min.   :30.00  
##  International:418    1st Qu.:133.0   1st Qu.:21.00   1st Qu.:31.00  
##                       Median :185.0   Median :36.00   Median :31.00  
##                       Mean   :202.3   Mean   :33.65   Mean   :31.22  
##                       3rd Qu.:243.0   3rd Qu.:40.00   3rd Qu.:32.00  
##                       Max.   :389.0   Max.   :66.00   Max.   :33.00  
##   PitchPremium    WidthEconomy    WidthPremium    PriceEconomy 
##  Min.   :34.00   Min.   :17.00   Min.   :17.00   Min.   :  65  
##  1st Qu.:38.00   1st Qu.:18.00   1st Qu.:19.00   1st Qu.: 413  
##  Median :38.00   Median :18.00   Median :19.00   Median :1242  
##  Mean   :37.91   Mean   :17.84   Mean   :19.47   Mean   :1327  
##  3rd Qu.:38.00   3rd Qu.:18.00   3rd Qu.:21.00   3rd Qu.:1909  
##  Max.   :40.00   Max.   :19.00   Max.   :21.00   Max.   :3593  
##   PricePremium    PriceRelative      SeatsTotal  PitchDifference 
##  Min.   :  86.0   Min.   :0.0200   Min.   : 98   Min.   : 2.000  
##  1st Qu.: 528.8   1st Qu.:0.1000   1st Qu.:166   1st Qu.: 6.000  
##  Median :1737.0   Median :0.3650   Median :227   Median : 7.000  
##  Mean   :1845.3   Mean   :0.4872   Mean   :236   Mean   : 6.688  
##  3rd Qu.:2989.0   3rd Qu.:0.7400   3rd Qu.:279   3rd Qu.: 7.000  
##  Max.   :7414.0   Max.   :1.8900   Max.   :441   Max.   :10.000  
##  WidthDifference PercentPremiumSeats
##  Min.   :0.000   Min.   : 4.71      
##  1st Qu.:1.000   1st Qu.:12.28      
##  Median :1.000   Median :13.21      
##  Mean   :1.633   Mean   :14.65      
##  3rd Qu.:3.000   3rd Qu.:15.36      
##  Max.   :4.000   Max.   :24.69
library(psych)
describe(Filter(is.numeric,airline))
##                     vars   n    mean      sd  median trimmed     mad   min
## FlightDuration         1 458    7.58    3.54    7.79    7.57    4.81  1.25
## SeatsEconomy           2 458  202.31   76.37  185.00  194.64   85.99 78.00
## SeatsPremium           3 458   33.65   13.26   36.00   33.35   11.86  8.00
## PitchEconomy           4 458   31.22    0.66   31.00   31.26    0.00 30.00
## PitchPremium           5 458   37.91    1.31   38.00   38.05    0.00 34.00
## WidthEconomy           6 458   17.84    0.56   18.00   17.81    0.00 17.00
## WidthPremium           7 458   19.47    1.10   19.00   19.53    0.00 17.00
## PriceEconomy           8 458 1327.08  988.27 1242.00 1244.40 1159.39 65.00
## PricePremium           9 458 1845.26 1288.14 1737.00 1799.05 1845.84 86.00
## PriceRelative         10 458    0.49    0.45    0.36    0.42    0.41  0.02
## SeatsTotal            11 458  235.96   85.29  227.00  228.73   90.44 98.00
## PitchDifference       12 458    6.69    1.76    7.00    6.76    0.00  2.00
## WidthDifference       13 458    1.63    1.19    1.00    1.53    0.00  0.00
## PercentPremiumSeats   14 458   14.65    4.84   13.21   14.31    2.68  4.71
##                         max   range  skew kurtosis    se
## FlightDuration        14.66   13.41 -0.07    -1.12  0.17
## 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

Plots

par(mfrow= c(1,2))
hist(PriceEconomy, breaks = 10)
hist(PricePremium, breaks = 10)

par(mfrow= c(1,2))
hist(SeatsEconomy, breaks = 10)
hist(SeatsPremium, breaks = 10)

par(mfrow= c(1,2))
hist(WidthEconomy, breaks = 10)
hist(WidthPremium, breaks = 10)

par(mfrow= c(1,2))
hist(PitchEconomy, breaks = 10)
hist(PitchPremium, breaks = 10)

library(lattice)
bwplot(PriceRelative~Airline, main = "Relative price difference of different Airline" , xlab = "Airline")

bwplot(PriceRelative~Aircraft, main = "Relative price difference of different Aircraft" , xlab = "Aircraft")

bwplot(PriceRelative~TravelMonth, main = "Relative price difference of different Travel month" , xlab = "Travel Month")

bwplot(PriceRelative~IsInternational, main = "Relative price difference of different types of Airline" , xlab = "Airline")

library(car)
scatterplot(PriceRelative~FlightDuration, cex = 0.9, pch=19, main = " Relative price difference vs Flight Duration")

scatterplot(PriceRelative~PercentPremiumSeats, cex = 0.9, pch=19, main = " Relative price difference vs Percent Premium Seats")

library(RColorBrewer)
mycolors <- brewer.pal(6,"Set1")
names(mycolors) <- levels(Airline)
scatterplotMatrix(~PriceRelative+SeatsTotal+PitchDifference+WidthDifference|Airline, data=airline , reg.line="" , smoother="", col=mycolors, smoother.args=list(col="grey") , cex=0.9 , pch=c(15,16,17,18,19,1) , main="Scatter Plot of difference between price, seats, width and pitch",legend.plot= FALSE)
legend(x="topright", legend = levels(Airline), col=mycolors, pch=c(15,16,17,18,19,1), cex = 0.67)

Correlations

round(cor(Filter(is.numeric, airline)),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
## 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
library(corrgram)
corrgram(airline, order = TRUE, lower.panel = panel.shade, upper.panel = panel.pie)

Regressions

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
fit = lm(PriceRelative ~ FlightDuration+SeatsEconomy+SeatsPremium+WidthEconomy+WidthPremium+PitchEconomy+PitchPremium, data = airline)
summary(fit)
## 
## Call:
## lm(formula = PriceRelative ~ FlightDuration + SeatsEconomy + 
##     SeatsPremium + WidthEconomy + WidthPremium + PitchEconomy + 
##     PitchPremium, data = airline)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -0.86549 -0.25418 -0.07713  0.14522  1.34717 
## 
## Coefficients:
##                  Estimate Std. Error t value Pr(>|t|)    
## (Intercept)     6.8912366  1.7209126   4.004 7.27e-05 ***
## FlightDuration  0.0278757  0.0058374   4.775 2.43e-06 ***
## SeatsEconomy    0.0007934  0.0003168   2.505   0.0126 *  
## SeatsPremium   -0.0076652  0.0019421  -3.947 9.19e-05 ***
## WidthEconomy   -0.0050452  0.0415730  -0.121   0.9035    
## WidthPremium    0.1256658  0.0259356   4.845 1.74e-06 ***
## PitchEconomy   -0.2606111  0.0411633  -6.331 5.90e-10 ***
## PitchPremium   -0.0194938  0.0212963  -0.915   0.3605    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 0.3689 on 450 degrees of freedom
## Multiple R-squared:  0.3401, Adjusted R-squared:  0.3299 
## F-statistic: 33.14 on 7 and 450 DF,  p-value: < 2.2e-16
coefficients(fit)
##    (Intercept) FlightDuration   SeatsEconomy   SeatsPremium   WidthEconomy 
##    6.891236561    0.027875683    0.000793419   -0.007665192   -0.005045239 
##   WidthPremium   PitchEconomy   PitchPremium 
##    0.125665753   -0.260611105   -0.019493820

Summary

Analysis of six different airlines gives us the following inference about the price difference between premium and economy class-