Skip to contents

This function takes a bag of models (x) and a set of new data (dfvar) with variation for one or more specific predictor variables to predict and plot the predictions from the bag. One can either plot only the mean or (weighted) median response for specific preditor variables, and possibly also the confidence interval, computed from the weighted quantiles of the prediction. All other variables are kept constant, as defined by the baseline parameter.

Usage

plot_response(
  x,
  dfvar,
  data,
  type = c("linear", "exponential", "logit", "cloglog")[1],
  zoi_shape = c("exp_decay", "gaussian_decay", "linear_decay", "threshold_decay")[1],
  which_cumulative = "cumulative",
  ci = TRUE,
  indiv_pred = FALSE,
  wq_probs = c(0.025, 0.5, 0.975),
  baseline = c("median", "mean", "zero")[1],
  zoi = FALSE,
  zoi_vals = c(100, 250, 500, 1000, 2500, 5000, 10000),
  ggplot = T,
  plot_mean = TRUE,
  plot_median = TRUE,
  n_features = 1,
  normalize = c(FALSE, "mean", "median", "ci")[1],
  logx = FALSE,
  ylim = NULL,
  y_lab = "Relative Selection Strength",
  col_ci = "grey",
  col_indiv = "grey",
  col_mean = "black",
  col_median = "red",
  linewidth_indiv = 1.2,
  linewidth_mean = 1.2,
  linewidth_median = 1.2,
  alpha_ci = 0.5,
  alpha_indiv = 0.3
)

Arguments

x

[bag,list]
A bag of models, resulting from a call to bag_models().

dfvar

[data.frame]
A data.frame with the values of the variables one wants to vary. All other variables are set to their mean or median (this is set by the parameter baseline). The column names of the dataframe might correspond exactly to the model covariates or to parts of that (for instance, "roads_paved_" to refer to all ZOI variables related to paved roads).

data

[data.frame]
The original data used for model fitting. Used only for taking the categories of the categorical variables.

type

[character(1)="linear"]{"linear", "exponential", "logit", "cloglog"}
Type of response. Might be "linear" (default), "exponential", "logit", and "cloglog".

zoi_shape

[character(1)="linear"]{"exp_decay", "gaussian_decay", "linear_decay", "threshold_decay"}
Shape of the ZOI. Necessary to be specified to represent correctly the estimated ZOI of the preditor variables.

ci

Should variation or confidence intervals be plotted?

wq_probs

[vector,numeric(3)=c(0.025, 0.5, 0.975)]
a three element with lower, mid, and higher weighted quantiles to be computed

Details

The function plot_response uses the bag_predict to produce the predictions.