[R-sig-ME] spaMM::fitme() - a glmm for longitudinal data that accounts for spatial autocorrelation
Francois Rousset
|r@nco|@@rou@@et @end|ng |rom umontpe|||er@|r
Tue Jul 14 00:06:50 CEST 2020
Le 13/07/2020 à 22:42, Sarah Chisholm a écrit :
> Thank you both for your reply.
>
> Thierry, the inlabru package sounds interesting. However, I should
> have mentioned that I'm not very familiar with Bayesian statistics and
> would prefer to use other methods if possible.
>
> Francois, I apologize for not contacting you directly first. To
> clarify my question, when using the nlme::gls() function with
> longitudinal data, it is necessary to group the data first. I'm
> *pretty sure* this is to avoid having distances of zero in the
> corSpatial object, although I'm not entirely sure of the details of
> fitting this model.
>
> What I'm wondering is, will the fitme() function recognize that there
> are repeated measurements through time on the same sites (and thus,
> duplicates of the sites' coordinate points in the data set)
yes it does
> to avoid calculating distances of zero between the same site from
> different years.
Internally, spaMM avoids zero distances (or rather, the singularities
that would occur if different rows of a distance matrix represented the
same location) by handling a distance matrix only among distinct spatial
locations in the data. There is no need to declare something like
nlme::groupedData() to achieve this, and your call to spaMM::fitme() is
OK. If there are non-zero but very close locations in the data,
near-singularities may occur but spaMM also tries to deal with them
automatically.
Best,
F.
> If I were to use lme4::lmer (for a normally distributed response
> variable) without a spatial random effect, the model would look like this:
>
> M1 <- lmer(y ~ year + class + (1| biome ) + (1| continent ) + (1|ID) ,
> data = df, family = "gaussian" , REML = TRUE)
>
> Thanks so much,
>
> Sarah
>
> On Mon, Jul 13, 2020 at 4:01 PM Francois Rousset
> <francois.rousset using umontpellier.fr
> <mailto:francois.rousset using umontpellier.fr>> wrote:
>
> Dear Sarah,
>
> perhaps try to contact that package's author directly...
>
> That being said, I am not quite sure what the question is, maybe
> because
> I am not familiar with constraints on the models nlme can fit and
> with
> its syntax. What would be the formula you would use with glmer if
> there
> were no spatial random effect?
>
> Best,
>
> F.
>
> Le 12/07/2020 à 23:25, Sarah Chisholm a écrit :
> > Hello,
> >
> > I'm trying to fit a GLMM that accounts for spatial
> autocorrelation (SAC)
> > using the spaMM::fitme() function in R. I have a longitudinal
> data set
> > where observations were collected repeatedly from a number of
> sites over 13
> > years. I'm interested in understanding what the effect of time
> (year) is on
> > the dependent variable (y), as well as the fixed effect of a
> categorical
> > variable (class) while accounting for the random factors biome,
> continent,
> > and ID (a unique ID for each site sampled). My full data set
> contains ~ 180
> > 000 rows and attached is a subset of these data ('sampleDF'). My
> current
> > fitme() model looks like this:
> >
> > library(spaMM)
> >
> > M1 <- fitme(y ~ year + class + (1|biome) + (1|continent) + (1|ID) +
> > Matern(1|long + lat), data = df, family = "gaussian", method =
> "REML")
> > I have two questions:
> >
> > 1) I'm uncertain if this is an appropriate way of applying the
> > spaMM::fitme() function to longitudinal data. I have some
> experience with
> > fitting GLS models that account for SAC to a longitudinal data
> set where I
> > had to group the data set by year using the nlme::groupedData()
> function
> > before fitting the model. Does a similar method need to be used
> in the case
> > of spaMM:fitme() and longitudinal data?
> >
> > 2) Is there another R package out there that can create a
> similar model (a
> > GLMM that accounts for SAC)?. I've found very few resources
> explaining the
> > use of functions in the spaMM package other than the user guide (F.
> > Rousset, 2020. An introduction to the spaMM package for mixed
> models) and
> > I'm not quite getting the help that I need from it. I'm wondering if
> > there's another approach to modeling these data that has a
> broader user
> > base and thus more easily accessible resources / online help
> (ex. stack
> > exchange / cross validated Qs and As).
> >
> > Thank you!
> > Sarah
> > _______________________________________________
> > R-sig-mixed-models using r-project.org
> <mailto:R-sig-mixed-models using r-project.org> mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>
>
>
> --
> Sarah Chisholm
> MSc Candidate
> Department of Biology
> University of Ottawa
> Linkedin <http://www.linkedin.com/in/sarah-chisholm-422a5785>
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list