Orders the posterior weight matrix from fash_eb_est based on a specified method of the posterior PSD.

fash_post_ordering(eb_output, ordering = "mean")

Arguments

eb_output

A list output from fash_eb_est, containing:

posterior_weight

A numeric matrix of posterior weights (datasets as rows, PSD as columns).

prior_weight

A data frame of prior weights (not used in this function).

ordering

A character string specifying the method for reordering datasets. Options are:

"mean"

Reorder by the mean of the posterior PSD (default).

"median"

Reorder by the median of the posterior PSD.

"lfdr"

Reorder by the local false discovery rate (posterior probability of PSD = 0).

Value

A list containing:

ordered_matrix

The reordered posterior weight matrix.

ordered_indices

The indices used to reorder the matrix.

ordered_metrics

The metrics used for ordering, aligned with the reordered matrix.

Examples

# Example usage
set.seed(1)
grid <- seq(0.1, 2, length.out = 5)
L_matrix <- matrix(rnorm(20), nrow = 4, ncol = 5)
eb_output <- fash_eb_est(L_matrix, penalty = 2, grid = grid)
result <- fash_post_ordering(eb_output, ordering = "mean")
print(result$ordered_matrix)
#>            0.1      1.05          2
#> [1,] 0.8206464 0.1674651 0.01188852
#> [2,] 0.6657481 0.2781053 0.05614653
#> [3,] 0.2994584 0.6788028 0.02173882
#> [4,] 0.1200311 0.8551535 0.02481532
print(result$ordered_indices)
#> [1] 4 2 1 3
print(result$ordered_metrics)
#> [1] 0.2816800 0.4708785 0.7861664 0.9595450