1
$\begingroup$

I have been looking for a clear answer to my question, with unsuccessful results so far... I am using R to compute a linear model between two variables. In a perfect world, I should obtain a relationship such as y = x, with a slope equal to 1 and an intercept of 0.

Below is a summary of the linear model I am computing with R:

Call:
lm(formula = Y ~ X, data = Data)

Residuals:
     Min       1Q   Median       3Q      Max 
-24.6647  -2.5081   0.7563   2.8372  24.9408 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept) -5.80592    1.48049  -3.922 0.000171 ***
X            1.09599    0.02548  43.015  < 2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 8.121 on 90 degrees of freedom
Multiple R-squared:  0.9536,    Adjusted R-squared:  0.9531 
F-statistic:  1850 on 1 and 90 DF,  p-value: < 2.2e-16

I understand that my intercept is -5.8 and slope 1.09. What I don't understand, based on the p-value that is also provided, if it says that it is statistically different from 0 and 1, or the complete opposite?

Thanks a lot for your help !! :)

$\endgroup$
4
  • $\begingroup$ The reference value is 0 for both terms, so the hypotheses are testing whether the intercept and slope are different from 0. $\endgroup$ Commented Jul 16, 2021 at 10:12
  • $\begingroup$ Thank you for you comment! So if I understand correctly, my intercept is different from 0, and so is my slope. Could you help me in identifying if my slope is different from 1? Thanks a lot! $\endgroup$
    – Thomas
    Commented Jul 16, 2021 at 10:17
  • 1
    $\begingroup$ To test both at the same time, try lm(y~x,offset=x,...) or equivalently lm((y-x)~x,,...) then look a the F-value for the regression. If you just want to test for slope being different from 1, just look at the test for its coefficient. $\endgroup$
    – Glen_b
    Commented Jul 17, 2021 at 7:35
  • $\begingroup$ Perhaps the simplest way to answer this question is to re-run the command in the form lm(Y-X ~ X, Data) and inspect the p-value at the bottom right of the summary output: it is a simultaneous test of your hypotheses. $\endgroup$
    – whuber
    Commented Oct 4, 2023 at 23:51

3 Answers 3

1
$\begingroup$

Unless there is a way to specify otherwise like there is in a function like t.test, the p-values in this kind of printout in R is for a test of the coefficient being zero, so you have quite strong evidence that neither the slope nor the intercept is zero. (Nothing you did specifies otherwise, though there might be a way to code the summary function to do so. If there is, I don’t know it.)

You have use the standard error and estimated value to construct a confidence interval. While there are ways to be more thorough about such a calculation, a “quick and dirty” way to get about a $95\%$ confidence interval for each coefficient is to take the estimated value $\pm$ two standard errors.

$$ \text{Intercept}: -5.81\pm 1.48 = (-8.77, -2.85)\\ \text{Slope}: 1.10\pm 0.0255 = (1.05, 1.15) $$

These confidence intervals give somewhat strong evidence that the intercept is not zero and the slope is not one (though this one is close and might not be practically different from one; that is, the true (population-level) slope might not be one but might not be so different that you care).

$\endgroup$
1
  • $\begingroup$ There’s much to consider when it comes to practical significance. For instance, I see a smallest magnitude of or $2.85$ in the intercept confidence interval and think that’s way too big. You know your subject and your problem, and you are free to decide otherwise. Perhaps any intercept (magnitude) less than ten is okay; perhaps any intercept (magnitude) less than a hundred is okay. Ditto for the slope. // My answer ignores the issue of multiple testing. It is not unusual to do this when it comes to regression coefficients, but that is not without controversy. //@Henry Thanks, good catch! $\endgroup$
    – Dave
    Commented Jul 16, 2021 at 10:56
0
$\begingroup$

The package emmeans has a great function to test various hypotheses about linear models. Here I show how to test the slope different than 1 (the standard summary output already tests the intercept different from zero.

> data(trees)
> 
> mod <- lm(Height ~ Girth, data=trees)
> summary(mod)

Call:
lm(formula = Height ~ Girth, data = trees)

Residuals:
     Min       1Q   Median       3Q      Max 
-12.5816  -2.7686   0.3163   2.4728   9.9456 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  62.0313     4.3833  14.152 1.49e-14 ***
Girth         1.0544     0.3222   3.272  0.00276 ** 
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 5.538 on 29 degrees of freedom
Multiple R-squared:  0.2697,    Adjusted R-squared:  0.2445 
F-statistic: 10.71 on 1 and 29 DF,  p-value: 0.002758

> 
> library(emmeans)
> mod.emt <- emtrends(mod, ~1, var="Girth")
> mod.emt
 1       Girth.trend    SE df lower.CL upper.CL
 overall        1.05 0.322 29    0.395     1.71

Confidence level used: 0.95 
> test(mod.emt, null=1)
 1       Girth.trend    SE df null t.ratio p.value
 overall        1.05 0.322 29    1   0.169  0.8672
$\endgroup$
0
$\begingroup$

I think you're looking for a joint test of the intercept and slope, so I would recommend a wald test with two degrees of freedom. To use the wald.test function you need the aod library and package.

> install.packages("aod", repos="http://cran.rstudio.com")
> library(aod)
> your_model <- lm(formula = Y ~ X, data = Data)
> wald.test(b = coef(your_model),
+.          H0 = c(0,1),
+           Sigma = vcov(your_model),
+.          Terms = 1:2)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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