average: Extract and average the best supported models from a...

averageR Documentation

Extract and average the best supported models from a phylogenetic path analysis.


Extract and average the best supported models from a phylogenetic path analysis.


average(phylopath, cut_off = 2, avg_method = "conditional", ...)



An object of class phylopath.


The CICc cut-off used to select the best models. Use Inf to average over all models. Use the best() function to only use the top model, or choice() to select any single model.


Either "full" or "conditional". The methods differ in how they deal with averaging a path coefficient where the path is absent in some of the models. The full method sets the coefficient (and the variance) for the missing paths to zero, meaning paths that are missing in some models will shrink towards zero. The conditional method only averages over models where the path appears, making it more sensitive to small effects. Following von Hardenberg & Gonzalez-Voyer 2013, conditional averaging is set as the default. Also see MuMIn::model.avg().


Arguments to pass to phylolm::phylolm and phylolm::phyloglm. Provide boot = K parameter to enable bootstrapping, where K is the number of bootstrap replicates. If you specified other options in the original phylo_path call you don't need to specify them again.


An object of class fitted_DAG.


  candidates <- define_model_set(
    A = NL ~ RS,
    B = RS ~ NL + BM,
    .common = c(LS ~ BM, DD ~ NL, NL ~ BM)
  p <- phylo_path(candidates, rhino, rhino_tree)

  # Models A and B have similar support, so we may decide to take
  # their average.

  avg_model <- average(p)
  # Print the average model to see coefficients, se and ci:

  ## Not run: 
  # Plot to show the weighted graph:

  # One can see that an averaged model is not necessarily a DAG itself.
  # This model actually has a path in two directions.

  # Note that coefficients that only occur in one of the models become much
  # smaller when we use full averaging:

  coef_plot(average(p, method = 'full'))
## End(Not run)

phylopath documentation built on Oct. 10, 2023, 1:05 a.m.