Subject: Re: [R] lm question
From: Martyn Plummer (plummer@iarc.fr)
Date: Mon 09 Oct 2000 - 20:43:20 EST
Message-ID: <XFMail.001009124320.plummer@iarc.fr>
On 09-Oct-00 Peter Dalgaard BSA wrote:
> Bill Simpson <wsi@gcal.ac.uk> writes:
>
>> I have not really used lm before and I was hoping for some help on a
>> simple problem.
>
>> I want to fit a model that has one y-intercept and three slopes, one for
>> each group.
>
> Actually, this is not so simple because it goes somewhat against the
> grain of the way the S/R model formulas are designed (they generally
> assume that identical intercepts only make sense with identical
> slopes).
>
> However,
>
>> lm(y~x:(grp-1)+1)
>
> Call:
> lm(formula = y ~ x:(grp - 1) + 1)
>
> Coefficients:
> (Intercept) x.grpa x.grpb x.grpc
> -0.80977 0.01847 0.13124 0.14259
>
> The form grp-1 gives you the "no-intercept" coding of the grp factor
> and its interaction (":") with x specifies separate slopes for each
> group. Once you've used "-1" the intercept disappears from the model,
> so you need to add it back in with "+1".
Is that really necessary?
R> lm(y ~ grp:x, data=foo)
Call:
lm(formula = y ~ grp:x, data = foo)
Coefficients:
(Intercept) grpa.x grpb.x grpc.x
-0.80977 0.01847 0.13124 0.14259
Martyn
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Thu 01 Feb 2001 - 16:14:27 EST