testQuantiles {DHARMa} | R Documentation |
Test for quantiles
Description
This function tests
Usage
testQuantiles(simulationOutput, predictor = NULL, quantiles = c(0.25, 0.5,
0.75), plot = T)
Arguments
simulationOutput |
an object of class DHARMa, either created via |
predictor |
an optional predictor variable to be used, instead of the predicted response (default) |
quantiles |
the quantiles to be tested |
plot |
if T, the function will create an additional plot |
Details
The function fits quantile regressions (via package qgam) on the residuals, and compares their location to the expected location (because of the uniform distributionm, the expected location is 0.5 for the 0.5 quantile).
A significant p-value for the splines means the fitted spline deviates from a flat line at the expected location (p-values of intercept and spline are combined via Benjamini & Hochberg adjustment to control the FDR)
The p-values of the splines are combined into a total p-value via Benjamini & Hochberg adjustment to control the FDR.
Author(s)
Florian Hartig
See Also
testResiduals
, testUniformity
, testOutliers
, testDispersion
, testZeroInflation
, testGeneric
, testTemporalAutocorrelation
, testSpatialAutocorrelation
, testQuantiles
, testCategorical
Examples
testData = createData(sampleSize = 200, overdispersion = 0.0, randomEffectVariance = 0)
fittedModel <- glm(observedResponse ~ Environment1, family = "poisson", data = testData)
simulationOutput <- simulateResiduals(fittedModel = fittedModel)
# run the quantile test
x = testQuantiles(simulationOutput)
x # the test shows a combined p-value, corrected for multiple testing
## Not run:
# accessing results of the test
x$pvals # pvalues for the individual quantiles
x$qgamFits # access the fitted quantile regression
summary(x$qgamFits[[1]]) # summary of the first fitted quantile
# possible to test user-defined quantiles
testQuantiles(simulationOutput, quantiles = c(0.7))
# example with missing environmental predictor
fittedModel <- glm(observedResponse ~ 1 , family = "poisson", data = testData)
simulationOutput <- simulateResiduals(fittedModel = fittedModel)
testQuantiles(simulationOutput, predictor = testData$Environment1)
plot(simulationOutput)
plotResiduals(simulationOutput)
## End(Not run)