IniziaInizia gratis

Visualizing goodness of fit

The chi-square goodness of fit test compares proportions of each level of a categorical variable to hypothesized values. Before running such a test, it can be helpful to visually compare the distribution in the sample to the hypothesized distribution.

Recall the vendor incoterms in the late_shipments dataset. Let's hypothesize that the four values occur with these frequencies in the population of shipments.

  • EXW: 0.75
  • CIP: 0.05
  • DDP: 0.1
  • FCA: 0.1

late_shipments is available; tibble, dplyr, ggplot2, and infer are loaded.

Questo esercizio fa parte del corso

Hypothesis Testing in R

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

# Using late_shipments, count the vendor incoterms
vendor_inco_term_counts <- ___


# Get the number of rows in the whole sample
n_total <- ___

hypothesized <- tribble(
  ~ vendor_inco_term, ~ prop,
  "EXW", 0.75,
  "CIP", 0.05,
  "DDP", 0.1,
  "FCA", 0.1
) %>%
  # Add a column of hypothesized counts for the incoterms
  ___

# See the results
hypothesized
Modifica ed esegui il codice