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.
This exercise is part of the course
Hypothesis Testing in R
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Plot vendor_inco_term filled by freight_cost_group.
# Make it a proportional stacked bar plot.
___