[R] Error message in gamm. Problem with temporal correlation structure
Simon Wood
s.wood at bath.ac.uk
Fri Feb 17 15:45:34 CET 2012
eva,
The problem is that the random effects and correlation structure that
you have specified don't meet the restrictions required by lme (which
gamm calls). You can see this by trying
M0 <-lme(H ~ Tillage , random=list(Block=~1), na.action=na.omit, data =
mydata, correlation = corARMA(form =~ Year|Tillage, p = 1, q = 0))
which will fail because you have multiple observations of Year for each
level of Tillage, and because the random effect and correlation formulae
are incompatible.
The multiple years problem could perhaps be solved by
corARMA(form =~ Year|Tillage/Block, p = 1, q = 0)
if that makes modelling sense?
A couple of possible fixes are then...
M1 <-gamm(H ~ Tillage + s(Year, by =Tillage),
random=list(Tillage=~1,Block=~1), na.action=na.omit, data = mydata,
correlation = corARMA(form =~ Year|Tillage/Block, p = 1, q = 0))
or, if you really don't want that r.e. structure, then
M2 <-gamm(H ~ Tillage + s(Year, by =Tillage)+s(Block,bs="re"),
na.action=na.omit, data = mydata, correlation = corARMA(form =~
Year|Tillage/Block, p = 1, q = 0))
[I've assumed that the mapping between this message and the data you
sent off list is DepVar=H, Treatment=Tillage]
best,
Simon
On 17/02/12 09:35, HERNANDEZ PLAZA, MARIA EVA wrote:
>
>
> HELLO ALL,
>
> I AM GETTING AN ERROR MESSAGE WHEN TRYING TO RUN A GAMM MODEL LIKE THE ONE BELOW.
>
> I AM USING R VERSION 2.14.1 (2011-12-22) AND MGCV 1.7-12.
>
> M1<-gamm(DepVar ~ Treatment + s(Year, by =Treatment), random=list(Block=~1), na.action=na.omit, data = mydata, correlation = corARMA(form =~ Year|Treatment, p = 1, q = 0))
>
> THIS IS THE ERROR MESSAGE
>
> Error in `*tmp*`[[k]] : attempt to select less than one element
>
> I have 312 observations. I get the error when I introduce the correlation structure in the model. I have the same problem even if I use /corAR1() /or I set bs=âcrâ. I also tried to increase the number of iterations using the control option, but I find the same problem.
>
> Is there any other way in which I could include the correlation structure?
>
> I would appreciate any suggestions
>
> thanks!
>
> eva
> [[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.
--
Simon Wood, Mathematical Science, University of Bath BA2 7AY UK
+44 (0)1225 386603 http://people.bath.ac.uk/sw283
More information about the R-help
mailing list