Dear lists,

Greetings. I read message for a question in R list on May 29 from Dr. ir. Thierry Onkelinx. It is very helpful for me. It is as following:

-------------------------

Dear Luke,

A workaround is to first create a new variable for the interaction.

TimeTertile <- interaction(Time, Tertile, drop = TRUE)

And then use that variable in the model

m1 <- glmer(y ~ TimeTertile + (1|Individual) + (1|Zone) + Max + Min, family=binomial)

Please not that I use glmer() instead of lmer() which give some more clear code. At the moment, lmer() will call glmer() for you when family is not Gaussian.

Then you can run multicomp

Timetest <- glht(m1, linfct = mcp(TimeTertile = "Tukey"))

 

-------------------------

But I encounter problem when I use your method to calculate my data. In my data, I tried to analyzed the effect of different successsional age of forest, environmental variable (represented by elevation) on species richness of forest. We sampled 12 forest plots (variable plot), and each successtional age has 3 forest plots (totally 4 successional age). We tried to analyze the effect of successional age and environment on species richness within each plot. We are interested in comparing species richness of forests at different age. So in my case, one of interactive variables is factor variables (successional age) and another is numeric variable (elevation). Following above-described method, I calculated as following:

elev.age=interaction(elevation,age,drop=T);

          model1=lmer(richness~elev.age+(1|plot));

But the error message is:

            Error in rep.int(c(1, numeric(n)), n - 1L) :

            negative length vectors are not allowed.

I also tried with

         model2=lmer(richness~elev*age+(1|plot);

 comp1<-glht(model2,linfct=(mcp(stage="Tukey",interaction_average=T,covariate_average=T)));

But it gives error message:

        Warning message:

mean(<data.frame>) is deprecated.

        Use colMeans() or sapply(*, mean) instead.

I checked it many times, but cannot find the right way. Could anyone please one give me any suggestions or hint? Your help will be highly appreciated!

Best wishes,

Xiangcheng Mi

 

---------------

Xiangcheng Mi,

Institute of Botany, Chinese Academy of Sciences,

Beijing, 100093

China







	[[alternative HTML version deleted]]

