Plot a heatmap of the selection gradient for two variables from a fitted coevfit object.

coev_plot_selection_gradient(
  object,
  var1,
  var2,
  contour = FALSE,
  limits = c(-2.5, 2.5)
)

Arguments

object

An object of class coevfit

var1

A character string equal to one of the coevolving variables in the model

var2

A character string equal to one of the coevolving variables in the model

contour

Logical (defaults to FALSE); whether to show white contour lines to indicate where selection is stronger than drift

limits

A numeric vector of length 2 (defaults to c(-2.5, 2.5)); specifying the lower limit and the upper limit of the x and y axes.

Value

A ggplot object

Details

The selection gradient is operationalised as the ratio of the change in a trait due to deterministic selection \(\Delta\alpha\) to the change in a trait due to stochastic drift \(\sigma\). Values between -1 and 1 indicate parameter space where the change due to drift is greater than change due to selection on the trait. Conversely, values greater than 1 (or less than -1) indicate parameter space where positive (or negative) selection is stronger than drift.

If three or more traits were included in the model, other traits are held at their median values during the computations. Note that selection gradient plots can potentially produce misleading pictures of coevolutionary dynamics when other traits are held constant in models with three or more traits.

If the plot does not look right, the user might try zooming out from the default parameter space by setting wider limits. For some variables (e.g., continuous and count variables), the default limits may not be suitable.

References

Ringen, E., Martin, J. S., & Jaeggi, A. (2021). Novel phylogenetic methods reveal that resource-use intensification drives the evolution of "complex" societies. EcoEvoRXiv. doi:10.32942/osf.io/wfp95

Sheehan, O., Watts, J., Gray, R. D., Bulbulia, J., Claessens, S., Ringen, E. J., & Atkinson, Q. D. (2023). Coevolution of religious and political authority in Austronesian societies. Nature Human Behaviour, 7(1), 38-45. 10.1038/s41562-022-01471-y

Author

Scott Claessens scott.claessens@gmail.com, Erik Ringen erikjacob.ringen@uzh.ch

Examples

if (FALSE) { # \dontrun{
# fit dynamic coevolutionary model
fit <- coev_fit(
  data = authority$data,
  variables = list(
    political_authority = "ordered_logistic",
    religious_authority = "ordered_logistic"
  ),
  id = "language",
  tree = authority$phylogeny,
  # additional arguments for cmdstanr::sample()
  chains = 4,
  parallel_chains = 4,
  seed = 1
  )

# plot selection gradient
coev_plot_selection_gradient(
  object = fit,
  var1 = "political_authority",
  var2 = "religious_authority"
  )
} # }