Comments (1)
OK, what I can say after a bit of trying around and bugfix #417 that the data shows overdispersion in the default DHARMa test, and underdispersion when looking at Pearson residuals and the PearsonChi2 test.
fit <- readRDS("~/Downloads/Basalarea_fit_Pinus.strobus_tekc(25,50).rds")
# just to get a rough idea about the dispersion - seems more underdispersed
x = residuals(fit, type = "scaled.pearson")
sd(x)
res = simulateResiduals(fit, n = 250, plot = F)
testDispersion(res) # overdispersion
testDispersion(res, type = "PearsonChisq") # underdispersion, although note
# that this test is biased towards underdispersion for strong REs
As noted , the PearsonChi2 test has a bias towards underdispersion but looking at the sd of the Pearson residuals, I'm tending to think that this is not the issue here, and that the point is indeed that we have:
- Underdispersion according to the average pearson Residual
- Overdispersion according to the DHARMa default test statistic, which is observed residual variance / expected variance.
Note that depending on the residual distribution, the two outcomes are not mutually exclusive, as the two statistics measure different things.
One thing that I noted is that if the p parameter is set wrong when fitting the Tweedie, the DHARMa test is picking up overdispersion, while the PearsonChi2 test is not, see example here (note that this will currently only work with the development version of DHARMa).
f2 <- function(x) 0.2 * x^11 * (10 * (1 - x))^6 + 10 *
(10 * x)^3 * (1 - x)^10
n <- 3000
x <- runif(n)
mu <- exp(f2(x)/3+.1);x <- x*10 - 4
y <- rTweedie(mu,p=1.5,phi=1.3)
# correct p
b <- gam(y~s(x,k=20),family=Tweedie(p=1.5))
res = simulateResiduals(b, plot = T)
testDispersion(res)
testDispersion(res, type = "PearsonChisq")
# incorrect p
b <- gam(y~s(x,k=20),family=Tweedie(p=1.1))
res = simulateResiduals(b, plot = T)
testDispersion(res) # reacts to the pattern
testDispersion(res, type = "PearsonChisq") # doesn't react to the pattern
# reason is probably that average scaled Pearson are still fine
x = residuals(b, type = "scaled.pearson")
sd(x)
Quite possibly, this or a similar issue could cause the residual pattern. As shown in the simulations, if the model is correctly specified, neither of the tests shows a problem, so something must be wrong.
All in all, while it's understandable that two tests with different test statistics may have diverging results, I don't find it super desirable that the tests are diverging so far. I'll keep this open to re-think the dispersion statistics. Problem is, as we tried, that simulated Pearson residuals don't work because of the frequent sd = 0 numeric problem. So, I currently don't see what test statistic I could generate that is closer to Pearson but stable under simulations .
from dharma.
Related Issues (20)
- Diagnostic plots for model using glmmTMB and Beta distibution HOT 6
- could not find function "ensureDHARMa"
- plotResiduals() falls back to predict and doesn't create a warning if variable doesn't exist
- Implement option to use DHARMa plots on general residual definition (bypassing simulation)
- Power of the KS test HOT 1
- How to resolve the residual versus predicted quantile devation (Dharma plot)?
- Could not find documentation on red-shaded area around smooth spline HOT 2
- Pattern in RE-grouped residual for binomial GLMM HOT 2
- Adjust DHARMa plots for color blindness
- DHARMa: fittedModel not in class of supported models for a glmmTMB model HOT 3
- Clarify dispersion tests
- Extracted Pearson residuals wrong for mccv (type should be "scaled.pearson")
- Adding support for multinomial family in mcvc::gam HOT 4
- Simulations with infitite values for weighted binomial GAM, interpreting plots HOT 3
- Move all function links to me md syntax [simulateResiduals]
- How to reject a model with underdispersion but low AIC
- DHARMa residual checks with with GLMMadaptive using ‘hurdle semi-continous’ or ‘hurdle log-normal’ HOT 1
- DHARMa: residuals and predictor do not have the same length. HOT 4
- plotResiduals() - automatically handle NA and extend form = ~
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dharma.