hist.DHARMa | R Documentation |
The function produces a histogram from a DHARMa output. Outliers are marked red.
## S3 method for class 'DHARMa'
hist(x, breaks = seq(-0.02, 1.02, len = 53),
col = c(.Options$DHARMaSignalColor, rep("lightgrey", 50),
.Options$DHARMaSignalColor), main = "Hist of DHARMa residuals",
xlab = "Residuals (outliers are marked red)", cex.main = 1, ...)
x |
A DHARMa simulation output (class DHARMa) |
breaks |
Breaks for hist() function. |
col |
Color for histogram bars. |
main |
Plot title. |
xlab |
Plot x-axis label. |
cex.main |
Plot cex.main. |
... |
Other arguments to be passed on to hist(). |
The function calls hist() to create a histogram of the scaled residuals. Outliers are marked red as default but it can be changed by setting options(DHARMaSignalColor = "red")
to a different color. See getOption("DHARMaSignalColor")
for the current setting.
plotSimulatedResiduals, plotResiduals
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)
############# Distribution ######################
plotQQunif(simulationOutput = simulationOutput,
testDispersion = FALSE,
testUniformity = FALSE,
testOutliers = FALSE)
hist(simulationOutput )
############# residual plots ###############
# rank transformation, using a simulationOutput
plotResiduals(simulationOutput, rank = TRUE, quantreg = FALSE)
# smooth scatter plot - usually used for large datasets, default for n > 10000
plotResiduals(simulationOutput, rank = TRUE, quantreg = FALSE, smoothScatter = TRUE)
# residual vs predictors, using explicit values for pred, residual
plotResiduals(simulationOutput, form = testData$Environment1,
quantreg = FALSE)
# if pred is a factor, or if asFactor = TRUE, will produce a boxplot
plotResiduals(simulationOutput, form = testData$group)
# to diagnose overdispersion and heteroskedasticity it can be useful to
# display residuals as absolute deviation from the expected mean 0.5
plotResiduals(simulationOutput, absoluteDeviation = TRUE, quantreg = FALSE)
# All these options can also be provided to the main plotting function
# If you want to plot summaries per group, use
simulationOutput = recalculateResiduals(simulationOutput, group = testData$group)
plot(simulationOutput, quantreg = FALSE)
# we see one residual point per RE
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.