Evaluates whether the cumulative mean of a tracked error metric in simulation outputs has stabilized, indicating convergence. This function helps determine if repeated simulations or resampling have produced stable estimates, which is critical for reliable inference in animal movement projects.
Use this function after running md_run() or
md_replicate() to check the reliability of outputs
before further interpretation or reporting.
md_check(
obj,
m = NULL,
tol = 0.05,
n_converge = 10,
plot = TRUE,
pal = c("#007d80", "#A12C3B")
)An object of class "movedesign_check" with the
following elements:
has_convergedLogical scalar indicating whether convergence was achieved.
recent_deltasNumeric vector of absolute changes in cumulative mean
over the last n_converge steps.
max_deltaMaximum absolute change among the last steps.
toleranceNumeric, the input tolerance tol.
n_convergeInteger, the input n_converge.
Character. Name of the variable checked.
Numeric vector. The last cumulative means checked.
A movedesign or related object returned by
md_run() or md_replicate().
Numeric (optional). If provided, restricts the convergence
check to results for a specific population sample size (m).
Defaults to NULL, which checks up to the maximum population
sample size.
Numeric. The tolerance threshold for absolute change in
the cumulative mean to declare convergence. Defaults to
0.05.
Integer. Number of consecutive steps within
tolerance required to confirm convergence. Defaults to 10.
Logical. If TRUE (default), generates a plot of
stepwise changes in the cumulative mean, highlighting when
convergence is achieved.
Character vector of color(s) of the plot, such as
c("#007d80", "#A12C3B")) (default).
The cumulative mean of error is calculated, and the absolute changes
over the last n_converge steps are inspected. If all are
below the specified tolerance, convergence is declared.
If plot = TRUE, a plot is shown of absolute stepwise change
in the cumulative mean, with a shaded region indicating the
convergence threshold, aiding visual assessment.
md_run(),
md_replicate()
if(interactive()) {
# After running a simulation or resampling:
md_check(output, tol = 0.05, n_converge = 10)
}
Run the code above in your browser using DataLab