From: jason <asremlforum_at_VSNI.CO.UK>

Date: Thu, 9 Jul 2009 00:40:55 +0100

Date: Thu, 9 Jul 2009 00:40:55 +0100

cullisb wrote:

*> 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
*

*>
*

Thanks for your help, Brian.

I tried the approach you described, but it seems to me that there is no effect on ASReml-R. In the following simple example, "oats.1" and "oats.2" return the identical results. Did I do something wrong? By contrast, it worked with lm() - see the differences between "oats.x1" and "oats.x2".

Code:

anova(oats.1 <- asreml(fixed=yield ~ Variety, data=oats))

# Df Sum of Sq Wald statistic Pr(Chisq)

# (Intercept) 1 778336 1070 <2e-16 ***

# Variety 2 1786 2 0.2930

# residual (MS) 728

anova(oats.x1 <- lm(yield ~ Variety, data=oats))

# Df Sum Sq Mean Sq F value Pr(>F)

# Variety 2 1786 893 1.2277 0.2993

# Residuals 69 50200 728

contrasts(oats$Variety,how.many=1)<-matrix(c(1,-1,0),3,1)

anova(oats.2 <- asreml(fixed=yield ~ Variety, data=oats))

# Df Sum of Sq Wald statistic Pr(Chisq)

# (Intercept) 1 778336 1070 <2e-16 ***

# Variety 2 1786 2 0.2930

# residual (MS) 728

anova(oats.x2 <- lm(yield ~ Variety, data=oats))

# Df Sum Sq Mean Sq F value Pr(>F)

#Variety 1 336 336 0.4554 0.502

#Residuals 70 51650 738

Jason

-------------------- m2f --------------------

Sent using Mail2Forum (http://www.mail2forum.com).

Read this topic online here:

http://www.vsni.co.uk/forum/viewtopic.php?p=641#641

-------------------- m2f --------------------

Received on Fri Jul 09 2009 - 00:40:55 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.)