Read data on airlines
airline<-read.csv(file="SixAirlinesDataV2.csv")
discribing statistics
attach(airline)
library(psych)
describe(airline)
## vars n mean sd median trimmed mad min
## Airline* 1 458 3.01 1.65 2.00 2.89 1.48 1.00
## Aircraft* 2 458 1.67 0.47 2.00 1.71 0.00 1.00
## FlightDuration 3 458 7.58 3.54 7.79 7.57 4.81 1.25
## TravelMonth* 4 458 2.56 1.17 3.00 2.58 1.48 1.00
## IsInternational* 5 458 1.91 0.28 2.00 2.00 0.00 1.00
## SeatsEconomy 6 458 202.31 76.37 185.00 194.64 85.99 78.00
## SeatsPremium 7 458 33.65 13.26 36.00 33.35 11.86 8.00
## PitchEconomy 8 458 31.22 0.66 31.00 31.26 0.00 30.00
## PitchPremium 9 458 37.91 1.31 38.00 38.05 0.00 34.00
## WidthEconomy 10 458 17.84 0.56 18.00 17.81 0.00 17.00
## WidthPremium 11 458 19.47 1.10 19.00 19.53 0.00 17.00
## PriceEconomy 12 458 1327.08 988.27 1242.00 1244.40 1159.39 65.00
## PricePremium 13 458 1845.26 1288.14 1737.00 1799.05 1845.84 86.00
## PriceRelative 14 458 0.49 0.45 0.36 0.42 0.41 0.02
## SeatsTotal 15 458 235.96 85.29 227.00 228.73 90.44 98.00
## PitchDifference 16 458 6.69 1.76 7.00 6.76 0.00 2.00
## WidthDifference 17 458 1.63 1.19 1.00 1.53 0.00 0.00
## PercentPremiumSeats 18 458 14.65 4.84 13.21 14.31 2.68 4.71
## max range skew kurtosis se
## Airline* 6.00 5.00 0.61 -0.95 0.08
## Aircraft* 2.00 1.00 -0.72 -1.48 0.02
## FlightDuration 14.66 13.41 -0.07 -1.12 0.17
## TravelMonth* 4.00 3.00 -0.14 -1.46 0.05
## IsInternational* 2.00 1.00 -2.91 6.50 0.01
## SeatsEconomy 389.00 311.00 0.72 -0.36 3.57
## SeatsPremium 66.00 58.00 0.23 -0.46 0.62
## PitchEconomy 33.00 3.00 -0.03 -0.35 0.03
## PitchPremium 40.00 6.00 -1.51 3.52 0.06
## WidthEconomy 19.00 2.00 -0.04 -0.08 0.03
## WidthPremium 21.00 4.00 -0.08 -0.31 0.05
## PriceEconomy 3593.00 3528.00 0.51 -0.88 46.18
## PricePremium 7414.00 7328.00 0.50 0.43 60.19
## PriceRelative 1.89 1.87 1.17 0.72 0.02
## SeatsTotal 441.00 343.00 0.70 -0.53 3.99
## PitchDifference 10.00 8.00 -0.54 1.78 0.08
## WidthDifference 4.00 4.00 0.84 -0.53 0.06
## PercentPremiumSeats 24.69 19.98 0.71 0.28 0.23
discribing PriceEcomony and PricePremium
library(psych)
describe(airline$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(airline$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
describe(airline$PriceRelative)
## vars n mean sd median trimmed mad min max range skew kurtosis
## X1 1 458 0.49 0.45 0.36 0.42 0.41 0.02 1.89 1.87 1.17 0.72
## se
## X1 0.02
Histogram for PriceEconomy and PricePremium
hist(airline$PriceEconomy,
breaks=18,
col="gray",
xlab="PriceEconomy",
main="Histogram for PriceEconomy")
hist(airline$PricePremium,
breaks=18,
col="gray",
xlab="PricePremium",
main="Histogram for PricePremium")
Boxplot of Pitch Economy
boxplot(PitchEconomy,horizontal = TRUE,main="Pitch economy",xlab="inches",col = "blue")
Boxplot of Pitch Premium
boxplot(PitchPremium,horizontal = TRUE,main="Pitch Premium",xlab="inches",col = "blue")
boxplot of seat Economy
boxplot(SeatsEconomy,horizontal = TRUE,main="Seats economy",xlab="Number of seats",col = "yellow")
boxplot of seat Premium
boxplot(SeatsPremium,horizontal = TRUE,main="Seats Premium",xlab="Number of seats",col = "yellow")
plot of PriceEconomy v/s TravelMonth
library(car)
##
## Attaching package: 'car'
## The following object is masked from 'package:psych':
##
## logit
scatterplot(x=airline$TravelMonth, y=airline$PriceEconomy,main="scatterplot of TravelMOnth vs PriceEcomony",xlab ="TravelMonth",ylab="PriceEconomy" )
plot of PricePremium v/s TravelMonth
library(car)
scatterplot(x=airline$TravelMonth, y=airline$PricePremium,main="scatterplot of TravelMonth vs PricePremium",xlab ="TravelMonth",ylab="PricePremium" )
## [1] "367" "369" "368"
scatterplotmatrix for finding dependence of PriceEconomy on the factors like TravelMonth,FlightDuration and SeatEconomy
scatterplotMatrix(formula = ~ TravelMonth + FlightDuration + SeatsEconomy +PriceEconomy, cex=0.5,
data=airline, diagonal="histogram")
scatterplotmatrix for finding dependence of PricePremium on the factors like TravelMonth,FlightDuration and SeatEconomy
scatterplotMatrix(formula = ~ TravelMonth + FlightDuration + SeatsPremium +PricePremium, cex=0.5,
data=airline, diagonal="histogram")
corrogram of the data set of airlines
library(corrgram)
corrgram(airline, order=FALSE,
lower.panel=panel.shade,
upper.panel=panel.pie,
diag.panel=panel.minmax,
text.panel=panel.txt,
main="Corrgram of airline intercorrelations")
T-Test
t.test(PriceEconomy,PricePremium)
##
## Welch Two Sample t-test
##
## data: PriceEconomy and PricePremium
## 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:
## -667.0831 -369.2793
## sample estimates:
## mean of x mean of y
## 1327.076 1845.258
Regression analysis-Economy class Price
fit <- lm(PriceEconomy~Aircraft+Airline+FlightDuration+PitchEconomy+WidthEconomy+SeatsEconomy+SeatsTotal+IsInternational+TravelMonth)
summary(fit)
##
## Call:
## lm(formula = PriceEconomy ~ Aircraft + Airline + FlightDuration +
## PitchEconomy + WidthEconomy + SeatsEconomy + SeatsTotal +
## IsInternational + TravelMonth)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2062.88 -225.82 82.01 333.89 1295.47
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1403.5686 3343.2395 0.420 0.67482
## AircraftBoeing 205.4897 69.0014 2.978 0.00306 **
## AirlineBritish -1488.2293 142.9282 -10.412 < 2e-16 ***
## AirlineDelta -750.3835 251.0278 -2.989 0.00295 **
## AirlineJet -2118.1280 177.5262 -11.931 < 2e-16 ***
## AirlineSingapore -2013.5367 179.3390 -11.228 < 2e-16 ***
## AirlineVirgin -1261.1819 150.4913 -8.380 7.09e-16 ***
## FlightDuration 102.9963 9.8625 10.443 < 2e-16 ***
## PitchEconomy -0.1632 88.2251 -0.002 0.99852
## WidthEconomy -46.5380 101.3161 -0.459 0.64622
## SeatsEconomy -8.2380 4.4291 -1.860 0.06355 .
## SeatsTotal 6.9760 4.1363 1.687 0.09240 .
## IsInternationalInternational 1236.9651 274.4896 4.506 8.45e-06 ***
## TravelMonthJul 99.2021 77.3651 1.282 0.20042
## TravelMonthOct -44.1857 65.7197 -0.672 0.50172
## TravelMonthSep 3.2497 65.5355 0.050 0.96047
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 523.5 on 442 degrees of freedom
## Multiple R-squared: 0.7286, Adjusted R-squared: 0.7194
## F-statistic: 79.11 on 15 and 442 DF, p-value: < 2.2e-16
Regression analysis-Premium class Price
fit <- lm(PricePremium~Aircraft+Airline+FlightDuration+PitchPremium+WidthPremium+SeatsPremium+SeatsTotal+IsInternational+TravelMonth)
summary(fit)
##
## Call:
## lm(formula = PricePremium ~ Aircraft + Airline + FlightDuration +
## PitchPremium + WidthPremium + SeatsPremium + SeatsTotal +
## IsInternational + TravelMonth)
##
## Residuals:
## Min 1Q Median 3Q Max
## -2133.0 -362.5 52.8 348.8 4422.7
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -4447.4061 5618.2846 -0.792 0.42902
## AircraftBoeing 249.0832 93.7752 2.656 0.00819 **
## AirlineBritish -1016.4414 145.5283 -6.984 1.06e-11 ***
## AirlineDelta -349.9291 562.9812 -0.622 0.53455
## AirlineJet -2101.6561 289.4373 -7.261 1.74e-12 ***
## AirlineSingapore -2161.7807 273.3757 -7.908 2.12e-14 ***
## AirlineVirgin -516.4144 475.7778 -1.085 0.27833
## FlightDuration 176.8906 14.2051 12.453 < 2e-16 ***
## PitchPremium 103.1443 228.7034 0.451 0.65221
## WidthPremium 49.0335 225.1650 0.218 0.82771
## SeatsPremium 3.0724 6.4245 0.478 0.63272
## SeatsTotal -0.4734 0.7007 -0.676 0.49968
## IsInternationalInternational 968.1084 727.0516 1.332 0.18369
## TravelMonthJul 91.6748 111.8856 0.819 0.41302
## TravelMonthOct -25.8581 95.0397 -0.272 0.78569
## TravelMonthSep -0.8705 94.7890 -0.009 0.99268
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 756.7 on 442 degrees of freedom
## Multiple R-squared: 0.6662, Adjusted R-squared: 0.6549
## F-statistic: 58.81 on 15 and 442 DF, p-value: < 2.2e-16
for Price difference
PriceDifference <- (PricePremium - PriceEconomy)
Regression analysis-Economy class PriceDifference
fit <- lm(PriceDifference~FlightDuration+PitchDifference+WidthDifference+SeatsEconomy+SeatsPremium+SeatsTotal+IsInternational)
summary(fit)
##
## Call:
## lm(formula = PriceDifference ~ FlightDuration + PitchDifference +
## WidthDifference + SeatsEconomy + SeatsPremium + SeatsTotal +
## IsInternational)
##
## Residuals:
## Min 1Q Median 3Q Max
## -869.7 -245.0 -48.1 138.0 3487.1
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -680.2122 136.4176 -4.986 8.80e-07 ***
## FlightDuration 93.2929 8.1075 11.507 < 2e-16 ***
## PitchDifference 53.2696 32.9336 1.617 0.10647
## WidthDifference 126.8535 32.0295 3.961 8.69e-05 ***
## SeatsEconomy -0.5342 0.3887 -1.374 0.17010
## SeatsPremium 16.7787 2.3220 7.226 2.14e-12 ***
## SeatsTotal NA NA NA NA
## IsInternationalInternational -579.0802 179.8990 -3.219 0.00138 **
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 476.4 on 451 degrees of freedom
## Multiple R-squared: 0.343, Adjusted R-squared: 0.3343
## F-statistic: 39.25 on 6 and 451 DF, p-value: < 2.2e-16
Regression analysis-Premium class PriceDifference
fit <- lm(PriceDifference~FlightDuration+PitchEconomy+WidthEconomy+PitchPremium+WidthPremium+SeatsEconomy+SeatsPremium+SeatsTotal+IsInternational)
summary(fit)
##
## Call:
## lm(formula = PriceDifference ~ FlightDuration + PitchEconomy +
## WidthEconomy + PitchPremium + WidthPremium + SeatsEconomy +
## SeatsPremium + SeatsTotal + IsInternational)
##
## Residuals:
## Min 1Q Median 3Q Max
## -897.9 -228.3 -68.8 120.9 3317.7
##
## Coefficients: (1 not defined because of singularities)
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 18831.7431 3912.0162 4.814 2.03e-06 ***
## FlightDuration 83.2522 8.2469 10.095 < 2e-16 ***
## PitchEconomy -303.1791 56.8031 -5.337 1.50e-07 ***
## WidthEconomy -131.7218 54.5592 -2.414 0.0162 *
## PitchPremium -288.6342 72.3187 -3.991 7.68e-05 ***
## WidthPremium 149.7156 32.9592 4.542 7.15e-06 ***
## SeatsEconomy 0.1852 0.4035 0.459 0.6464
## SeatsPremium 5.7414 3.0630 1.874 0.0615 .
## SeatsTotal NA NA NA NA
## IsInternationalInternational 728.8061 310.4695 2.347 0.0193 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 463 on 449 degrees of freedom
## Multiple R-squared: 0.3822, Adjusted R-squared: 0.3712
## F-statistic: 34.73 on 8 and 449 DF, p-value: < 2.2e-16
Regression analysis-Relative price
fit <- lm(PriceRelative~FlightDuration+PitchEconomy+WidthEconomy+PitchPremium+WidthPremium+SeatsEconomy+SeatsPremium+SeatsTotal+PitchDifference+WidthDifference)
summary(fit)
##
## Call:
## lm(formula = PriceRelative ~ FlightDuration + PitchEconomy +
## WidthEconomy + PitchPremium + WidthPremium + SeatsEconomy +
## SeatsPremium + SeatsTotal + PitchDifference + WidthDifference)
##
## Residuals:
## Min 1Q Median 3Q Max
## -0.86549 -0.25418 -0.07713 0.14522 1.34717
##
## Coefficients: (3 not defined because of singularities)
## 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 ***
## PitchEconomy -0.2606111 0.0411633 -6.331 5.90e-10 ***
## WidthEconomy -0.0050452 0.0415730 -0.121 0.9035
## PitchPremium -0.0194938 0.0212963 -0.915 0.3605
## WidthPremium 0.1256658 0.0259356 4.845 1.74e-06 ***
## SeatsEconomy 0.0007934 0.0003168 2.505 0.0126 *
## SeatsPremium -0.0076652 0.0019421 -3.947 9.19e-05 ***
## SeatsTotal NA NA NA NA
## PitchDifference NA NA NA NA
## WidthDifference NA NA NA NA
## ---
## 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