[R-sig-ME] how to code a mixed model with spatially autocorrelated variables in glmmTMB
th|erry@onke||nx @end|ng |rom |nbo@be
Mon May 9 18:52:48 CEST 2022
Note that you need the normalised residuals because those take the
correlation structure and variance structure into account.
I use INLA for more complex models. So I can't help you that much with the
details of glmmTMB. Without the data it is hard to tell why a model doesn't
Setting a dummy dimension to a fixed value is a trick that I use to handle
unidirectional spatial structures with packages that require two dimensions.
ir. Thierry Onkelinx
Statisticus / Statistician
Vlaamse Overheid / Government of Flanders
INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND
Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
thierry.onkelinx using inbo.be
Havenlaan 88 bus 73, 1000 Brussel
To call in the statistician after the experiment is done may be no more
than asking him to perform a post-mortem examination: he may be able to say
what the experiment died of. ~ Sir Ronald Aylmer Fisher
The plural of anecdote is not data. ~ Roger Brinner
The combination of some data and an aching desire for an answer does not
ensure that a reasonable answer can be extracted from a given body of data.
~ John Tukey
Op ma 9 mei 2022 om 15:42 schreef Tim Richter-Heitmann <
trichter using uni-bremen.de>:
> Dear group,
> dear Thierry,
> thank you very much for your valuable input.
> Before i am going to ask my question, here is a reminder of my dataset:
> i have the following data:
> /outcome: Abundance data (likely negative binomial or Poisson), //
> //potentially autocorrelated//
> //environmental predictors: 8 continuous variables, potentially //
> //autocorrelated, potentially collinear.//
> //A Spatial structure of the measurement: the depth of the measurement //
> //into a sediment ("Core Depth"). Continuous, in cm. It has only one //
> //dimension, like a gradient.//
> //Location: a random effect. A factor with 7 levels with about 17 - 25 //
> //observations each. The location of the measurement on the seafloor. //
> //These Locations are so far apart, that i cant imagine that they are //
> //autocorrelated. Thus, id like to use it as factor./
> In nlme, I have coded the model like:
> mod.0 <- lme(outcome~ environmental predictors,
> random = ~ 1|Location,
> correlation = corLin(form = ~ Depth),
> (Depth as another predictor variable never improved the models, so i
> stick to just formulate them as a correlation structure; corLin yielded
> better AICs than CorAR1; i also checked collinearity and there is none).
> However, the residual plots cleary show some heteroscedasticity towards
> higher values, so i would like to switch to another family to model the
> abundance (as they are counts).
> In glmmTMB, i could code
> mod.1 <- glmmTMB(Abundance ~ Some continous predictors+ (1|Core),
> data=total, family=nbinom1)
> mod.2 <- glmmTMB(Abundance ~ ar1(as.factor(Depth) + 0 | Core),
> data=total, family=nbinom1)
> (Note: mod.1 did not converge)
> Here are my questions:
> 1. How can i combine both right hand sites in glmmTMB to have a model
> that encompasses all parameters, just like mod.0 in mlme?
> (it is that just concatening them yields either an error or ignores one
> half of the model)
> 2. glmmTMB requires coordinates for spatial structures. I can code Depth
> with an "all-zero"-Coordinate to have binary coordinates. Is this better
> than using ar1?
> Thanks for your advice and input!
> Cheers, Tim
> Am 05.05.2022 um 15:12 schrieb Thierry Onkelinx:
> > Dear Tim,
> > 1. Time is a 1D correlation structure. Depth can be thought of as a 1D
> > correlation too. So you can use similar structures.
> > 2. Model building is as much an art as a science. The full model
> > should make sense. Don't include variables for which you can't explain
> > their relevance. Avoid confounding variables. Sometimes you can reduce
> > the confounding by creating new variables based on the available
> > variables. You might want to contact a local statistician.
> > 3. Start with Poisson. Switch to negative binomial in case of
> > overdispersion. Have a look at the packages glmmtmb and INLA. They
> > provide more distributions than nlme and allow correlated random
> > effects (which you want to model the depth).
> > Best regards,
> > ir. Thierry Onkelinx
> > Statisticus / Statistician
> > Vlaamse Overheid / Government of Flanders
> > INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE
> > AND FOREST
> > Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance
> > thierry.onkelinx using inbo.be
> > Havenlaan 88 bus 73, 1000 Brussel
> > www.inbo.be <http://www.inbo.be>
> > To call in the statistician after the experiment is done may be no
> > more than asking him to perform a post-mortem examination: he may be
> > able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher
> > The plural of anecdote is not data. ~ Roger Brinner
> > The combination of some data and an aching desire for an answer does
> > not ensure that a reasonable answer can be extracted from a given body
> > of data. ~ John Tukey
> > <https://www.inbo.be>
> > Op do 5 mei 2022 om 14:06 schreef Tim Richter-Heitmann | Universitaet
> > Bremen <trichter using uni-bremen.de>:
> > Dear group,
> > i have the following data:
> > outcome: Abundance data (likely negative binomial or Poisson),
> > potentially autocorrelated
> > environmental predictors: 8 continuous variables, potentially
> > autocorrelated, potentially collinear.
> > A Spatial structure of the measurement: the depth of the measurement
> > into a sediment ("Core Depth"). Continuous, in cm. It has only one
> > dimension, like a gradient.
> > Location: a random effect. A factor with 7 levels with about 17 - 25
> > observations each. The location of the measurement on the seafloor.
> > These Locations are so far apart, that i cant imagine that they are
> > autocorrelated. Thus, id like to use it as factor.
> > I would like to model something like:
> > gls(Abundance ~ Predictors + 1|Location, correlation =
> > corGaus(~Depth))
> > Here are some questions:
> > 1. Is this ok? Since depth is linear and progressive, can it be
> > treated like a temporal structure? Or could Depth be also modelled as
> > a fixed effect? It is clear from the data that abundance varies by
> > Depth.
> > 2. What would be the best way to select the best explaining
> > 3. How to get the negative binomial distribution of the outcome into
> > the model?
> > I am very curious about your advise.
> > Best, Tim
> > --
> > Dr. Tim Richter-Heitmann
> > University of Bremen
> > Microbial Ecophysiology Group (AG Friedrich)
> > FB02 - Biologie/Chemie
> > Leobener Straße (NW2 A2130)
> > D-28359 Bremen
> > Tel.: 0049(0)421 218-63062
> > Fax: 0049(0)421 218-63069
> > _______________________________________________
> > R-sig-mixed-models using r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> Dr. Tim Richter-Heitmann
> University of Bremen
> Microbial Ecophysiology Group (AG Friedrich)
> FB02 - Biologie/Chemie
> Leobener Straße (NW2 A2130)
> D-28359 Bremen
> Tel.: 0049(0)421 218-63062
> Fax: 0049(0)421 218-63069
> [[alternative HTML version deleted]]
> R-sig-mixed-models using r-project.org mailing list
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models