Skip to contents

Maps one component of a surface extracted with simulated_surface() over its prediction grid, by default the mean. plot() of the surface does the same.

Usage

plot_simulated_surface(
  x,
  quantity = "mean",
  palette = NULL,
  limits = NULL,
  ...
)

# S3 method for class 'RiskMap_simulated_surface'
plot(x, ...)

Arguments

x

The result of simulated_surface().

quantity

The simulated component to map, one of "mean" (the default), "linear_predictor", "spatial_effect", "nugget" and "group_effect", as in simulated_values(). The mean is the prevalence for a binomial model, the mean per unit exposure for a Poisson or negative binomial model and the mean of the response for a Gaussian model. The nugget and the group effect are zero when the model has none.

palette

Colour palette. NULL selects the defaults of plot_prediction(), a calm-to-alarm sequential palette for the mean and a palette centred at zero for the linear predictor and the effects. A character vector of colours or the name of an HCL palette accepted by grDevices::hcl.colors() can be supplied. Prefix a named palette with "-" to reverse it, for example "-Viridis".

limits

NULL (the default) or a numeric vector of two increasing numbers giving the range of the colour scale, for example to map several simulations on a common scale.

...

For plot(), the arguments of plot_simulated_surface(). For plot_simulated_surface(), arguments passed to the ggplot2 fill scale, for example transform = "sqrt" for skewed values. The map sets colours, limits, breaks, labels, oob, na.value and guide itself. To change them, add another fill scale to the map with +.

Value

A ggplot object.

Details

The colours and the legend follow plot_prediction(), and the legend title names the mapped component. The returned object can be modified further with standard ggplot2 functions.

Examples

data(italy_sim)
example_data <- italy_sim[1:50, ]
fit <- glgpm(y ~ gp(), data = example_data, family = "gaussian",
             messages = FALSE)
grid <- create_grid(create_convex_hull(example_data), spacing = 20)
simulation <- simulate_glgpm(fit, nsim = 2, what = c("data", "surface"),
                             prediction_grid = grid, seed = 1)
surface <- simulated_surface(simulation, simulation = 2)
plot_simulated_surface(surface, quantity = "spatial_effect")

# The same map
plot(surface, quantity = "spatial_effect")