corCAR1 doesn't allow you to have the same value of Week appearing more
than once within a level of Treatment. Maybe average these replicates,
if that makes sense in this context?
The singularity problem relates to lack of identifiability in the GAM
structure. Treatment appears too many times! The way you have things set
up the smooths of Week will be confounded with the factor(Treatment)
term, and with the smooth of Treatment. I'd be inclined to declare
Treatment as a factor and use
richness ~ s(Week,by=Treatment) + Treatment
dropping the smooth of Treatment (using this syntax will give a smooth
of Week for each level of Treatment, and the smooths will be centred, so
not confounded with the Treatment term.)
best,
Simon
On 05/10/11 15:21, Karel V wrote:> Dear all,
>
> I?m analyzing this dataset containing biodiversity indices, measured over
> time (Week), and at various contaminant concentrations (Treatment). We have
> two replicates (Replicate) per treatment.
> I?m looking for the effects of time (Week) and contaminant concentration
> (Treatment) on diversity indices (e.g. richness).
>
> Initial analysis with GAM models showed temporal autocorrelation of
> diversity. So now I?m trying to fit this gamm (gamm1):
>
> gamm1<- gamm(richness~
> s(Week,by=as.numeric(Treatment=="0"),k=6) +
> s(Week,by=as.numeric(Treatment=="0.5"),k=6) +
> s(Week,by=as.numeric(Treatment=="5"),k=6) +
> s(Week,by=as.numeric(Treatment=="15"),k=6) +
> s(Week,by=as.numeric(Treatment=="50"),k=6) +
> s(Week,by=as.numeric(Treatment=="150"),k=6) +
> s(Treatment,k=6,fx=FALSE) + factor(Treatment),
>
correlation=corCAR1(form=~Week|factor(Treatment),data=indices,family=gaussian)
>
> I seem to be having difficulties with the correlation structure. An initial
> error occurred because replicates were taken at the same time:
>
> /Error in Initialize.corCAR1(X[[2L]], ...) :
> Covariate must have unique values within groups for corCAR1 objects /
>
> I solved this by selecting one replicate but is there another solution for
> this?
>
> Moreover, when analyzing the data of one replicate, I received following
> error:
>
> /Error in MEestimate(lmeSt, grps) :
> Singularity in backsolve at level 0, block 1
> /
> I have no idea how to solve this. It seems to be related with the
complexity
> of the model because no error occurred when running a simpler gamm (gamm2):
>
> gamm2<- gamm(richness~
> s(Week,k=6,fx=FALSE) + factor(Treatment),
> correlation=corCAR1(form=~Week|conc.f), data=test,family=gaussian)
>
> Any help would be well appreciated!
>
> With kind regards,
> Karel
>
>
>
>
> --
> View this message in context:
http://r.789695.n4.nabble.com/gamm-problems-with-corCAR1-tp3874669p3874669.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> 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