# How to do a hypothesis test of a coefficient’s significance

## Description

Let’s say we have a linear model, either one variable or many. How do we conduct a test of significance for the coefficient of a single explanatory variable in the model? Similarly, how can we determine if an explanatory variable has a significant impact on the response variable?

## Solution, in R

View this solution alone.

We will use the fake data shown below with a single variable model. You can use a model created from your own actual data instead.

1
2
3
x <- c( 34,   9,  78,  60,  22,  45,  83,  59,  25)
y <- c(126, 347, 298, 309, 450, 187, 266, 385, 400)
model <- lm(y ~ x)


We can test whether a coefficient is zero by using that as our null hypothesis, $H_0: \beta_i = 0$. We can use any value $0 \le \alpha \le 1$ as our Type 1 error rate; we will set $\alpha$ to be 0.05 here.

The answer to our hypothesis test can be obtained by looking at just the coefficients portion of the model summary:

1
summary(model)$coef  1 2 3 Estimate Std. Error t value Pr(>|t|) (Intercept) 354.082248 76.732772 4.6144853 0.002441995 x -1.009013 1.472939 -0.6850334 0.515358250  The final column of output shows$p$-values for each$\beta_i$. The$p$-value associated with the$x$row is therefore for$\beta_1$, the coefficient on$x$. Because it is 0.515358250, which is greater than$\alpha$, we cannot reject the null hypothesis, and we should continue to assume that$\beta_1=0\$ and there is no significant relationship between the explanatory and response variable in this situation.

See a problem? Tell us or edit the source.

## Opportunities

This website does not yet contain a solution for this task in any of the following software packages.

• Python
• Excel
• Julia

If you can contribute a solution using any of these pieces of software, see our Contributing page for how to help extend this website.