plot_results {EcoDiet}R Documentation

Plot the posterior means or probability distribution(s)

Description

This function plots the posterior means or probability distribution(s) for one or the two variable(s) of interest : the trophic link probabilities ("eta") and/or the diet proportions ("PI").

The figure(s) can be saved as PNG using: save = TRUE, and the directory path to which the figures are saved can be precised with: save_path = ".".

If no "pred" nor "prey" parameter is entered, the plot will be a raster plot with the mean priors for all the trophic groups.

If one predator name is entered as "pred", the probability distribution(s) will be plotted for all its prey(s) by default. Some specific prey(s) name(s) can also be entered because if a predator has 22 preys, plotting them all will make the plot hard to read. So you can specify the one or many prey(s) of interest and only display their corresponding probability distribution(s).

The "variable" parameter can be specified if one wants to plot the priors for only one variable ("PI" or "eta").

Usage

plot_results(
  jags_output,
  data,
  pred = NULL,
  prey = NULL,
  variable = c("eta", "PI"),
  save = FALSE,
  save_path = "."
)

Arguments

jags_output

the mcmc.list object output by the run_model() function

data

the preprocessed data list output by the preprocess_data() function

pred

the predator name for which we want to plot the probability densities

prey

the prey(s) name(s) for which we want to plot the probability densities

variable

the variable(s) for which we want to plot the probability densities. By default we will plot the two variables of interest: eta and PI.

save

A boolean describing whether the figure should be saved as PNG. By default the figures are not saved.

save_path

A string describing the path to which the figures should be saved. By default the figures are saved in a temporary directory.

See Also

plot_prior to plot the prior means or probability distribution(s), plot_data to plot the input data

Examples



realistic_biotracer_data <- read.csv(system.file("extdata", "realistic_biotracer_data.csv",
                                               package = "EcoDiet"))
realistic_stomach_data <- read.csv(system.file("extdata", "realistic_stomach_data.csv",
                                             package = "EcoDiet"))

data <- preprocess_data(biotracer_data = realistic_biotracer_data,
                        trophic_discrimination_factor = c(0.8, 3.4),
                        literature_configuration = FALSE,
                        stomach_data = realistic_stomach_data)
                        
write_model(literature_configuration = FALSE)

mcmc_output <- run_model("EcoDiet_model.txt", data, run_param="test")
                        
plot_results(mcmc_output, data)
plot_results(mcmc_output, data, pred = "Crabs")
plot_results(mcmc_output, data, pred = "Crabs",
             variable = "PI", prey = c("Bivalves", "Shrimps"))
             



[Package EcoDiet version 2.0.1 Index]