[R] lme:correlationstructure AR1 and random factor
Ben Bolker
bbolker at gmail.com
Tue Mar 29 23:32:31 CEST 2011
yvonne fabian <yvo.fabian <at> gmx.de> writes:
>
> Dear helpers,
>
> I tried these models to run in the package nlme, but allways got the same
> error message...
>
> I have a correlation in 5 sessions within a field (n=12) with ten traps in
> one field.
>
> res2a <- lme(response~x+y+z+treatment),correlation =
> corARMA(form = ~ session|trapfield, p = 1, q = 0), random=~1|field,
> na.action=na.omit, data=plates, method="ML")
>
> res2a <- lme(response~x+y+z+treatment,correlation =
> corCAR1(form = ~ session|trapfield), random=~1|field, na.action=na.omit,
> data=plates, method="ML")
>
> Error: Incompatible formulas for groups in "random" and "correlation"
>
> What is the problem?
lme() insists that the grouping variable for the random effects
and for the correlation be the same. In your example they are
"field" and "trapfield" respectively. (The error message seems
pretty clear to me ...)
You might want to:
* invest in a copy of Pinheiro and Bates 2000, if you don't
already have one (don't know if this particular question is answered
therein, but reading it will definitely be valuable)
* post future such questions to the r-sig-mixed-models mailing
list
* consider whether you would rather use corAR1() rather than
corARMA(p=1,q=0)? They should be equivalent.
I don't know offhand of an R package that will allow you to
fit the model you want (correlation within trap-field combinations,
random effects across fields), but you might have some options/
get some ideas from posting to r-sig-mixed-models.
Ben Bolker
More information about the R-help
mailing list