[R-sig-ME] Spatial correlation in glmmTMB

André Pardal @ndre@p@rd@|@@ouz@ @end|ng |rom gm@||@com
Mon Jul 22 13:23:52 CEST 2019


Thank you all for the comments. Actually, there is a misspelling in my
first email and sorry for not explaining properly. I will try below:

I collected data in 62 locations along a large spatial scale (> 500 km).
And I surely have replication inside each location.
First I performed a model selection for identifying the best random
structure than the fixed structure. The final best model is as below.

m1 = glmmTMB(density ~ wave_exposure + (1|subregion/location), data=
mydata, family= nbinom1, ziformula= ~0)

The term (1|subregion/location) is the random effect of subregion and
location (and location is nested in subregion)

When I try to account for spatial correlation a have the following model:

m1.spatial = glmmTMB(density ~ wave_exposure + (1|subregion/location) +
exp(pos +0|group), data= mydata, family= nbinom1, ziformula= ~0)

The term exp(pos +0|group) refers to the spatial correlation. exp =
exponential covariance structure; pos = numFactor putting spatial
coordinates together; group = a dummy factor (mydata$group <- factor(rep(1,

I already tried to create a jitter for spatial coordinates, since some
packages do not work if the distance between two coordinates is zero.
I also tried changing the dummy factor to be a repetition from 1 to 62
(since I have 62 locations).

Actually, most of times the model not even runs and cracks my R.

Well, I guess I will try spaMM.

Thanks a lot.


On Fri, 19 Jul 2019 at 09:47, Francois Rousset <
francois.rousset using umontpellier.fr> wrote:

> Dear André,
> I saw your question on R-sig-ME. I am not sure I fully understand syntax
> in "wave_exposure + (1|location) exp(pos + 0|group)" so I hesitate to reply
> through R-sig-ME. However, perhaps you should try the spaMM package by
> library("spaMM")
> m1 <-  fitme(density ~ wave_exposure + Matern(1|easting+northing), data=
> mydata, family= negbin())
> Let me know whether this is useful.
> F.
> -------- Message transféré --------
> Sujet : [R-sig-ME] Spatial correlation in glmmTMB
> Date : Wed, 17 Jul 2019 18:15:39 +0100
> De : André Pardal <andre.pardal.souza using gmail.com>
> <andre.pardal.souza using gmail.com>
> Pour : r-sig-mixed-models using r-project.org
> Hello,
> I would like to ask for help on how to account for spatial correlation in
> glmmTMB package.
> According to the help page (
> https://cran.r-project.org/web/packages/glmmTMB/vignettes/covstruct.html),
> I need to create a numFactor object grouping coordinates and a dummy
> grouping factor.
> mydata$pos <- numFactor(mydata$easting, mydata$northing)## spatial
> coordinates
> mydata$group <- factor(rep(1, nrow(mydata)))## dummy factor
> Regarding to the dummy variable, I have 62 locations in my dataframe. The
> dummy variable should be 1 for all observations, or go from 1 to 62?
> (Actually I have tried both possibilities. First one give me convergence
> problems, second one cracks my R).
> I have been trying to run the following negative binomial mixed model:
> m1 = glmmTMB(density ~ wave_exposure + (1|location) exp(pos + 0|group),
> data= mydata, family= nbinom1, ziformula= ~0) ##
> I also tried different covariance structures (gau and mat), but no success
> so far.
> Any ideas or suggestions here?
> Thank you in advance!
> Andre.
> --
> Visiting PhD student
> School of Ocean Sciences
> Bangor University
> Menai Bridge, Anglesey, UK
> 	[[alternative HTML version deleted]]
> _______________________________________________R-sig-mixed-models using r-project.org mailing listhttps://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models

M. Sc. André Luiz Pardal-Souza
Doutorando em Evolução e Diversidade
Centro de Ciências Naturais e Humanas
Universidade Federal do ABC (UFABC)
Currículo Lattes <http://lattes.cnpq.br/6271009643657143>

Visiting PhD student
School of Ocean Sciences
Bangor University
Menai Bridge, Anglesey, UK

	[[alternative HTML version deleted]]

More information about the R-sig-mixed-models mailing list