# Changing null hypothesis in linear regression

I have some data that is highly correlated. If I run a linear regression I get a regression line with a slope close to one (= 0.93). What I'd like to do is test if this slope is significantly different from 1.0. My expectation is that it is not. In other words, I'd like to change the null hypothesis of the linear regression from a slope of zero to a slope of one. Is this a sensible approach? I'd also really appreciate it you could include some R code in your answer so I could implement this method (or a better one you suggest!). Thanks.

-

set.seed(20); y = rnorm(20); x = y + rnorm(20, 0, 0.2) # generate correlated data
summary(lm(y ~ x))                  # original model
summary(lm(y ~ x, offset= 1.00*x))  # testing against slope=1
summary(lm(y-x ~ x))                # testing against slope=1


Outputs:

            Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.01532    0.04728   0.324     0.75
x            0.91424    0.04128  22.148 1.64e-14 ***


            Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.01532    0.04728   0.324   0.7497
x           -0.08576    0.04128  -2.078   0.0523 .


            Estimate Std. Error t value Pr(>|t|)
(Intercept)  0.01532    0.04728   0.324   0.7497
x           -0.08576    0.04128  -2.078   0.0523 .

-
Thank you! I just couldn't figure out how to change the lm command. –  Nick Crawford Apr 21 '11 at 14:35

Your hypothesis can be expressed as $R\beta=r$ where $\beta$ is your regression coefficients and $R$ is restriction matrix with $r$ the restrictions. If our model is

$$y=\beta_0+\beta_1x+u$$

then for hypothesis $\beta_1=0$, $R=[0,1]$ and $r=1$.

For these type of hypotheses you can use linearHypothesis function from package car:

set.seed(20); y = rnorm(20); x = y + rnorm(20, 0, 0.2) # generate correlated data
mod <- lm(y ~ x))                  # original model

> linearHypothesis(mod,matrix(c(0,1),nrow=1),rhs=c(1))
Linear hypothesis test

Hypothesis:
x = 1

Model 1: restricted model
Model 2: y ~ x

Res.Df     RSS Df Sum of Sq      F  Pr(>F)
1     19 0.96022
2     18 0.77450  1   0.18572 4.3162 0.05234 .
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

-

It seems you're still trying to reject a null hypothesis. There are loads of problems with that, not the least of which is that it's possible that you don't have enough power to see that you're different from 1. It sounds like you don't care that the slope is 0.07 different from 1. But what if you can't really tell? What if you're actually estimating a slope that varies wildly and may actually be quite far from 1 with something like a confidence interval of ±0.4. Your best tactic here is not changing the null hypothesis but actually speaking reasonably about an interval estimate. If you apply the command confint() to your model you can get a 95% confidence interval around your slope. Then you can use this to discuss the slope you did get. If 1 is within the confidence interval you can state that it is within the range of values you believe likely to contain the true value. But more importantly you can also state what that range of values is.

-

The point of testing is that you want to reject your null hypothesis, not confirm it. The fact that there is no significant difference, is in no way a proof of the absence of a significant difference. For that, you'll have to define what effect size you deem reasonable to reject the null.

Testing whether your slope is significantly different from 1 is not that difficult, you just test whether the difference $slope - 1$ differs significantly from zero. By hand this would be something like :

set.seed(20); y = rnorm(20); x = y + rnorm(20, 0, 0.2)
model <- lm(y~x)

coefx <- coef(summary(model))[2,1]
seslope <- coef(summary(model))[2,2]
DF <- model$df.residual # normal test p <- (1 - pt(coefx/seslope,DF) )*2 # test whether different from 1 p2 <- (1 - pt(abs(coefx-1)/seslope,DF) )*2  Now you should be aware of the fact that the effect size for which a difference becomes significant, is > qt(0.975,DF)*seslope [1] 0.08672358  provided that we have a decent estimator of the standard error on the slope. Hence, if you decide that a significant difference should only be detected from 0.1, you can calculate the necessary DF as follows : optimize( function(x)abs(qt(0.975,x)*seslope - 0.1), interval=c(5,500) )$minimum
[1] 6.2593


Mind you, this is pretty dependent on the estimate of the seslope. To get a better estimate on seslope, you could do a resampling of your data. A naive way would be :

n <- length(y)
seslope2 <-
mean(
replicate(n,{
id <- sample(seq.int(n),1)
model <- lm(y[-id]~x[-id])
coef(summary(model))[2,2]
})
)


putting seslope2 in the optimization function, returns :

\$minimum
[1] 6.954609


All this will tell you that your dataset will return a significant result faster than you deem necessary, and that you only need 7 degrees of freedom (in this case 9 observations) if you want to be sure that non-significant means what you want it means.

-