Maps one component of one simulation from simulate_glgpm() over its
prediction grid, by default the mean, with the sampling locations overlaid
when data were also simulated. plot() of the simulation does the same.
Usage
plot_simulation(
x,
simulation = 1,
quantity = "mean",
palette = NULL,
limits = NULL,
...
)
# S3 method for class 'RiskMap_simulation'
plot(x, ...)Arguments
- x
The result of
simulate_glgpm(), including a surface.- simulation
A single simulation number to plot, defaulting to one.
- quantity
The simulated component to map, one of
"mean"(the default),"linear_predictor","spatial_effect","nugget"and"group_effect", as insimulated_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.
NULLselects the defaults ofplot_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 bygrDevices::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 ofplot_simulation(). Forplot_simulation(), arguments passed to the ggplot2 fill scale, as inplot_simulated_surface().
Details
The colours and the legend follow plot_prediction(). 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)
plot_simulation(simulation, simulation = 2)
# The same map
plot(simulation, simulation = 2)
