emulator_plot: Plot Emulator Outputs

Description Usage Arguments Details Value Examples

View source: R/plotting.R

Description

A wrapper for plotting emulator outputs, for two dimensions.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
emulator_plot(
  em,
  var_name = "exp",
  npoints = 40,
  targets = NULL,
  cb = FALSE,
  params = NULL,
  fixed_vals = NULL,
  ...
)

Arguments

em

A single Emulator object, or a list thereof

var_name

The output to plot: options are described above

npoints

The number of lattice points per input direction

targets

The observations. Required if plotting implausibility

cb

Should implausibility plots be coloured as colourblind friendly?

params

Which input parameters should be plotted?

fixed_vals

What should the fixed values of unplotted parameters be?

...

Any optional parameters for nth_implausible

Details

If the input space is greater than 2-dimensional, the mid-range values are chosen for any input beyond the plotted two, unless specific slice values are chosen (see below).

If a list of k emulators are given (e.g. those derived from emulator_from_data or full_wave), then the result is a kx3 grid of plots. If a single emulator is given, then a single plot is returned.

Options for plotting variables are passed via the var parameter: current choices are 'exp' (Expectation), 'var' (Variance), 'imp' (Implausibility), and 'maximp' (n-th maximum Implausibility). If either of the implausibilities are desired, the targets parameter must not be NULL. Bear in mind that n-th maximum implausibility is only permitted if a list of emulators is provided: the ... parameters that can be passed to this function are for optional parameters that can be passed to the nth_implausible function (for example, which level of maximum implausibility is wanted).

The two parameters params and fixed_vals determine the 2d slice that is plotted. The argument params should be a list containing exactly two elements: the names of the two parameters to plot. The argument fixed_vals can contain any number of remaining parameters and the values to fix them at: this should be a named list of values. If any parameters do not have specified values, their mid-range values are chosen.

Value

A ggplot object.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
 ranges <- list(aSI = c(0.1, 0.8), aIR = c(0, 0.5), aSR = c(0, 0.05))
 targets <- list(
  list(val = 281, sigma = 10.43),
  list(val = 30, sigma = 11.16),
  list(val = 689, sigma = 14.32)
 )
 outputs <- c('nS','nI','nR')
 ems <- emulator_from_data(GillespieSIR, outputs, ranges, deltas=rep(0.1, 3), quadratic = TRUE)
 t_ems <- purrr::map(seq_along(ems), ~ems[[.]]$adjust(GillespieSIR, outputs[[.]]))
 names(t_ems) <- outputs
 emulator_plot(t_ems$nI)
 emulator_plot(t_ems, var_name = 'var', npoints = 10)
 emulator_plot(t_ems, var_name = 'sd', npoints = 10)
 emulator_plot(t_ems, var_name = 'imp', targets = targets, npoints = 10)
 emulator_plot(t_ems, npoints = 10, fixed_vals = list(aSR = 0.01))
 emulator_plot(t_ems, npoints = 10, params = c('aSI', 'aSR'), fixed_vals = list(aIR = 0.4))

Tandethsquire/emulatorr documentation built on April 12, 2021, 1:08 a.m.