Compare the posteriori probabilities of 2 permutations
Source:R/log_posteriori_of_gips.R
compare_posteriories_of_perms.RdCheck which permutation is more likely and how much more likely.
Usage
compare_posteriories_of_perms(
perm1,
perm2 = "()",
S = NULL,
number_of_observations = NULL,
delta = 3,
D_matrix = NULL,
was_mean_estimated = TRUE,
print_output = TRUE,
digits = 3
)
compare_log_posteriories_of_perms(
perm1,
perm2 = "()",
S = NULL,
number_of_observations = NULL,
delta = 3,
D_matrix = NULL,
was_mean_estimated = TRUE,
print_output = TRUE,
digits = 3
)Arguments
- perm1, perm2
Permutations to compare. How many times
perm1is more likely thanperm2? Those can be provided as thegipsobjects, thegips_permobjects, or anything that can be used as thexparameter in thegips_perm()function. They do not have to be of the same class.- S, number_of_observations, delta, D_matrix, was_mean_estimated
The same parameters as in the
gips()function. If at least one ofperm1orperm2is agipsobject, they are overwritten with those from thegipsobject.- print_output
A boolean. When
TRUE(default), the computed value will be printed with additional text and returned invisibly. WhenFALSE, the computed value will be returned visibly.- digits
Integer. Only used when
print_output = TRUE. The number of digits after the comma to print. It can be negative, can be+Inf. It is passed tobase::round().
Value
The function compare_posteriories_of_perms() returns
the value of how many times the perm1 is more likely than perm2.
The function compare_log_posteriories_of_perms() returns
the logarithm of how many times the perm1 is more likely than perm2.
Functions
compare_log_posteriories_of_perms(): More stable, logarithmic version ofcompare_posteriories_of_perms(). The natural logarithm is used.
See also
print.gips()- The function that prints the posterior of the optimizedgipsobject compared to the starting permutation.summary.gips()- The function that calculates the posterior of the optimizedgipsobject compared to the starting permutation.find_MAP()- The function that finds the permutation that maximizeslog_posteriori_of_gips().log_posteriori_of_gips()- The function thiscompare_posteriories_of_perms()calls underneath.
Examples
require("MASS") # for mvrnorm()
#> Loading required package: MASS
perm_size <- 6
mu <- runif(6, -10, 10) # Assume we don't know the mean
sigma_matrix <- matrix(
data = c(
1.05, 0.8, 0.6, 0.4, 0.6, 0.8,
0.8, 1.05, 0.8, 0.6, 0.4, 0.6,
0.6, 0.8, 1.05, 0.8, 0.6, 0.4,
0.4, 0.6, 0.8, 1.05, 0.8, 0.6,
0.6, 0.4, 0.6, 0.8, 1.05, 0.8,
0.8, 0.6, 0.4, 0.6, 0.8, 1.05
),
nrow = perm_size, byrow = TRUE
) # sigma_matrix is a matrix invariant under permutation (1,2,3,4,5,6)
number_of_observations <- 13
Z <- MASS::mvrnorm(number_of_observations, mu = mu, Sigma = sigma_matrix)
S <- cov(Z) # Assume we have to estimate the mean
g <- gips(S, number_of_observations)
g_map <- find_MAP(g, max_iter = 10, show_progress_bar = FALSE, optimizer = "Metropolis_Hastings")
compare_posteriories_of_perms(g_map, g, print_output = TRUE)
#> The permutation () is 1 times more likely than the () permutation.
exp(compare_log_posteriories_of_perms(g_map, g, print_output = FALSE))
#> [1] 1