視覺化適合度檢定
「卡方適合度檢定」會將類別變數各水準的比例與假設的數值做比較。在執行檢定前,先把樣本中的分配與假設分配做視覺化比較,常常很有幫助。
回想 late_shipments 資料集中供應商的 incoterms。讓我們假設在所有出貨中,這四個值的機率如下。
EXW:0.75CIP:0.05DDP:0.1FCA:0.1
已提供 late_shipments;並已載入 tibble、dplyr、ggplot2 和 infer。
本練習屬於課程
R 中的假設檢定
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# 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