[R] Tukey Test, lme, error: less than two groups
smckinney at bccrc.ca
Thu Dec 2 23:03:47 CET 2010
Comments in-line below
> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Lilith
> Sent: December-02-10 9:39 AM
> To: r-help at r-project.org
> Subject: [R] Tukey Test, lme, error: less than two groups
> Dear R-group,
> I am trying desperately to get this Tukey test working. Its my first time
> here so I hope my question is not too stupid, but I couldn't find anything
> helpful in the help or in the forum.
> I am analysing a dataset of treated grasses. I want to find out, if the
> grasses from different Provenances react differently.
> In the aov test I found a significance for the combination Treatment and
> Treatmentf:Provenancef p-value: 0.008023 **
> In the Linear fixed effects model lme, I can see that there is a
> significance for two provenances (HU and ES)
> summary(PAM.lme<-lme(PAMval~Treatmentf*Provenancef*Pretreatmentf, random=
> Value Std.Error DF t-value
> (Intercept) 0.6890317 0.06117401 994 11.263473
> TreatmentfF -0.2897619 0.05484590 467 -5.283201
> ProvenancefDE 0.0105873 0.05484590 467 0.193037
> TreatmentfF:ProvenancefES 0.1647302 0.08226884 467 2.002340
> TreatmentfF:ProvenancefHU 0.1569524 0.07756381 467 2.023526
> No the big mystery is the Tukey test. I just can't find the mistake, it
> keeps telling me, that there are " less than two groups"
> summary(glht(PAM.lme, linfct = mcp(Provenancef = "Tukey")))
> Fehler in contrMat(table(mf[[nm]]), type = types[pm]) :
> less than two groups
> I guess its important to know that I made factors out of some of the data.
> Here is the code:
> PAMdata$provenance[PAMdata$provenance == "5"] = "ES"
> PAMdata$provenance[PAMdata$provenance == "6"] = "HU"
> # etc.
> Treatmentf <- factor(PAMdata$treatment, levels=c("C","F"))
> 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)
> Pretreatmentf <- as.factor(PAMdata$pretreatment)
> Provenancef <- as.factor(PAMdata$provenance)
> Greenhousef <- as.factor(PAMdata$greenhouse)
> Individualf <- as.factor(PAMdata$individual)
> PAMval <- (PAMdata$DataPAM)
I suspect the problem is the creation of all these individual variables.
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
PAMdata$PAMval <- (PAMdata$DataPAM)
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
~1|Datef/Code, data = PAMdata, na.action=na.omit))
summary(glht(PAM.lme, linfct = mcp(Provenancef = "Tukey")))
(If you still get an error, run the
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
with(PAMdata, table(Pretreatmentf, Provenancef, Treatmentf))
show? Is Pretreatmentf even needed in the model?
The output of the command
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.
> Thank you for any hint! That Tukey test seems so easy, I just can't find the
> Thank you very much fpr your help and greetings from Tanzania,
> View this message in context: http://r.789695.n4.nabble.com/Tukey-Test-lme-error-less-than-two-groups-
> Sent from the R help mailing list archive at Nabble.com.
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help