From pdalgd at gmail.com  Thu Apr 22 08:32:32 2010
From: pdalgd at gmail.com (Peter Dalgaard)
Date: Thu, 22 Apr 2010 08:32:32 +0200
Subject: [Rd] Bugs? when dealing with contrasts
In-Reply-To: <i2l971536df1004211343ibca0d37do8c2bd5470f43ba4f@mail.gmail.com>
References: <l2u971536df1004211100q9beecbep1bceb5bbbd3b8175@mail.gmail.com>
	<4BCF5F60.7020203@gmail.com>
	<i2l971536df1004211343ibca0d37do8c2bd5470f43ba4f@mail.gmail.com>
Message-ID: <4BCFED80.30307@gmail.com>

Gabor Grothendieck wrote:
> On Wed, Apr 21, 2010 at 4:26 PM, Peter Dalgaard <pdalgd at gmail.com> wrote:
...
>> I.e., that R reverts to using indicator variables when the intercept is
>> absent.
> 
> Is there any nice way of getting contr.sum coding for the interaction
> as opposed to the ugly code in my post that I used to force it? i.e.
> cbind(1, model.matrix(~ fac)[,2:3] * scores)

I think not. In general, an interaction like ~fac:scores indicates three
lines with a common intercept and three different slopes, and changing
the parametrization is not supposed to change the model, whereas your
model inserts a restriction that the slopes sum to zero (if I understand
correctly). So if you want to fit "ugly" models, you get to do a little
ugly footwork.

(A similar, simpler, issue arises if you want to have a 2x2 design with
no effect in one column and/or one row (think clinical trial, placebo
vs. active, baseline vs. treated. You can only do this us explicit dummy
variables, not with the two classifications represented as factors.)


-- 
Peter Dalgaard
Center for Statistics, Copenhagen Business School
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



[Rd] Bugs? when dealing with contrasts
Peter Dalgaard