Hi all: There's a question about glht function. My data:data_ori,which inclue CD4, GROUP,time. f_GROUP<-factor(data_ori$GROUP) f_GROUP is a factor of 3 levels(0,1,2,3) result <- lme(sqrt(CD4) ~ f_GROUP*time ,random = ~time|ID,data=data_ori) glht(result, linfct = mcp(f_GROUP="Tukey") ) Error in `[.data.frame`(mf, nhypo[checknm]) : undefined columns selected I can't find out the reason for Error. Any help from you are welcome. Many thanks! [[alternative HTML version deleted]]
On 2011-07-26 00:16, Lao Meng wrote:> Hi all: > There's a question about glht function. > > My data:data_ori,which inclue CD4, GROUP,time. > > > f_GROUP<-factor(data_ori$GROUP) > > f_GROUP is a factor of 3 levels(0,1,2,3) > > > result<- lme(sqrt(CD4) ~ f_GROUP*time ,random = ~time|ID,data=data_ori) > > glht(result, linfct = mcp(f_GROUP="Tukey") ) > Error in `[.data.frame`(mf, nhypo[checknm]) : undefined columns selected > > > I can't find out the reason for Error.I think glht() is looking for f_GROUP in data_ori. You have defined f_GROUP in your global environment but have not added it to your dataframe. Peter Ehlers> > > Any help from you are welcome. > > > Many thanks! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.
On Jul 26, 2011 Lao Meng wrote:> glht(result, linfct = mcp(f_GROUP="Tukey") ) > Error in `[.data.frame`(mf, nhypo[checknm]) : undefined columns selectedIt is almost certainly the underscore in the name ("_") that is causing the problem. Try putting the term in quotes ("f_GROUP"). Regards, Mark. ----- Mark Difford (Ph.D.) Research Associate Botany Department Nelson Mandela Metropolitan University Port Elizabeth, South Africa -- View this message in context: http://r.789695.n4.nabble.com/a-question-about-glht-function-tp3695038p3695067.html Sent from the R help mailing list archive at Nabble.com.
On Tue, 26 Jul 2011, Lao Meng wrote:> Hi all: > There's a question about glht function. > > My data:data_ori,which inclue CD4, GROUP,time. > > > f_GROUP<-factor(data_ori$GROUP) > > f_GROUP is a factor of 3 levels(0,1,2,3) > > > result <- lme(sqrt(CD4) ~ f_GROUP*time ,random = ~time|ID,data=data_ori) > > glht(result, linfct = mcp(f_GROUP="Tukey") ) > Error in `[.data.frame`(mf, nhypo[checknm]) : undefined columns selected > > > I can't find out the reason for Error.We can't either based on the information you provide. If I set up random data based on your specification, then everything works fine for me in R 2.13.1 with nlme 3.1-102 and multcomp 1.2-7. ## random data set.seed(0) data_ori <- data.frame( CD4 = rnorm(100)^2, time = runif(100), f_GROUP = factor(sample(0:3, 100, replace = TRUE)), ID = factor(rep(1:10, each = 10)) ) ## model fitting library("nlme") result <- lme(sqrt(CD4) ~ f_GROUP * time, random = ~ time | ID, data = data_ori) ## multiple comparisons library("multcomp") glht(result, linfct = mcp(f_GROUP = "Tukey")) Everything works ok. glht() just issues an appropriate warning that Tukey contrasts of f_GROUP might not be what you want in the presence of interactions.> > Any help from you are welcome. > > > Many thanks! > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >