liveBook · Manning

T-test

As explained in Effective Data Analysis

A t-test is a statistical test that evaluates differences between means using a t-distributed test statistic.

A t-test assesses whether the means of two groups differ statistically. Use an independent-samples t-test for separate groups, or a paired-samples t-test for values measured before and after a change within the same group. Start with the question and study design, not the test. section 4.2.1 section 2.1.3

Before treating a difference as a finding:

  • Inspect the distributions, including skew and extreme outliers, and check whether the groups have comparable variances. Transformations may help approximate a normal distribution. section 4.2.1
  • Plan sample size and significance threshold in advance. Power analysis estimates the sample size needed to detect a specified effect at a chosen power and alpha level. section 4.2.2
  • Interpret statistical significance alongside the size and practical importance of the difference. A larger sample can make a difference statistically significant without making it more useful to a decision. section 4.2.1

Support requests before and after a search change

Compare daily Help Center visits and chat support requests during the 90 days before a search-functionality change with the 90 days after it. An independent-samples t-test is proposed to assess differences, alongside descriptive trends and an additional non-parametric test. Communicate the result in terms the stakeholders can use, rather than reporting significance alone. section 2.1.3

Practice with weather data

To compare July temperatures in Boston and New York City, visualize both distributions, check t-test assumptions, assess sample size with an a priori power analysis, and run an independent-samples t-test. Then explain to a non-specialist both what the result suggests and what it cannot establish. section 4.3.4

import numpy as np
from scipy import stats as st     #1

n = 0     #2
mu, sigma = 75.5, 6.2
mu2, sigma2 = 77.9, 6.5
X1 = np.random.normal(mu, sigma, n)
X2 = np.random.normal(mu2, sigma2, n)     #3

result = st.ttest_ind(X1, X2)
print(result)    #4

This Python example generates two normal samples and runs an independent-samples t-test with SciPy; the sample size is supplied after power analysis. section 4.2.2

How Effective Data Analysis covers it

How deep it goes
Defines independent and paired tests, illustrates assumptions and sample-size effects, and provides exercises for power analysis and testing.
Examples
Compares support metrics around a search change, simulated scores, and July temperatures in Boston and New York City.
What it assumes
Assumes basic familiarity with group means and requires a Python environment with statsmodels, NumPy, and SciPy for the coding exercise.
What you can do after
Apply it via SciPy after checking assumptions and sample size, then summarize findings for a stakeholder.
How it connects
Links t-tests to parametric statistics, study design, power analysis, ANOVA, and non-parametric tests.

Also explained in

Compare how 2 books explain t-test →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Effective Data Analysis. The section links point to the parts of the book it draws on.