# [R] Making slope coefficients ``relative to 0''.

From: Rolf Turner <r.turner_at_auckland.ac.nz>
Date: Fri, 16 May 2008 15:55:01 +1200

I am interested in whether the slopes in a linear model are different from 0.

I.e. I would like to obtain the slope estimates, and their standard errors,
``relative to 0'' for each group, rather than relative to some baseline.

Explicitly I would like to write/represent the model as

y = a_i + b_i*x + E

i = 1, ..., K, where x is a continuous variate and i indexes groups (levels of a factor with K levels).

The ``usual'' structure (using ``treatment contrasts'') gives

y = a + a_i + b*x + b_i*x + E

i = 2, ..., K. (So that b is the slope for the baseline group, and b_i measures
how much the slope for group i differs from that for the baseline group.

I can force the *intercepts* to be ``relative to 0'' by putting a
``-1'' into the formula:

lm(y ~ g*x-1)

But I don't really care about the intercepts; it's the slopes I'm interested in.

And there doesn't seem to a way to do the thing equivalent to the
``-1'' trick

for slopes. Or is there?

There are of course several work-arounds. (E.g. calculate my b_i- hats and their
standard errors from the information obtained from the usual model structure.
Or set up my own dummy variable to regress upon. Easy enough, and I could do that.)

I just wanted to know for sure that there wasn't a sexier way, using some aspect
of the formula machinery with which I am not yet familiar.

Thanks for any insights.

cheers,

Rolf Turner

```######################################################################
```
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Fri 16 May 2008 - 09:32:47 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 16 May 2008 - 10:30:36 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.