Sandy Adriaenssens
2011-Apr-11 09:50 UTC
[R] multiple comparisons with generalised least squares
Dear R users, I have used the following model: M1 <- gls(Nblad ~ Concentration+Season + Concentration:Season, data=DDD, weights=varIdent(form=~ 1 | Season*Concentration)) to assess the effect of Concentration and Season on nitrogen uptake by leaves (Nblad). I accounted for the difference in variance across the factor levels by using the varIdent function. Then I wanted to perform multiple comparisons with the glht function of the multcomp package. glht(M1,linfct = mcp(Season = "Tukey")) However, here I got an error message "Error in terms.default(object) : no terms component. Error in factor_contrasts(model) : no ?model.matrix? method for ?model? found!". Does the glht function work with a gls model? And if not, is there an other way to perform multiple comparisons for a gls model? I've searched this forum for an answer to this question, but I could only found someone with the same question which remained unanswered. I hope someone can provide an answer now! Many thanks in advance! Sandy -- View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p3441513.html Sent from the R help mailing list archive at Nabble.com.
Hi Sandy, I was wondering if you ever recieved an answer regarding the use of multiple comparisons for gls models? I have also been searching various forums and books to see if there are any methods I could use and have only found people, such as yourself, asking the same question. Many thanks if you can give any assistance, Rachel -- View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p4632412.html Sent from the R help mailing list archive at Nabble.com.
racmar wrote> > I have also been searching various forums and books to see if there are > any methods I could use and have only found people, such as yourself, > asking the same question. >I was looking into this recently, as well, and found that the problem has to do with building the model.matrix/terms/model.frame for gls objects when using the glht function. I ended up creating three gls-specific functions and was able to get estimates/confidence intervals for the toy example below. You may find these functions useful (under the caveat that I only checked that I got estimates and not that the estimates were correct ;) ). Ariel Example: library(nlme) Orthodont$fage <- factor(Orthodont$age) #toy example with Orthodont data using age as a factor fitgls <- gls( distance ~ fage, data=Orthodont, weights = varIdent(form =~1|fage)) library(multcomp) #notice the error about the model.matrix for gls objects when using glht confint( glht (fitgls, mcp(fage="Tukey") )) #create model.frame, terms, and model.matrix functions specifically for gls objects model.matrix.gls <- function(object, ...) model.matrix(terms(object), data = getData(object), ...) model.frame.gls <- function(object, ...) model.frame(formula(object), data = getData(object), ...) terms.gls <- function(object, ...) terms(model.frame(object),...) #now run glht again confint( glht( fitgls, mcp(fage="Tukey") )) -- View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p4636009.html Sent from the R help mailing list archive at Nabble.com.
Ariel THANK YOU for posting this. worked great for me just pasting this part into R Ariel wrote> model.matrix.gls <- function(object, ...) > model.matrix(terms(object), data = getData(object), ...) > > > model.frame.gls <- function(object, ...) > model.frame(formula(object), data = getData(object), ...) > > > terms.gls <- function(object, ...) > terms(model.frame(object),...)and running ghlt again. it seemed to me like the output was correct. -- View this message in context: http://r.789695.n4.nabble.com/multiple-comparisons-with-generalised-least-squares-tp3441513p4648972.html Sent from the R help mailing list archive at Nabble.com.
Maybe Matching Threads
- Extracting the full coefficient matrix from a gls summary?
- xen4.0.0 64 bit boot "panic on cpu 0, crc errror"
- xen4.0.0 64 bit boot "panic on cpu 0, crc errror"
- Do we have a tree to support 2.6.34 dom0 kernel
- What''s the different for "dom0_max_vcpus=4 dom0_vcpus_pin" and "dom0_max_vcpus=4" ?