एक p-value, दो तरीके
आपने पहले देखा है कि null वितरण तक पहुँचने के आम तौर पर दो तरीके होते हैं: गणना (computation) के जरिए और एक गणितीय approximation के जरिए. Chi-squared goodness of fit टेस्ट भी इसका अपवाद नहीं है. Approximation वितरण फिर से "Chi-squared distribution" ही है, जिसके degrees of freedom श्रेणियों (categories) की संख्या माइनस एक के बराबर होते हैं.
इस अभ्यास में आप इन दोनों तरीकों की तुलना करेंगे ताकि एक p-value निकाली जा सके, जो जाँचती है कि ईरान (Iran) के first digits का वितरण Benford's Law से कितना मेल खाता है. ध्यान दें कि पिछले अभ्यास में आपने जो observed statistic बनाया था, वह आपके work space में chi_obs_stat नाम से सेव है.
यह अभ्यास पाठ्यक्रम का हिस्सा है
R में श्रेणीबद्ध डेटा के लिए अनुमान
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Compute degrees of freedom
degrees_of_freedom <- ___ %>%
# Pull out first_digit vector
pull("first_digit") %>%
# Calculate n levels and subtract 1
___
# Plot both null dists
___
# Add density layer
___
# Add vertical line at obs stat
___
# Overlay chisq approx
stat_function(fun = dchisq, args = list(df = ___), color = "blue")