Tweaking model diagnostic plots?

9 views
Skip to first unread message

Hartman, Rosemary@DWR (she/her)

unread,
Feb 19, 2026, 6:47:56 PM (4 days ago) Feb 19
to Bay-Delta Data Science Fun

Hi Data Science PWT,

 

I would like to include some nice-looking model diagnostic plots with a paper, and my all-time favorite model diagnostic tool is the R package DHARMa. However, I want to tweak the output graphs just slightly to make them nicer for inclusion in a manuscript. Smaller points, move the “dispersion test” label so it’s readable, etc. But I can’t figure out how to modify the graphs or recreate the graphs from the simulated residuals. Has anyone done this before? Or have suggestions of other nice diagnostic plots?

 

Thanks!

 

library(DHARMa)

### ** Examples from the manual

 

testData = createData(sampleSize = 200, family = poisson(),

                      randomEffectVariance = 1, numGroups = 10)

fittedModel <- glm(observedResponse ~ Environment1,

                   family = "poisson", data = testData)

simulationOutput <- simulateResiduals(fittedModel = fittedModel)

 

######### main plotting function #############

 

# for all functions, quantreg = T will be more

# informative, but slower

 

plot(simulationOutput, quantreg = FALSE)

 

---
Rosemary Hartman,
PhD, she/her
Environmental Program Manager

Rosemary...@water.ca.gov
California Department of Water Resources
M:
916-882-2926

saveourwater.com

 

Andrews, Lucy@DWR (she/her)

unread,
Feb 19, 2026, 11:45:26 PM (4 days ago) Feb 19
to Bay-Delta Data Science Fun, Hartman, Rosemary@DWR (she/her)
Hi Rosie - fun question! I hope I can answer it (admittedly I'm not that familiar with the methods, but I do know funky plotting code...) - here are my thoughts, lmk if I missed the mark:

 I've attached a script that produces ggplot objects that mimic the DHARMa plot objects. This should give you greater control over layout, aesthetics, axis breaks and labels, etc. Here are the plots that the script produces (obviously a little different than yours given that the data are generated through simulation). Hit me up if you have other questions about this, happy to follow up with you.

Lucy




From: 'Hartman, Rosemary@DWR (she/her)' via Bay-Delta Data Science Project Work Team <bay-delta-...@googlegroups.com>
Sent: Thursday, February 19, 2026 3:47 PM
To: Bay-Delta Data Science Fun <bay-delta-...@googlegroups.com>
Subject: [bay-delta-datascience] Tweaking model diagnostic plots?
 
--
https://interagencyecologicalprogram.github.io/DataScience/
---
You received this message because you are subscribed to the Google Groups "Bay-Delta Data Science Project Work Team" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bay-delta-datasc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bay-delta-datascience/SA1PR09MB10668A59A8386CAB7A4072203BC6BA%40SA1PR09MB10668.namprd09.prod.outlook.com.
dharma_plotting_example.R

Hartman, Rosemary@DWR (she/her)

unread,
Feb 20, 2026, 10:37:32 AM (4 days ago) Feb 20
to Andrews, Lucy@DWR (she/her), Bay-Delta Data Science Fun

Wow, this is PERFECT! Thanks so much!

Reply all
Reply to author
Forward
0 new messages