(Also posted on StackExchange but submitting to R-help to reach more potential 
experts)I am using the gamm function in the mgcv package in R to specify a 
model that predicts abundance with respect to elevation and year based on 
repeated measures from several sites. My overarching question is how abundance 
changes over elevation, knowing and accounting for the fact that it also 
changes over time. GAMM is used because I do not want to restrict the 
relationship of either elevation or year with abundance to be linear. I expect 
the data to be spatially autocorrelated within years (sites closer together 
will have more similar values than sites further apart within each year) and 
would like to account for this.
I'm having trouble figuring out the proper full formulation of the GAMM.

The variables are: 1) abundance (continuous response) 2) elevation (numeric, 
continuous predictor) 3) year (numeric, continuous predictor as we expect a 
gradual change in abundance over time) 4) spatial autocorrelation term (based 
on the lat/long of the sites where data were collected) 5) site (random factor)

The model formulation I have come up with is:

model<-gamm(abundance ~ s(elevation, bs = "tp")+s(year, bs = "tp"), 
correlation=corSpher(form = ~ y+x|year), random=list(site=~1), data=input.data)

My questions are:

Is the repeated measures nature of the data adequately accounted for here or do 
I also need to include year in my random effects (nest site in year)?

Have I properly taken year into account in my spatial autocorrelation term?
Finally, when running this model, I get an error and a warning:Error in 
corFactor.corSpatial(object):  Na/NaN/Inf in foreign function call (arg 1) In 
addition: Warning message: In min(unlist(attr(object,"covariate"))): no 
non-missing arguments to min, returning InfNot sure why this is happening. If I 
run the GAMM without the random effect of site, it does not return the error...

Not sure why this is happening. If I run the GAMM without the random effect of 
site, it does not return the error...

Many thanks in advance for any help!


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
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.

Reply via email to