Learn R Programming

DHARMa (version 0.4.7)

benchmarkRuntime: Benchmark runtimes of several functions

Description

Benchmark runtimes of several functions

Usage

benchmarkRuntime(createModel, evaluationFunctions, n)

Arguments

createModel

a function that creates and returns a fitted model.

evaluationFunctions

a list of functions that are to be evaluated on the fitted models.

n

number of replicates.

Author

Florian Hartig

Details

This is a small helper function designed to benchmark runtimes of several operations that are to be performed on a list of fitted models. In the example, this is used to benchmark the runtimes of several DHARMa tests.

Examples

Run this code

createModel = function(){
  testData = createData(family = poisson(), overdispersion = 1,
                        randomEffectVariance = 0)
  fittedModel <- glm(observedResponse ~ Environment1, data = testData, family = poisson())
  return(fittedModel)
}

a = function(m){
  testUniformity(m, plot = FALSE)$p.value
}

b = function(m){
  testDispersion(m, plot = FALSE)$p.value
}

c = function(m){
  testDispersion(m, plot = FALSE, type = "PearsonChisq")$p.value
}


evaluationFunctions = list(a,b, c)

benchmarkRuntime(createModel, evaluationFunctions, 2)

Run the code above in your browser using DataLab