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

Exercise

Performing a chi-square test

The chi-square independence test compares proportions of successes of one categorical variable across the 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, and the following have been loaded: matplotlib.pyplot as plt, pandas as pd, and pingouin.

Instructions 1/5

undefined XP
    1
    2
    3
    4
    5
  • Calculate the proportion of freight_cost_group in late_shipments grouped by vendor_inco_term.