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 |
A) The study wants to test whether the type of ticket is independent of the type of flight. Clearly state the null and alternative hypotheses. (2 points)
B) Compute the expected frequencies by completing the table below. (3 points)
Type of Ticket |
Domestic Flight |
International Flight |
Total |
First Class |
|||
Business Class |
|||
Economy Class |
|||
Total |
C) Compute the test statistic.
Please copy your R code and the result and paste them here.
D) At 5% significance level, compute the critical value for the test statistic and the p value for the test. Draw your conclusion. (5 points)
Please copy your R code and the result and paste them here.
E) Use the function chisq.test() in R to run the test directly to confirm your results above are correct. (4 points)
Please copy your R code and the result and paste them here.
A) The study wants to test whether the type of ticket is independent of the type of flight. Clearly state the null and alternative hypotheses. (2 points)
Ho: type of ticket is independent of the type of flight
H1: type of ticket is not independent of the type of flight
B) Compute the expected frequencies by completing the table below. (3 points)
Type of Ticket |
Domestic Flight |
International Flight |
Total |
First Class |
35.5891 |
15.4109 |
51 |
Business Class |
150.7304 |
65.2696 |
216 |
Economy Class |
455.6804 |
197.3196 |
653 |
Total |
642 |
278 |
920 |
C) Compute the test statistic.
Please copy your R code and the result and paste them here.
R code:
observed = c(29,22,95,121,518,135) # observed frequencies
expected = c(35.5891, 15.4109, 150.7304, 65.2696, 455.6804, 197.3196)# expected frequencies
chi2 = sum((observed- expected)^2/ expected)
chi2
R output:
[1] 100.4334
D) At 5% significance level, compute the critical value for the test statistic and the p value for the test. Draw your conclusion. (5 points)
Please copy your R code and the result and paste them here.
R code:
qchisq(.95, df=2) # 7 degrees of freedom
pchisq(chi2, df=2,lower.tail=FALSE)
R output:
> qchisq(.95, df=2) # 7 degrees of freedom
[1] 5.991465
> pchisq(chi2, df=2,lower.tail=FALSE)
[1] 1.552954e-22
E) Use the function chisq.test() in R to run the test directly to confirm your results above are correct. (4 points)
Please copy your R code and the result and paste them here.
Rcode:
M <- as.table(rbind(c(29,22), c(95,121),c(518,135)))
chi2<- chisq.test(M)
chi2
R output:
Pearson's Chi-squared test
data: M
X-squared = 100.43, df = 2, p-value < 2.2e-16
conclusion: calculated chi square 100.43 > 5.991, the critical
value at 0.05 level of significance. Ho is rejected. we conclude
that the type of ticket is not independent of the type of
flight.