sens: Simple local sensitivity analysis

Description Usage Arguments Value Note Author(s) Examples

Description

Performs a simplistic local sensitivity analysis. Allows for a vector-valued objective function, that is, the sensitivity of multiple criteria with respect to parameters can be tested. See details below.

Usage

1
sens(fn, p, sort = TRUE, silent = TRUE, ...)

Arguments

fn

Objective function. This function must accept as its first argument a named numeric vector of parameters. It must return a named numeric vector (which can be of length 1).

p

Data frame specifying the parameters' default values as well as the test values. There must be four columns: 'name', 'default', 'min', and 'max'.

sort

If TRUE, the result data frames are sorted to show the most sensitive parameters at the top.

silent

If TRUE, diagnostic messages are suppressed.

...

Additional arguments passed to function fn.

Value

A list of data frames. The list length and the element names are determined by the return vector of fn. In the common case where fn returns a (named) scalar, the list is of length 1. The data frame at position i has the following columns:

Note

For a each parameter in p, function fn is called twice. In the two calls, the particular parameter is set to its lower and upper test value, respectively. All other parameters are fixed at their defaults. This procedure is applied to every parameter. In total, the sensitivity test requires 2 * nrow(p) + 1 evaluations of fn. The one additional evaluation is necessary to compute fn with default values for all parameters ('base scenario').

Lower and upper test values of the parameters can be constructed, for example, by multiplying the defaults with, say, 0.9 and 1.1. For this to work a parameter's default must not be zero.

Author(s)

David Kneis david.kneis@tu-dresden.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Sensitivity of parameters of a linear model
obs= data.frame(x=c(1,2), y=c(1,2))
model= function(p, x) { p["slope"] * x + p["intercept"] }
objfun= function(p, obs) { c(sse= sum((obs$y - model(p, obs$x))^2)) }
p= data.frame(
  name=c("slope","intercept"),
  default= c(1, 0),
  min= c(0.5, -1),
  max= c(2, 1)
)
sens(fn=objfun, p=p, obs=obs)

# Like above but for a vector-valued objective function
objfun= function(p, obs) { c(sse= sum((obs$y - model(p, obs$x))^2),
  mae= sum(abs(obs$y - model(p, obs$x)))) }
sens(fn=objfun, p=p, obs=obs)

dkneis/mcu documentation built on May 15, 2019, 9:12 a.m.

Related to sens in dkneis/mcu...