[R] problem with se.contrast()

Prof Brian Ripley ripley at stats.ox.ac.uk
Thu Feb 17 13:53:22 CET 2005


The first problem is that Material is undefined when you called 
se.contrast, as you removed it.  This may work, but it certainly is not 
intentional and what variable gets picked up may not be predicted 
reliably.

The second is that I think you need R-devel which has some fixes.

However, I think this is an inappropriate analysis (which is why the older 
code trips up).  Your analysis is equivalent to using the fixed-effects 
model Lab + Material on the means of each Material block.  If there is 
something different about the replicates of the Material, this was a very 
poor design and so I suspect that is not what was done.  It looks like a 
randomized block design with replication in the blocks, for which

aov(Measurement ~ Lab + Material, data = testdata)

is the appropriate analysis.  In any case, there is no need of a 
multi-stratum analysis.


On Wed, 16 Feb 2005, Jamie Jarabek wrote:

> I am having trouble getting standard errors for contrasts using se.contrast() 
> in what appears to be a simple case to me. The following test example 
> illustrates my problem:
>
> Lab <- factor(rep(c("1","2","3"),each=12))
> Material <- factor(rep(c("A","B","C","D"),each=3,times=3))
> Measurement <- 
> c(12.20,12.28,12.16,15.51,15.02,15.29,18.14,18.08,18.21,18.54,18.36
> ,18.45,12.59,12.30,12.67,14.98,15.46,15.22,18.54,18.31,18.60,19.21,18.77
> ,18.69,12.72,12.78,12.66,15.33,15.19,15.24,18.00,18.15,17.93,18.88,18.12,18.03)
>
> testdata <- data.frame(Lab,Material,Measurement)
> rm(list=c("Lab","Material","Measurement"))
>
> test.aov <- with(testdata,aov(Measurement ~ Material + Error(Lab/Material)))
>
> This gives me the desired ANOVA table. I next want to get the standard
> errors for certain contrasts and following the help page for
> se.contrast() I tried the following but I get an error:
>
>> se.contrast(test.aov,list(Material=="A",Material=="B",Material=="C",Material=="D"),coef=c(1,1,-1,-1),data=testdata)
> Error in matrix(0, length(asgn), ncol(effects), dimnames = list(nm[1 + :
>        length of dimnames [1] not equal to array extent
>
> I have tested this on R 2.0.1 on Windows XP and Solaris and get the same
> error on both systems. I am unsure as to what I am doing wrong here. Thanks 
> for any help.
>
> Jamie Jarabek
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list