Re: [R] multiple comparisons with generalised least squares

2012-11-08 Thread mikachu
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.

__
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.


Re: [R] multiple comparisons with generalised least squares

2012-07-10 Thread Ariel

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.

__
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.


Re: [R] multiple comparisons with generalised least squares

2012-06-05 Thread racmar
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.

__
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.


[R] multiple comparisons with generalised least squares

2011-04-11 Thread Sandy Adriaenssens
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.

__
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.