# [R] Regression through the origin

Rau, Roland Rau at demogr.mpg.de
Tue May 23 13:49:42 CEST 2006

```Hi,
a first step to answer your question: Regression through the origin (=
without intercept) can be done by explicitly stating in the 'formula'
argument '-1'
If you check the help page of 'lm' for example:

help(lm)

It will say in the 'Details' section:
A formula has an implied intercept term.  To remove this use
either 'y ~ x - 1' or 'y ~ 0 + x'.  See 'formula' for more details
of allowed formulae.

An example is given at the end of the help page:
## Annette Dobson (1990) "An Introduction to Generalized Linear
Models".
## Page 9: Plant Weight Data.
ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14)
trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69)
group <- gl(2,10,20, labels=c("Ctl","Trt"))
weight <- c(ctl, trt)
anova(lm.D9 <- lm(weight ~ group))
summary(lm.D90 <- lm(weight ~ group - 1))# omitting intercept

I hope this helps a bit.

Best,
Roland

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Trujillo L.
> Sent: Tuesday, May 23, 2006 12:54 PM
> To: r-help at stat.math.ethz.ch
> Subject: [R] Regression through the origin
>
> Dear R-users:
>
> Sorry for the naiveness of my question but I have been trying in the
> R-help and the CRAN website without any success. I am trying
> to perform
> a regression through the origin (without intercept) and my
> main concern
> is about its evaluative statistics. It is clear for me that R squared
> does not make sense if you do not have an intercept in your model and
> how big is the assumption that the response is zero when all the
> predictors are zero. If I still want to perform a regression in that
> conditions, does R have any options to evaluate the model adequacy
> correctly?
>
>
> Leonardo Trujillo.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help