Bonferroni correction
Let's implement multiple hypothesis tests using the Bonferroni correction approach that we discussed in the slides. You'll use the imported multipletests()
function in order to achieve this.
Use a single-test significance level of .05 and observe how the Bonferroni correction affects our sample list of p-values already created.
This is a part of the course
“Practicing Statistics Interview Questions in Python”
Exercise instructions
- Compute a list of the Bonferroni adjusted p-values using the imported
multipletests()
function. - Print the results of the multiple hypothesis tests returned in index 0 of your
p_adjusted
variable. - Print the p-values themselves returned in index 1 of your
p_adjusted
variable.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
from statsmodels.sandbox.stats.multicomp import multipletests
pvals = [.01, .05, .10, .50, .99]
# Create a list of the adjusted p-values
p_adjusted = multipletests(____, alpha=____, method='bonferroni')
# Print the resulting conclusions
print(____)
# Print the adjusted p-values themselves
print(____)
This exercise is part of the course
Practicing Statistics Interview Questions in Python
Prepare for your next statistics interview by reviewing concepts like conditional probabilities, A/B testing, the bias-variance tradeoff, and more.
Prepare to dive deeper into crucial concepts regarding experiments and testing by reviewing confidence intervals, hypothesis testing, multiple tests, and the role that power and sample size play. We'll also discuss types of errors, and what they mean in practice.
Exercise 1: Confidence intervalsExercise 2: Confidence interval by handExercise 3: Applying confidence intervalsExercise 4: Hypothesis testingExercise 5: One tailed z-testExercise 6: Two tailed t-testExercise 7: Power and sample sizeExercise 8: Effect on type II errorExercise 9: Calculating sample sizeExercise 10: Visualizing the relationshipExercise 11: Multiple testingExercise 12: Calculating error ratesExercise 13: Bonferroni correctionWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.