florianhartig / DHARMa

Diagnostics for HierArchical Regession Models
http://florianhartig.github.io/DHARMa/
200 stars 21 forks source link

OrdBeta() Distribution in glmmTMB #390

Open AustinNash001 opened 9 months ago

AustinNash001 commented 9 months ago

Hi Dr. Hartig,

I have been using DHARMa with the newly implemented ordered beta distribution (Kubinec 2022), ordbeta() in glmmTMB. I have noticed that every model that I have fit on proportional data that is 0,1 inclusive has simulated residuals that perfectly match the predicted line in DHARMa. I acknowledge that this is not a fully reproducible example, as I simply wanted to highlight this pattern that I have observed. There is a good chance that all of these models are fitting quite well, but I just wanted to bring this to attention. Feel free to close this if simulated residuals for the ordbeta() distribution have been implemented in DHARMa or are covered by other implementations. Thank you for your effort and incredible package!

florianhartig commented 9 months ago

Hello Austin,

I'll leave this open to check myself if I find the time, but just to say: the easiest way to check sensitivity would be to simulate an example a) without a problem, b) with a structural error, and then compare residuals.

Cheers F

AustinNash001 commented 9 months ago

Hi Dr. Hartig, I will try a simulated example and respond here. With thanks, Austin

AustinNashSci commented 8 months ago

Hi Dr. Hartig, I have simulated a dataset without structural issues and a dataset with a skewed dataset, and the DHARMa residual plot looks identical. I have never seen a residual plot of an ordbeta() glmmTMB model that looks different, which is very different from my experience with other families, which is why I was wondering if there is a deeper issue, here is the markdown. orderedBeta.pdf

florianhartig commented 8 months ago

Hi Austin,

thanks, I'll look into that - if it's not too much trouble, could you past your situation and model / DHARMa code here as well?

AustinNash001 commented 8 months ago

Hi Dr. Hartig, here is my code:

No Issue

library("DHARMa")
library("glmmTMB")

set.seed(1) 

## No issues

y = runif(n = 1000, min = 0, max = 1)
x1 = rnorm(1000)
x2 = rnorm(1000)

data = as.data.frame(cbind(y,x1,x2))

model = glmmTMB(y ~ x1 + x2, data = data, family = ordbeta())

summary(model)

plot(simulateResiduals(model))

Structural Issue

## Structural Issues

y = runif(n = 1000, min = 0, max = 1)

y[y> 0.8] = 1

y[y< 0.6] = 0

x1 = rnorm(1000)
x2 = rnorm(1000)

data = as.data.frame(cbind(y,x1,x2))

model = glmmTMB(y ~ x1 + x2, data = data, family = ordbeta())

summary(model)

plot(simulateResiduals(model))

The overall situation is that I am modeling the effects of certain environmental covariates on the percent cover of vegetation classes 0,1 inclusive. I had been using zero-inflated beta regression but I would like to use the ordered beta distribution for a more straightforward interpretation.

bbolker commented 4 months ago

Coming back here to point out that the SIMULATE code for ordbeta was added to glmmTMB one day after this was originally posted (and should be in version 1.1.8 that went to CRAN on 7 Oct 2023); when I run the code in this comment I get sensible results.

AustinNash001 commented 4 months ago

Thanks for pointing this out, looks like it is making sensible results now. Originally the same residual plot occurred for both tests.

-Austin


From: Ben Bolker @.> Sent: Wednesday, February 28, 2024 4:30 PM To: florianhartig/DHARMa @.> Cc: Nash, Austin (Contractor) @.>; Author @.> Subject: [EXTERNAL] Re: [florianhartig/DHARMa] OrdBeta() Distribution in glmmTMB (Issue #390)

This email has been received from outside of DOI - Use caution before clicking on links, opening attachments, or responding.

Coming back here to point out that the SIMULATE code for ordbeta was added to glmmTMB one day after this was originally posted; when I run the code in this commenthttps://github.com/florianhartig/DHARMa/issues/390#issuecomment-1775676669 I get sensible results.

— Reply to this email directly, view it on GitHubhttps://github.com/florianhartig/DHARMa/issues/390#issuecomment-1970163498, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BC26YPUNGE743NQFOYZ2YY3YV7D2VAVCNFSM6AAAAAA5IM25IWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNZQGE3DGNBZHA. You are receiving this because you authored the thread.Message ID: @.***>