Dear lme and lmer -ers, I have some problems using "home-made" contrast matrix in lme and lmer.
I did an experiment to investigate the relationship between the response of an animal and some factors, namely the light wavelength (WA), the light intensity to which this animal was exposed and the sex of the animal tested. - The response can be a variable LA (normal distribution) or another variable PE (normal distribution). Each analysed separately. - WA has 6 different levels: 400, 430, 470, 540, 570, 620 nm. - the light intensity has 4 different levels: 1, 2, 7, 50. - the same animal was used in several tests. I suspect the response varies quadratically with WA (intermediate wavelengths more efficient to evoke a response than extreme wavelengths) but I would like to know if 470 is different from 540 nm, if 430 is different from 570 nm... I analyse the response with WA as an ordered factor, either with lmer (for PE) or with lme (for LA). All models tested converge but the by-default contrast matrix is really hard to interpret because all the contrasts always involve all the wavelengths. Here is an example of the syntax for lmer and lme, for the complete model: model1<-lmer(PE~Sex+LightIntensity+ordered(WA)+(1|Animal),data=datamic,na.action=na.omit,family="poisson",REML=FALSE) model2<-lme(LA~Sex+LightIntensity+ordered(WA),random=~1|Animal,data=datamic,na.action=na.omit,method="ML") So I built a specific contrast matrix: cmat.r<-matrix(c(-3/6,-2/6,-1/6,+1/6,+2/6,+3/6, # linear effect -3/6,+1/6,+2/6,+2/6,+1/6,-3/6, # main quadratic effect 0,0,-1/2,+1/2,0,0, # mid wavelengths 0,-1/2,0,0,+1/2,0, #intermediate wavelengths -1/2,0,0,0,0,+1/2),6,5) # extreme wavelengths colnames(cmat.r) <- c(".L",".Q",".mid",".inter",".extr") contrasts(ordered(datamic$WA)<- cmat.r When I run the lme models, for all models involving WA, I get an error message (approximate English translation): Error in MEEM(object, conLin, control$niterEM) : Singularity encountered in inverse resolution in level 0, block 1 When I run the lmer models, for all models involving WA, I get an error message (approximate English translation): Warning message: In mer_finalize(ans) : gr cannot be computed at initial par (65) What is/are the problems and the solutions? - Is the contrast matrix of a rank inferior to what it should be? - Are there some other code lines I should have put to facilitate convergence? Thank you for your help. Doris Gomez [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.