Randomization density
100 repetitions का उपयोग करने से आप permuting की प्रक्रिया को समझते हैं. लेकिन, 100 इतना पर्याप्त नहीं है कि आप proportions के null differences के संभावित मानों की पूरी रेंज देख सकें.
Inference के चार चरण याद करें. यही वही चार चरण हैं जिनका उपयोग इस कोर्स और आगे आने वाले statistical inference कोर्सों के सभी inference अभ्यासों में होगा. प्रक्रिया को याद रखने के लिए फंक्शन के नामों का सहारा लें.
specifyresponse और explanatory वैरिएबल्स को निर्दिष्ट करेगा.hypothesizenull hypothesis को घोषित करेगा.generateresamples, permutations, या simulations बनाएगा.calculatesummary statistics निकालेगा.
इस अभ्यास में, आप इस प्रक्रिया को 1000 बार दोहराएँगे ताकि proportions के null differences के पूरे distribution का अंदाज़ा लग सके.
यह अभ्यास पाठ्यक्रम का हिस्सा है
R में Inference की बुनियाद
अभ्यास निर्देश
dplyr, ggplot2, NHANES, और infer पैकेज आपके लिए लोड कर दिए गए हैं.
inferसिंटैक्स का उपयोग करते हुएHomeOwnवैरिएबल को shuffle करके proportions में 1000 differences जेनरेट करें.inferसिंटैक्स याद रखें:- यह
specifyकरें कि रुचि का संबंधHomeOwnबनामGenderहै और इस संदर्भ में success homeownership है,success = "Own". - यह
hypothesizeकरें कि null सत्य है जहाँnull = "independence"है (अर्थात gender और homeownership संबंधित नहीं हैं). - 1000 permutations
generateकरें;repsको 1000 पर सेट करें. calculateकरें सांख्यिकीय मानstat = "diff in props"के साथ और orderc("male", "female")रखें.
- यह
- density plot का कोड चलाएँ ताकि differences के distribution का एक स्मूद विज़ुअल रिप्रेज़ेंटेशन बन जाए. कर्व का आकार कैसा है?
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Perform 1000 permutations
homeown_perm <- homes %>%
# Specify HomeOwn vs. Gender, with `"Own" as success
___(___ ~ ___, success = "___") %>%
# Use a null hypothesis of independence
___(___) %>%
# Generate 1000 repetitions (by permutation)
___(reps = ___, type = "permute") %>%
# Calculate the difference in proportions (male then female)
___(___, order = ___))
# Density plot of 1000 permuted differences in proportions
ggplot(homeown_perm, aes(x = stat)) +
geom_density()