testUniformity | R Documentation |
This function tests the overall uniformity of the simulated residuals in a DHARMa object
testUniformity(simulationOutput, alternative = c("two.sided", "less",
"greater"), plot = TRUE)
simulationOutput |
an object of class DHARMa, either created via simulateResiduals for supported models or by createDHARMa for simulations created outside DHARMa, or a supported model. Providing a supported model directly is discouraged, because simulation settings cannot be changed in this case. |
alternative |
a character string specifying whether the test should test if observations are "greater", "less" or "two.sided" compared to the simulated null hypothesis. See stats::ks.test for details |
plot |
if TRUE, plots calls plotQQunif as well |
The function applies a stats::ks.test for uniformity on the simulated residuals.
Florian Hartig
testResiduals, testUniformity, testOutliers, testDispersion, testZeroInflation, testGeneric, testTemporalAutocorrelation, testSpatialAutocorrelation, testQuantiles, testCategorical
testData = createData(sampleSize = 100, overdispersion = 0.5, randomEffectVariance = 0)
fittedModel <- glm(observedResponse ~ Environment1 , family = "poisson", data = testData)
simulationOutput <- simulateResiduals(fittedModel = fittedModel)
# the plot function shows 2 plots and runs 4 tests
# i) KS test i) Dispersion test iii) Outlier test iv) quantile test
plot(simulationOutput, quantreg = TRUE)
# testResiduals tests distribution, dispersion and outliers
testResiduals(simulationOutput)
####### Individual tests #######
# KS test for correct distribution of residuals
testUniformity(simulationOutput)
# KS test for correct distribution within and between groups
testCategorical(simulationOutput, testData$group)
# Dispersion test - for details see ?testDispersion
testDispersion(simulationOutput) # tests under and overdispersion
# Outlier test (number of observations outside simulation envelope)
# Use type = "boostrap" for exact values, see ?testOutliers
testOutliers(simulationOutput, type = "binomial")
# testing zero inflation
testZeroInflation(simulationOutput)
# testing generic summaries
countOnes <- function(x) sum(x == 1) # testing for number of 1s
testGeneric(simulationOutput, summary = countOnes) # 1-inflation
testGeneric(simulationOutput, summary = countOnes, alternative = "less") # 1-deficit
means <- function(x) mean(x) # testing if mean prediction fits
testGeneric(simulationOutput, summary = means)
spread <- function(x) sd(x) # testing if mean sd fits
testGeneric(simulationOutput, summary = spread)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.