Skip to content

Commit

Permalink
help simplifications to improve speed
Browse files Browse the repository at this point in the history
  • Loading branch information
florianhartig committed Sep 8, 2020
1 parent e333735 commit 212f594
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 46 deletions.
9 changes: 2 additions & 7 deletions DHARMa/inst/examples/simulateResidualsHelp.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
library(lme4)

testData = createData(sampleSize = 200, overdispersion = 0.5, family = poisson())
testData = createData(sampleSize = 100, overdispersion = 0.5, family = poisson())
fittedModel <- glmer(observedResponse ~ Environment1 + (1|group),
family = "poisson", data = testData)

Expand All @@ -18,14 +18,9 @@ residuals(simulationOutput)
# transform residuals to other pdf, see ?residuals.DHARMa for details
residuals(simulationOutput, quantileFunction = qnorm, outlierValues = c(-7,7))

# calculating summaries per group
# calculating residuals per group
simulationOutput = recalculateResiduals(simulationOutput, group = testData$group)
plot(simulationOutput, quantreg = FALSE)

# create residuals with refitting, see ?simulateResiduals for details
# n=10 is very low, set higher when using this for real
simulationOutput <- simulateResiduals(fittedModel = fittedModel,
n = 10, refit = TRUE)
plot(simulationOutput, quantreg = FALSE)


5 changes: 2 additions & 3 deletions DHARMa/inst/examples/testsHelp.R
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
testData = createData(sampleSize = 200, overdispersion = 0.5, randomEffectVariance = 0)
testData = createData(sampleSize = 100, overdispersion = 0.5, randomEffectVariance = 0)
fittedModel <- glm(observedResponse ~ Environment1 , family = "poisson", data = testData)
simulationOutput <- simulateResiduals(fittedModel = fittedModel)

Expand All @@ -7,7 +7,7 @@ simulationOutput <- simulateResiduals(fittedModel = fittedModel)
plot(simulationOutput, quantreg = TRUE)

# testResiduals tests distribution, dispersion and outliers
testResiduals(simulationOutput)
# testResiduals(simulationOutput)

####### Individual tests #######

Expand All @@ -17,7 +17,6 @@ testUniformity(simulationOutput)
# Dispersion test
testDispersion(simulationOutput) # tests under and overdispersion
testDispersion(simulationOutput, alternative = "less") # only underdispersion
testDispersion(simulationOutput, alternative = "less") # only underdispersion

# if model is refitted, a different test will be called
simulationOutput2 <- simulateResiduals(fittedModel = fittedModel, refit = TRUE, seed = 12)
Expand Down
9 changes: 2 additions & 7 deletions DHARMa/man/recalculateResiduals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions DHARMa/man/residuals.DHARMa.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions DHARMa/man/simulateResiduals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions DHARMa/man/testDispersion.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions DHARMa/man/testGeneric.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions DHARMa/man/testResiduals.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions DHARMa/man/testUniformity.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions DHARMa/man/testZeroInflation.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 212f594

Please sign in to comment.