[R] Forcing the intercept

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue Nov 14 09:15:20 CET 2006


On Mon, 13 Nov 2006, Heather Maughan wrote:

> Dear R-users:
>
> I am doing multiple regressions using the "lm" function and would like to
> force the intercept to be equal to a specific value (such as 4.3).  I was
> able to find out how to force it through the origin but this does not work
> for other values.

?offset, e.g  0+x1+x2+offset(rep(4.3, 127))

You could also use y-4.3 ~ rhs, but that gives problems for prediction.

> I am also interested in forcing the regression parameters obtained from one
> regression in another regression with a subset of the data.

That makes no sense to me: do you just want to predict the fit on a 
subset? If so use predict() or fitted().

> Are either of these possible in R?  I have been searching the help guide for
> hours and have been unsuccessful.

Not sure what 'the help guide' is, but you need a book about doing 
statistics with R.


-- 
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



More information about the R-help mailing list