Hypothesis Testing and Statistical Analysis¶
In this module, you will learn the statistics that an analysis of social media data needs: how to describe a set of numbers, how to test a claim about them, and how to measure whether two values change together.
Social media data is highly skewed. A few accounts have millions of followers, and most accounts have very few. The mean, a histogram with equal bins, and a test that assumes a normal distribution all give a wrong picture of such data. Each page shows what to use for skewed data.
Learning objectives¶
- Describe a set of numbers with the mean and the median, and say which one fits skewed data
- Plot a distribution with a histogram, a box plot, a violin plot, a CDF, and a CCDF
- Use log bins and log axes for skewed data such as follower counts
- State a null hypothesis and explain what a p-value means
- Run a binomial test and a t-test with SciPy, and choose another test when the data is not normal
- Report the p-value and the size of the difference, not only whether the result is significant
- Plot the relationship between two variables and measure it with the Spearman or the Pearson coefficient
- Explain why a correlation does not show a cause
Pages¶
| Page | What it covers |
|---|---|
| Descriptive statistics and distributions | The mean and the median, and five plots of a distribution: histogram, box plot, violin plot, CDF, and CCDF; log bins and log axes for skewed data |
| Hypothesis testing | What a p-value means; a test built by simulation with a coin; the binomial test and the t-test; how to choose another test; how to report a result; significance and effect size |
| Correlation | Why a correlation does not show a cause; the scatter plot on log axes; the Spearman and the Pearson coefficient; the 2D histogram |
Notebooks¶
Each notebook holds all the code of one page and runs in Colab without setup. Two of the notebooks download a small data file (154 KB) on first run.
Tools¶
| Tool | What it is for |
|---|---|
scipy.stats (Python) |
Statistical tests, correlation coefficients, and distributions |
statsmodels (Python) |
Statistical models and more tests, such as the two-proportions z-test |
matplotlib (Python) |
Histograms, box plots, CDFs, scatter plots, and 2D histograms |
| R | A language made for statistics |
Every plot and test in this module uses scipy.stats, statsmodels, and matplotlib.
Related¶
- Data format and management, whose tabular data notebook covers the pandas tables that these notebooks use
- Measurements and metrics, whose scores are the numbers that you describe and compare with these methods