I want to test whether coefficients in one linear regression are different from each other or whether at least one of them is significantly different from one certain value, say
You can compare the coefficients list from each respective model (say mod1 and mod2), as in:
diff=merge(mod1$coefficients, mod2$coefficients, by=0, all=TRUE)
diff[is.na(diff)]=0
diff$error=abs(diff$x-diff$y)
diff[order(diff$error, decreasing=TRUE),]
This produces a data frame sorted by the absolute value of the difference in coefficients, i.e.:
Row.names x y error
1 (Intercept) -0.264189182 -0.060450853 2.037383e-01
6 id 0.003402056 0.000000000 3.402056e-03
3 b -0.001804978 -0.003357193 1.552215e-03
2 a -0.049900767 -0.049417150 4.836163e-04
4 c 0.013749907 0.013819799 6.989203e-05
5 d -0.004097366 -0.004110830 1.346320e-05
If the slopes are not what you are after, you can access the other coefficients using the coef() function:
coef(summary(model))
To get Pr(>|z|), for example, use:
coef(summary(model))[,"Pr(>|z|)"]