BaşlayınÜcretsiz Başlayın

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.

Bu egzersiz

Hypothesis Testing in R

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# 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
Kodu Düzenle ve Çalıştır