Skip to contents

[Experimental] Analyses convergence in Monte Carlo simulations by computing standardised and raw differences between consecutive iterations to evaluate stability and convergence of statistical measures.

Usage

mcmodule_converg(
  mcmodule,
  from_quantile = 0.95,
  to_quantile = 1,
  conv_threshold = NULL,
  print_summary = TRUE,
  progress = FALSE
)

Arguments

mcmodule

(mcmodule object). Module containing simulation results.

from_quantile

(numeric). Lower bound quantile for analysis. Default: 0.95.

to_quantile

(numeric). Upper bound quantile for analysis. Default: 1.

conv_threshold

(numeric, optional). Custom convergence threshold for standardised differences. Default: NULL.

print_summary

(logical). If TRUE, print convergence analysis summary. Default: TRUE.

progress

(logical). If TRUE, print progress information. Default: FALSE.

Value

A data frame with convergence statistics. Each row represents one node. Key columns:

  • expression: Expression identifier.

  • variate: Variate (data row) identifier.

  • node: Node name.

  • max_dif_scaled: Maximum standardised difference.

  • max_dif: Maximum raw difference.

  • conv_threshold: Convergence at custom threshold, if provided.

  • conv_01, conv_025, conv_05: Convergence at 1%, 2.5%, 5% thresholds.

Details

The function performs the following:

  • Calculates convergence statistics for specified quantile range

  • Generates diagnostic plots for standardized and raw differences

  • Provides detailed convergence summary including:

    • Total nodes analyzed

    • Number and percentage of nodes converged at different thresholds

    • Maximum/minimum deviations

    • List of non-converged nodes (if any)

Examples

if (FALSE) { # \dontrun{
results <- mcmodule_converg(mc_results)
results <- mcmodule_converg(mc_results, from_quantile = 0.90, conv_threshold = 0.01)
} # }