Code Monkey home page Code Monkey logo

Comments (6)

florianhartig avatar florianhartig commented on July 17, 2024

Hello,

this is expected (however, admittedly, not ideal behaviour). The reason behind this is the following:

  • DHARMa residuals are not expected to change when including REs, in particular REs with covariance structures, because glmmTMB does not (yet) allow to condition simulations and predictions on the fitted REs. Basically DHARMa residuals are calculated around your fixed effect structure (though they re-simulate the REs). See #16 and just opened issue glmmTMB/glmmTMB#888.

  • glmmTMB residuals are calculated conditional on fitted REs, so in this case you see the residual correlation minus the RE structure.

How to fix this:

First of all, the fact that your autocorrelation structure disappears with glmmTMB residuals (either unstructured or with a structured RE) means that the REs are temporally autocorrelated, so you should fit an AR1 structure.

Ifs you test a glmmTMB model with covariance in the REs (such as AR1) in DHARMa, you can currently either ignore the autocorrelation, or use the rotation argument, see #364. I hope that the glmmTMB developers will include an option to condition simulations on the fitted REs in the future, which should produce similar residuals as you produce with act(residuals(model)).

from dharma.

mlkirchner avatar mlkirchner commented on July 17, 2024

Hi Florian,

Thanks for the quick and helpful response! I didn't realize that the DHARMa residuals for glmmTMB are not conditioned on the RE structure, but then it makes complete sense that the autocorrelation would still be present.

I'm fine with ignoring the autocorrelation in DHARMa until glmmTMB #888 is addressed.

But I did try the rotation argument and am still not getting the same results as acf. That's also to be expected, right? Because as you said in #301, "The problem, however, is that this will likely only work perfectly for symmetric linear homogenous cdfc, such as the multivariate normal." So, hypothetically, since I'm seeing a decrease in the autocorrelation structure by including the rotation argument, that's indicative that the AR1 structure is effective, even though the autocorrelation isn't completely solved by DHARMa's calculations?

This is mostly out of curiosity at this point, because as I said, I'm fine with continuing to use glmmTMB's residuals and acf to detect autocorrelation structure.

Thanks again!
Michelle

from dharma.

florianhartig avatar florianhartig commented on July 17, 2024

Hello Michelle,

you tried this on your AR1 model, right? My comments referred to real GLMMs - in your case, you essentially fit an LMM, so the rotation should be exact, provided your nSim is large enough.

By exact, I mean that the autocorrelation part of the AR1 model is correctly removed, and if you see autocorrelation remaining in the DHARMa residuals with rotation, you should probably interpret this as some kind of signal remaining.

There are still differences between the residuals, because DHARMa does not condition on your other REs, so the residuals will differ in their exact numeric values. It could be that some of the other REs absorb autocorrelation. In particular, in your model, you have both

(1 | date)
ar1(date + 0 | id)

The (1 | date) will likely absorb autocorrelation that does not fit the form of the AR1, which would show up in DHARMa but not in the glmmTMB plots. You could test this by calculating the acdf acf on the fitted REs of (1 | date)

Cheers,
Florian

from dharma.

mlkirchner avatar mlkirchner commented on July 17, 2024

from dharma.

florianhartig avatar florianhartig commented on July 17, 2024

typo, I meant acf

from dharma.

florianhartig avatar florianhartig commented on July 17, 2024

OK, I will consider this closed for the moment, in case you have further questions feel free to re-open the issue!

from dharma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.