Re: Contrasts

From: <brian.cullis_at_DPI.NSW.GOV.AU>
Date: Wed, 8 Jul 2009 17:44:01 +1000

Dear jason
in answer to Q2

here is some simple R code to set up a factor with contrasts that you may
wish to include in the linear mixed model via the fixed formula argument,
I presume.

You can then interact the factor "fff" with any other terms in any way you
wish

Note that if you dont specify how.many then R will create a full matrix
with the extra column being orthogonal to the mean and the first column
and normalised

> fff <- factor(c(1,2,3,1,2,3))
> contrasts(fff) <- matrix(c(-1,1,0),3,1)
> fff
[1] 1 2 3 1 2 3
attr(,"contrasts")
  [,1] [,2]
1 -1 -0.4082483
2 1 -0.4082483
3 0 0.8164966
Levels: 1 2 3
> contrasts(fff,how.many=1) <- matrix(c(-1,1,0),3,1)
> fff
[1] 1 2 3 1 2 3
attr(,"contrasts")
  [,1]
1 -1
2 1
3 0
Levels: 1 2 3
>

HTH

warm regards

Brian Cullis
Research Leader, Biometrics &
Senior Principal Research Scientist
NSW Department of Primary Industries
Wagga Wagga Agricultural Institute

Visiting Professorial Fellow
School of Mathematics and Applied Statistics
Faculty of Informatics
University of Wollongong

Professor,
Faculty of Agriculture, Food & Natural Resources
The University of Sydney

Adjunct Professor
School of Computing and Mathematics
Charles Sturt University

Phone: 61 2 6938 1855
Fax: 61 2 6938 1809
Mobile: 0439 448 591
 
Received on Thu Jul 08 2009 - 17:44:01 EST

This webpage is part of the ASReml-l discussion list archives 2004-2010. More information on ASReml can be found at the VSN website. This discussion list is now deprecated - please use the VSN forum for discussion on ASReml. (These online archives were generated using the hypermail package.)