I'm working with some data and I used R to the a linear regression model Y = aX + b. The code I used was summary(lm(Y~X)) What I got was

              Estimate  Std. Error t value Pr(>|t|)    
(Intercept) -0.3884045  0.0260232  -14.93   <2e-16 ***
X            0.0062095  0.0004635   13.40   <2e-16 ***

What I want to test now is the null hypothesis H0: a=0, that is, the case where the slope is zero.

I'm confused about how to do that. I tried using the offset parameter ( the idea was to subtract the 'a' coefficient found previously in the former fit ), but I'm not sure it is the correct way to test this hypothesis. What I did was:


and I got:

             Estimate   Std. Error t value Pr(>|t|)    
(Intercept) -3.884e-01  2.602e-02  -14.93   <2e-16 ***
X           -2.464e-08  4.635e-04    0.00        1  

Is it right? Am I now supposed to reject H0 since the p-value found was 1?



The output when you print the summary of the original model contains (in this case), the column Pr(>|t|) gives you the p-value associated with the hypothesis test you want

              Estimate  Std. Error t value Pr(>|t|)    
(Intercept) -0.3884045  0.0260232  -14.93   <2e-16 ***
X            0.0062095  0.0004635   13.40   <2e-16 ***

In this case $p < 2 \times10^{-16}$. There isn't much point reporting at that level of precision, but you are rejecting the null hypothesis that $a=0$ at all but the most ludicrous level of confidence.

For cases when you are testing multiple parameters (such as the effect of a multi-level categorical variable) you can fit the reduced model, then use anova to perform the hypothesis test.


lmFull <- lm(Fertility~., swiss)
# drop Examination and Education
lmReduced <- update(lm1, .~. - Examination - Education)
anova(lmFull, lmReduced,test= 'F')
## Analysis of Variance Table
## Model 1: Fertility ~ Agriculture + Examination + Education + Catholic + 
##     Infant.Mortality
## Model 2: Fertility ~ Agriculture + Catholic + Infant.Mortality
##   Res.Df  RSS Df Sum of Sq      F    Pr(>F)    
## 1     41 2105                                  
## 2     43 4408 -2     -2303 22.428 2.629e-07 ***
## ---
## Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
  • $\begingroup$ I'm still confused about the p-value. The very small value obtained (<2e-16) is for which null hypothesis? H0: a=0 or H0: a=0.0062095? What I wanted was the p-value for H0: a=0. $\endgroup$ – rafa Mar 15 '13 at 0:27
  • 1
    $\begingroup$ It is the p value for the hypothesis that a=0 (or the probability of getting the estimate or more extreme given the data if $a$ was actually = 0). (a=0 is the null hypothesis) $\endgroup$ – mnel Mar 15 '13 at 0:32

If I understand correctly, you're overthinking it. You're interested in a linear model mapping X, and an intercept, to Y. You're interested in the slope a mapping X to Y. The linear regression that you run (without that offset) finds a coefficient of 0.0062095. That coefficinet is very much significantly different from zero, with p<.00001. In other words, the probability that the a is zero is very small (assuming that a linear model is a good match to the data.

I think that you're done. What is this business with offsets?

  • $\begingroup$ I understand that the p-value for H0: a=0.0062095 is really small, but does it necessarily mean that H0: a=0 would have a high p-value? Could it be a little worse, but still not-rejectable? $\endgroup$ – rafa Mar 15 '13 at 0:32
  • $\begingroup$ When you run a simple regression like this in R, the P value is just telling you the probability that the coefficient is actually zero. The absolute magnitude of the coefficient depends on your data. For example, say that you are regressing weight on height. Say that you are measuring hight in kilometers. There will be a clear, significant relationship, but the units will be very small, because kilometers are very big. $\endgroup$ – generic_user Mar 15 '13 at 0:55
  • $\begingroup$ Ok, I understand now. Thank you for your consideration! $\endgroup$ – rafa Mar 15 '13 at 3:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.