Dear Sibylle, Have you tried to create a new variable?
ME$fDiversity <- factor(ME$Diversity) H08_lme <- lme( log(Height2008_mean) ~ fDiversity, data = ME, random = ~ 1|Plot/SubPlot, weights = varPower(form = ~Diversity), na.action = na.omit, subset = ME$Species == "Ace_pse", method = "ML" ) summary(H08_lme) anova(H08_lme) g_H08_lme <- glht(H08_lme, linfct = mcp(fDiversity = "Tukey")) Please note that Iâve added (a lot of) whitespace to your code to make it easier to read. Best regards, Thierry ir. Thierry Onkelinx Instituut voor natuur- en bosonderzoek / Research Institute for Nature and Forest team Biometrie & Kwaliteitszorg / team Biometrics & Quality Assurance Kliniekstraat 25 1070 Anderlecht Belgium + 32 2 525 02 51 + 32 54 43 61 85 thierry.onkel...@inbo.be<mailto:thierry.onkel...@inbo.be> www.inbo.be<http://www.inbo.be/> To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey Van: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] Namens Sibylle Stöckli Verzonden: donderdag 25 juli 2013 12:16 Aan: r-help@r-project.org Onderwerp: [R] lme (weights) and glht Dear R members, I tried to fit an lme model and to use the glht function of multcomp. However, the glht function gives me some errors when using weights=varPower(). The glht error makes sense as glht needs factor levels and the model works fine without weights=. Does anyone know a solution so I do not have to change the lme model? Thanks Sibylle --> works fine ME$Diversity=factor(ME$Diversity) H08_lme<-lme(log(Height2005_mean)~Diversity, data=ME, random=~1|Plot/ SubPlot, na.action=na.omit, subset=ME$Species=="Pse_men", method="ML") summary(H08_lme) anova(H08_lme) g_H08_lme<-glht(H08_lme, linfct=mcp(Diversity="Tukey")) print(summary(g_H08_lme)) --> using lme with weights I changed the order of factor() and introduced as.factor in the model H08_lme<-lme(log(Height2008_mean)~as.factor(Diversity), data=ME, random=~1|Plot/SubPlot, weights=varPower(form=~Diversity), na.action=na.omit, subset=ME$Species=="Ace_pse", method="ML") summary(H08_lme) anova(H08_lme) ME$Diversity=factor(ME$Diversity) g_H08_lme<-glht(H08_lme, linfct=mcp(Diversity="Tukey")) Error in mcp2matrix(model, linfct = linfct) : Variable(s) �Diversity� have been specified in �linfct� but cannot be found in �model�! [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org<mailto: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. * * * * * * * * * * * * * D I S C L A I M E R * * * * * * * * * * * * * Dit bericht en eventuele bijlagen geven enkel de visie van de schrijver weer en binden het INBO onder geen enkel beding, zolang dit bericht niet bevestigd is door een geldig ondertekend document. The views expressed in this message and any annex are purely those of the writer and may not be regarded as stating an official position of INBO, as long as the message is not confirmed by a duly signed document. [[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.