Ken Nussear wrote:> Trying to use contrast to look at differences within an lme
>
> lme.fnl.REML <- lme(Max ~ S + Tr + Yr + Tr:Yr, random = ~1 |TID,
> method = "REML")
>
> I have three levels of Tr I'm trying to contrast among different
> years (R, T97, T98), years = 1997-1999, so I'm interested in
> contrasts of the interaction term.
>
> > anova(lme.fnl.REML)
> numDF denDF F-value p-value
> (Intercept) 1 168 19255.389 <.0001
> S 1 168 5.912 0.0161
> Tr 2 116 15.919 <.0001
> Yr 1 168 77.837 <.0001
> Tr:Yr 2 168 47.584 <.0001
> > summary(lme.fnl.REML)
> Linear mixed-effects model fit by REML
> Data: NULL
> AIC BIC logLik
> 580.6991 613.5399 -281.3496
>
> Random effects:
> Formula: ~1 | TID
> (Intercept) Residual
> StdDev: 0.3697006 0.5316062
>
> Fixed effects: Max ~ S + Tr + Yr + Tr:Yr
> Value Std.Error DF t-value p-value
> (Intercept) -13.5681 113.2623 168 -0.119793 0.9048
> SM 0.2187 0.0957 168 2.284605 0.0236
> TrT97 1375.5897 164.0060 116 8.387434 0.0000
> TrT98 2890.9462 455.3497 116 6.348848 0.0000
> Yr 0.0099 0.0567 168 0.174005 0.8621
> TrT97:Yr -0.6883 0.0821 168 -8.384798 0.0000
> TrT98:Yr -1.4463 0.2279 168 -6.347310 0.0000
> Correlation:
> (Intr) SM TrT97 TrT98 Yr TT97:Y
> SM 0.067
> TrT97 -0.691 -0.049
> TrT98 -0.248 -0.001 0.171
> Yr -1.000 -0.067 0.691 0.248
> TrT97:Yr 0.691 0.048 -1.000 -0.171 -0.691
> TrT98:Yr 0.248 0.001 -0.171 -1.000 -0.248 0.171
>
> Standardized Within-Group Residuals:
> Min Q1 Med Q3 Max
> -2.19017911 -0.58108001 -0.04983642 0.57323031 2.39811353
>
> Number of Observations: 291
> Number of Groups: 119
> >
>
> When I try to get the contrast I get one of two errors each time.
>
> Trying for a paired contrast...
>
> tst <- contrast(lme.fnl.REML, a=list(Yr=levels(Yr), Tr="R"),
b=list
> (Yr=levels(Yr, Tr="T97")))
> Error in gendata.default(fit = list(modelStruct = list(reStruct = list
> ( :
> not enough factors
>
> Trying to include the other factor to make R happy....
>
> > tst <- contrast(lme.fnl.REML, a=list(Yr=levels(Yr),
Tr="R"), b=list
> (Yr=levels(Yr, Tr="T97")), c=list(Yr=levels(Yr,
Tr="T98"))
> + )
> Error in contrastCalc(fit, ...) : argument 4 matches multiple formal
> arguments
>
> Can anyone help with the syntax here?
I believe you need to include one or more values S at which to
contrast the treatments in each of the lists. So you might try
something like this:
contrast(lme.fnl.REML,
a=list(Yr=levels(Yr), Tr="R", S="M"),
b=list(Yr=levels(Yr), Tr="T97", S="M"))
or
contrast(lme.fnl.REML,
a=list(Yr=levels(Yr), Tr="R", S=levels(S)),
b=list(Yr=levels(Yr), Tr="T97", S=levels(S)))
> Thanks
>
> Ken
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
--
Chuck Cleland, Ph.D.
NDRI, Inc.
71 West 23rd Street, 8th floor
New York, NY 10010
tel: (212) 845-4495 (Tu, Th)
tel: (732) 512-0171 (M, W, F)
fax: (917) 438-0894