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

From: Bert Gunter <gunter.berton_at_gene.com>
Date: Fri, 16 May 2008 08:45:30 -0700

 Either lm(y~ a-1 + a:x) or lm (y~ a + (a-1):x) or lm(y~ a+ a:(x-1))

-----Original Message-----
From: bgunter
Sent: Friday, May 16, 2008 8:39 AM
To: Rolf Turner
Subject: RE: [R] Making slope coefficients ``relative to 0''.

lm(y ~ a + a:(x-1))

-----Original Message-----
From: r-help-bounces_at_r-project.org [mailto:r-help-bounces_at_r-project.org] On Behalf Of Rolf Turner
Sent: Thursday, May 15, 2008 8:55 PM
To: R-help forum
Subject: [R] Making slope coefficients ``relative to 0''.

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.

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 - 16:51:31 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 - 17:30:37 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.

list of date sections of archive