Hypothesis Testing: Testing an Association
Learn about hypothesis tests that can be used to evaluate whether there is an association between two variables.
StartKey Concepts
Review core concepts you need to learn to master this subject
Two-Sample T-Test
Multiple Two-Sample T-Tests
Analysis of Variance
Tukey’s Range Test
Hypothesis Testing Assumptions
Chi-Square Test
Chi-Square Assumptions
Two-Sample T-Test
Two-Sample T-Test
from scipy.stats import ttest_ind
#separate out claw lengths for two species
grizzly_bear = data.claw_length[data.species=='grizzly']
black_bear = data.claw_length[data.species=='black']
#run the t-test here:
tstat, pval = ttest_ind(grizzly_bear, black_bear)
We can test an association between a quantitative variable and a binary categorical variable by using a two-sample t-test. The null hypothesis for a two-sample t-test is that the difference in group means is equal to zero. A two-sample t-test can be implemented in Python using the ttest_ind()
function from scipy.stats
. The example code shows a two-sample t-test for testing an association between claw length and species of bear (grizzly or black).
- 1In this lesson, we’ll use hypothesis tests to make inference about population-level associations between two variables. We will cover four different hypothesis tests: * Two Sample T-Tests (for a…
- 2Suppose that a company is considering a new color-scheme for their website. They think that visitors will spend more time on the site if it is brightly colored. To test this theory, the company sho…
- 3In the previous exercise, we used a two-sample t-test to investigate an association between a quantitative variable (time spent on a website) and a binary categorical variable (an old color scheme …
- 5Let’s say that we have performed an ANOVA to compare sales at the three VeryAnts stores. We calculated a p-value less than 0.05 and concluded that there is a significant difference between at least…
- 6Before we use a two sample t-test, ANOVA, or Tukey’s range test, we need to be sure that the following things are true: #### 1. The observations should be independently randomly sampled from the p…
- 7If we want to understand whether the outcomes of two categorical variables are associated, we can use a Chi-Square test. It is useful in situations like: * An A/B test where half of users were sho…
- 8Before we use a Chi-Square test, we need to be sure that the following things are true: #### 1. The observations should be independently randomly sampled from the population This is also true of 2…
What you'll create
Portfolio projects that showcase your new skills
How you'll master it
Stress-test your knowledge with quizzes that help commit syntax to memory