[R] Trouble with contrasts
Prof Brian D Ripley
ripley at stats.ox.ac.uk
Sat Jan 26 08:41:03 CET 2002
On 26 Jan 2002, Patrick E. McKnight wrote:
> Greetings,
>
> I have a nagging problem with contrasts and I can't seem to resolve it.
> A factor exists with four levels (lib1, lib2, con1, con2) and when I
> check the contrasts or set the contrasts to any of the prespecified
> ones, I do not get the exact contrasts necessary to test the
> theoretically relevant ones. I need orthogonal contrasts that look just
> like this matrix:
>
> con1 con2 con3
> lib1 1 0 1
> lib2 -1 0 1
> con1 0 1 -1
> con2 0 -1 -1
>
> How might I change the contrast matrix for this factor and this one
> alone? I see in the documentation that C ought to be the ticket but I
> can't figure out how to specify the matrix correctly. I read in MASS or
> S programming that the matrix can be specified but I was unable to
> follow the example and apply the logic to my problem.
I presume that you are using con1 and con2 in two different senses in your
rows and columns!
You need to know the order of the levels, for which it would be unusual to
have the order you gave. But if that is the order, and the factor is
called` foo'
contrasts(foo) <- M
where M is the matrix you give is all that is required: MASS p.157, last
para. You could also use C in the formula, but you will get less clear
labels on your output.
I presume you do have the balance needed to make these orthogonal
contrasts.
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272860 (secr)
Oxford OX1 3TG, UK Fax: +44 1865 272595
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list