This function filters and processes posterior samples from RJMCMC outputs based on a specified mixture size. It generates clean posterior summaries and the trajectory of the posterior distribution.

get_clean_posterior(outputs, mix_size, n_chain)

Arguments

outputs

List. The RJMCMC outputs, containing jump matrices for all chains.

mix_size

Integer. The desired mixture size (number of components) to filter the posterior samples.

n_chain

Integer. The number of chains in the RJMCMC output.

Value

A list containing two components:

  • summary_post: A data frame summarizing the posterior samples with columns: p (mixing proportions), mu (means), sigma (standard deviations), order (ranked means), sample (sample index), and chain (chain index).

  • post_traj_sum: A data frame summarizing the posterior trajectory, including mean and uncertainty intervals (mean_qi).

Details

The function filters jump matrices for samples matching the specified mix_size (number of components). It constructs a clean summary of posterior parameters and calculates the posterior trajectory using a sequence of x-values (e.g., for visualization of the mixture distribution).

Steps:

  1. Filter Samples:

    • Selects jump matrices with mix_size columns.

    • Extracts parameters: mixing proportions (p), means (mu), and standard deviations (sigma).

  2. Generate Posterior Trajectory:

    • Uses the filtered posterior parameters to calculate the PDF of the mixture distribution over a range of x-values.

    • Aggregates the trajectories across samples using mean_qi() to summarize uncertainty.