In: Statistics and Probability
A Bloomberg Businessweek subscriber study asked, “in the past 12 months, when traveling for business, what type of airline ticket did you purchase most often?” A second question asked if the type of airline ticket purchased most often was for domestic or international travel. Sample data obtained are shown in the following table.
Type of Ticket |
Domestic Flight |
International Flight |
---|---|---|
First class |
29 |
22 |
Business class |
95 |
121 |
Economy class |
518 |
135 |
The study wants to test whether the type of ticket is independent of the type of flight. Clearly state the null and alternative hypotheses.
Compute the test statistic.
Please copy your R code and the result and paste them here.
At 5% significance level, compute the critical value for the test statistic and the p value for the test. Draw your conclusion.
Please copy your R code and the result and paste them here.
Use the function chisq.test() in R to run the test directly to confirm your results above are correct.
A Bloomberg Businessweek subscriber study asked, “in the past 12 months, when travelling for business. The type of airline ticket purchase most often was International Flight. The type of airline ticket purchased most often was for domestic travel.
The null and alternative hypotheses:
Null hypothesis: The type of ticket is independent of the type of flight.
Alternative hypothesis: The type of ticket is dependent of the type of flight.
## R code
Input =("
Injection.area Domestic_Flight International_Flight
First 29 22
Business 95 121
Economy 518 135
")
Matrix = as.matrix(read.table(textConnection(Input),
header=TRUE,
row.names=1))
Matrix
### Chi-square test
chisq.test(Matrix)
## Output
> Input =("
+ Injection.area Domestic_Flight International_Flight
+ First 29 22
+ Business 95 121
+ Economy 518 135
+ ")
>
> Matrix = as.matrix(read.table(textConnection(Input),
+ header=TRUE,
+ row.names=1))
>
> Matrix
Domestic_Flight International_Flight
First 29 22
Business 95 121
Economy 518 135
>
> ### Chi-square test
> chisq.test(Matrix)
Pearson's Chi-squared test
data: Matrix
X-squared = 100.43, df = 2, p-value < 2.2e-16
Conclusion: The estimated p-value is less than 0.05 level of significance. Hence, we reject the null hypothesis and conclude that the type of ticket is dependent on the type of flight at 0.05 level of significance.