Skip to content

Tukey Test, lme, error: less than two groups

4 messages · Steven McKinney, Lilith Epperlein, Mark Difford

#
Comments in-line below
I suspect the problem is the creation of all these individual variables.

Try instead

PAMdata$Treatmentf <- factor(PAMdata$treatment, levels=c("C","F"))
PAMdata$Datef <- factor(PAMdata$Date, levels=c( "25.05.10 14:00","26.05.10
 19:00","27.05.2010 7:30","27.05.10 14:00","01.06.10 14:00","02.06.10
 19:00","23.06.10 12:30"),ordered=TRUE)
...
PAMdata$PAMval <- (PAMdata$DataPAM)
PAMdata$Code<-(PAMdata$code)
etc.

so that all of your required variables are variables in the dataframe PAMdata.

When you pass off fitted model objects to additional functions, the
additional functions often require access to the dataframe used in the
initial modeling.  Then call lme with

summary(PAM.lme<-lme(PAMval~Treatmentf*Provenancef*Pretreatmentf, random=
 ~1|Datef/Code, data = PAMdata, na.action=na.omit))

then try

summary(glht(PAM.lme, linfct = mcp(Provenancef = "Tukey")))

again.
 
(If you still get an error, run the

traceback()

command and provide that information.)


I'm also wondering why no term for Pretreatmentf shows in your model output.
After setting up the factor variables in the PAMdata dataframe, what does the
command

with(PAMdata, table(Pretreatmentf, Provenancef, Treatmentf))

show?  Is Pretreatmentf even needed in the model?

The output of the command

sessionInfo() 

is also useful to help people figure out such issues.

Also, if you can share the data, or a mock-up of it, others will
be able to run code examples, and not just guess.

HTH

Steve McKinney
#
Lilith,
You need to look, in particular, at what's in your variable "Provenancef." 

##
PAMdata$Provenancef
levels(PAMdata$Provenancef)

And if the call to glht() is returning an object you need to inspect
obj$linfct. It contains the contrast matrix (for Tukey contrasts) and needs
to match the number of coefficients in your model. Try the following for
further clues:

glht(PAM.lme, linfct = mcp(Provenancef = "Tukey"))$linfct
coef(PAMaov)

Regards, Mark.