Carries out the backward phase of SURFACE's stepwise AIC routine. Beginning with a fitted Hansen model produced by surfaceForward
, tests pairwise collapses of regimes and identifies collapses that improve the fit. Continues this iterative process until the model stops improving beyond the given AIC threshold
surfaceBackward(otree, odata, starting_model, aic_threshold = 0,
max_steps = NULL, save_steps = FALSE, filename = "temp_back_list.R",
verbose = FALSE, only_best = FALSE, plotaic = FALSE,
error_skip = FALSE, sample_shifts = FALSE, sample_threshold = 2)
collapseRegimes(otree, odata, oldshifts, oldaic, oldfit, aic_threshold = 0,
only_best = FALSE, verbose = TRUE, plotaic = TRUE, error_skip = FALSE,
sample_shifts = FALSE, sample_threshold = 2)
collapseRegime
returns a list corresponding to one iteration of the backward phase of the SURFACE analysis; surfaceBackward
returns a list of such lists consisting of each step of the stepwise process
The fitted Hansen model selected for improving the AICc most over the previous iteration; consists of a single hansentree
object if the number of traits m = 1
, or a list of hansentree
objects if m > 1
The AICc for each model tested during the iteration (one per pair of regimes)
The AICc of the current Hansen model
The shifts present in the current Hansen model; represented as a named character vector of regime assignments (lower-case letters), with names indicating branches containing shifts
Phylogenetic tree in ouchtree
format
Data frame with rownames corresponding to otree@labels
The Hansen model to attempt regime collapses on; typically the final element of a surfaceForward
analysis
Change in AICc needed to accept a candidate model as a sufficient improvement over the previous iteration of SURFACE. Defaults to zero, meaning any improvement in the AICc will be accepted; more stringent thresholds are specified using *negative* values of aic_threshold
Maximum number of steps in the backward phase to carry out (assuming the model improvement continues to exceed aic_threshold
)
A logical indicating whether to save the current iteration of the model at each step (overwriting if necessary) to a file filename
(defaults to FALSE
)
Name of the file to save progress to at each step, if savesteps=TRUE
A logical indicating whether to print progress (defaults to FALSE
)
A logical indicating whether to only allow one pair of regimes to be collapsed at each iteration; if FALSE
, igraph
functions are used to identify pairs of regimes that can be collapsed to improve the model without any inconsistencies (defaults to FALSE
)
A logical indicating whether to plot AICc values of candidate models at each step (defaults to FALSE
)
A logical indicating whether to skip over any candidate model that produces an error message (this is rare, but can cause an entire analysis to abort; defaults to FALSE
)
A logical indicating whether to sample from among the best models at each step (those within sample_threshold
of the best AICc), rather than always selecting the best candidate model (defaults to FALSE
; both sample_shifts
and only_best
must be set to TRUE
to use this option during the backward phase
Number of AICc units within which to sample among candidate models that are close to as good as the best model at each step (defaults to 2, but only used if sample_shifts=TRUE
and only_best=TRUE
)
Shifts present in the previous iteration of the Hansen model
AICc value for the Hansen model from the previous iteration
Previous fitted Hansen model
Travis Ingram
Can be time-consuming, as the number of likelihood searches at a step is k(k-1)/2
, where k
is the number of regimes in the model.
Butler, M.A. & King, A.A. (2004) Phylogenetic comparative analysis: a modeling approach for adaptive evolution. American Naturalist 164: 683-695.
Ingram, T. & Mahler, D.L. (2013) SURFACE: detecting convergent evolution from comparative data by fitting Ornstein-Uhlenbeck models with stepwise AIC. Methods in Ecology and Evolution 4: 416-425.
Mahler, D.L., Ingram, T., Revell, L.J. & Losos, J.B. (2013) Exceptional convergence on the macroevolutionary landscape in island lizard radiations. Science 341: 292-295.
surfaceForward
, surfaceSimulate
, surfaceTreePlot
, surfaceSummary
if (FALSE) {
data(surfaceDemo)
tree<-surfaceDemo$tree
dat<-surfaceDemo$sim$dat
olist<-convertTreeData(tree,dat)
otree<-olist[[1]]; odata<-olist[[2]]
fwd<-surfaceForward(otree, odata, aic_threshold = 0, exclude = 0, verbose = FALSE, plotaic = FALSE)
k<-length(fwd)
bwd<-surfaceBackward(otree, odata, starting_model = fwd[[k]], aic_threshold = 0)
}
Run the code above in your browser using DataLab