HERNANDEZ PLAZA, MARIA EVA
2012-Feb-17 09:35 UTC
[R] Error message in gamm. Problem with temporal correlation structure
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]]
Simon Wood
2012-Feb-17 11:41 UTC
[R] Error message in gamm. Problem with temporal correlation structure
eva, I can't manage to replicate this by simulation. Is there any chance you could send me the data off-list, and I can take a look (if so I'll only use the data for the purpose of finding out what's wrong, of course). 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
Simon Wood
2012-Feb-17 14:45 UTC
[R] Error message in gamm. Problem with temporal correlation structure
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
Seemingly Similar Threads
- an unknown error message when using gamm function
- Help with gamm errors
- GAMM : how to use a smoother for some levels of a variable, and a linear effect for other levels?
- mcv package gamm function Error in chol(XVX + S)
- ERROR: gamm function (mgcv package). attempt to set an attribute on NULL