Hi, Sorry if this is an obvious one, but is there a simple way to modify the lm function to test whether a slope coefficient is significantly different from 1 instead of different from 0? Thanks, Martin Martin Biuw SEA MAMMAL RESEARCH UNIT Gatty Marine Laboratory School of Environmental and Evolutionary Biology University of St Andrews Fife, Scotland KY16 8LB UK phone +44 (0)1334 462630 fax + 44 (0)1334 462632 http://www.smru.st-and.ac.uk http://www.smru.st-and.ac.uk/research/individuals/martinbiuw.htm [[alternate HTML version deleted]]
No modification needed. Fit either of lm(y-x ~ x + z) lm(y ~ x + z + offset(x)) and the t-test in the summary will be a test of the coefficient of x being one. You can also use such models to do an anova against a modle with unit coefficient. On Thu, 5 Jun 2003, Martin Biuw wrote:> Sorry if this is an obvious one, but is there a simple way to modify the lm > function to test whether a slope coefficient is significantly different > from 1 instead of different from 0?-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Martin Biuw wrote:> Hi, > Sorry if this is an obvious one, but is there a simple way to modify the lm > function to test whether a slope coefficient is significantly different > from 1 instead of different from 0? > > Thanks, >There might be an easier way, but the brute force method would be: R> set.seed(1) R> x <- data.frame(x = 1:10, y = 1:10 + rnorm(10)) R> lm.x <- lm(y ~ x, data = x) R> coef.x <- summary(lm.x)$coef R> # t-statistic comparing slope to 1 R> t.x <- (coef.x["x","Estimate"]-1)/coef.x["x","Std. Error"] R> # p-value R> 2 * pt(abs(t.x), lm.x$df, lower = FALSE) [1] 0.5559868 Hope this helps, Sundar