1. Learn
  2. /
  3. Courses
  4. /
  5. Hypothesis Testing in R

Exercise

Performing a chi-square test

The chi-square independence test compares proportions of successes of a categorical variable across categories of another categorical variable.

Trade deals often use a form of business shorthand in order to specify the exact details of their contract. These are International Chamber of Commerce (ICC) international commercial terms, or incoterms for short.

The late_shipments dataset includes a vendor_inco_term that describes the incoterms that applied to a given shipment. The choices are:

  • EXW: "Ex works". The buyer pays for transportation of the goods.
  • CIP: "Carriage and insurance paid to". The seller pays for freight and insurance until the goods board a ship.
  • DDP: "Delivered duty paid". The seller pays for transportation of the goods until they reach a destination port.
  • FCA: "Free carrier". The seller pays for transportation of the goods.

Perhaps the incoterms affect whether or not the freight costs are expensive. Test these hypotheses with a significance level of 0.01.

\(H_{0}\): vendor_inco_term and freight_cost_group are independent.

\(H_{A}\): vendor_inco_term and freight_cost_group are associated.

late_shipments is available; ggplot2 and infer are loaded.

Instructions 1/3

undefined XP
    1
    2
    3
  • Using the late_shipments dataset, draw a proportional stacked bar plot of vendor_inco_term with fill color by freight_cost_group.