t-test for a regression coefficient
Models and regression · reference distribution: t(n−k−1)
When to use it
Test whether an explanatory variable has an effect in a regression, holding the others fixed.
Null hypothesis
The coefficient is zero: βⱼ = 0.
Assumptions
- Independent, normal residuals with constant variance
Test statistic
t = \dfrac{\hat{\beta}_j}{SE(\hat{\beta}_j)}Effect size
Standardized coefficient: the effect in standard deviations of y per standard deviation of x.
\beta^*_j = \hat{\beta}_j \, \dfrac{s_{x_j}}{s_y}How to report it
b = 1.85, SE = 0.62, t(47) = 2.98, p = .005
In R and Python
R
summary(lm(y ~ x1 + x2, data = df))
Python
import statsmodels.formula.api as smf
smf.ols("y ~ x1 + x2", data=df).fit().summary()
In Python, stats is scipy.stats and np is numpy.
Variants and alternatives
- Wald, the version for generalized models
Where it sits in the catalog
Models and regression. Tests run inside a fitted model: whether a coefficient matters, whether the model explains anything and whether the residuals meet the assumptions.
In the decision tree
- What do you want to do? Test a regression model
- What do you want to test? Whether an explanatory variable has an effect
- How was the model fitted? Least squares (linear regression)