summary
method for gips
class.
Arguments
- object
An object of class
gips
. Usually, a result of afind_MAP()
.- ...
Further arguments passed to or from other methods.
- x
An object of class
summary.gips
to be printed
Value
The function summary.gips()
computes and returns a list of summary
statistics of the given gips
object. Those are:
For unoptimized
gips
object:optimized
-FALSE
.start_permutation
- the permutation thisgips
represents.start_permutation_log_posteriori
- the log of the a posteriori value the start permutation has.times_more_likely_than_id
- how many more likely thestart_permutation
is over the identity permutation,()
. It can be less than 1, meaning the identity permutation is more likely. Remember that this number can big and overflow toInf
or small and underflow to 0.n0
- the minimum number of observations needed for the covariance matrix's maximum likelihood estimator (corresponding to a MAP) to exist. See \(C\sigma\) andn0
section invignette("Theory", package = "gips")
or in its pkgdown page.S_matrix
- the underlying matrix. This matrix will be used in calculations of the posteriori value inlog_posteriori_of_gips()
.number_of_observations
- the number of observations that were observed for theS_matrix
to be calculated. This value will be used in calculations of the posteriori value inlog_posteriori_of_gips()
.was_mean_estimated
- given by the user while creating thegips
object:TRUE
means theS
parameter was the output ofstats::cov()
function;FALSE
means theS
parameter was calculated withS = t(X) %*% X / number_of_observations
.
delta
,D_matrix
- the hyperparameters of the Bayesian method. See the Hyperparameters section ofgips()
documentation.AIC
,BIC
- output ofAIC.gips()
andBIC.gips()
functions.n_parameters
- number of free parameters in the covariance matrix.
For optimized
gips
object:optimized
-TRUE
.found_permutation
- the permutation thisgips
represents. The visited permutation with the biggest a posteriori value.found_permutation_log_posteriori
- the log of the a posteriori value the found permutation has.start_permutation
- the original permutation thisgips
represented before optimization. It is the first visited permutation.start_permutation_log_posteriori
- the log of the a posteriori value the start permutation has.times_more_likely_than_start
- how many more likely thefound_permutation
is over thestart_permutation
. It cannot be a number less than 1. Remember that this number can big and overflow toInf
.n0
- the minimal number of observations needed for the existence of the maximum likelihood estimator (corresponding to a MAP) of the covariance matrix (see \(C\sigma\) andn0
section invignette("Theory", package = "gips")
or in its pkgdown page).S_matrix
- the underlying matrix. This matrix will be used in calculations of the posteriori value inlog_posteriori_of_gips()
.number_of_observations
- the number of observations that were observed for theS_matrix
to be calculated. This value will be used in calculations of the posteriori value inlog_posteriori_of_gips()
.was_mean_estimated
- given by the user while creating thegips
object:TRUE
means theS
parameter was output of thestats::cov()
function;FALSE
means theS
parameter was calculated withS = t(X) %*% X / number_of_observations
.
delta
,D_matrix
- the hyperparameters of the Bayesian method. See the Hyperparameters section ofgips()
documentation.AIC
,BIC
- output ofAIC.gips()
andBIC.gips()
functions.n_parameters
- number of free parameters in the covariance matrix.optimization_algorithm_used
- all used optimization algorithms in order (one could start optimization with "MH", and then do an "HC").did_converge
- a boolean, did the last used algorithm converge.number_of_log_posteriori_calls
- how many times was thelog_posteriori_of_gips()
function called during the optimization.whole_optimization_time
- how long was the optimization process; the sum of all optimization times (when there were multiple).log_posteriori_calls_after_best
- how many times was thelog_posteriori_of_gips()
function called after thefound_permutation
; in other words, how long ago could the optimization be stopped and have the same result. If this value is small, consider runningfind_MAP()
again withoptimizer = "continue"
. Foroptimizer = "BF"
, it isNULL
.acceptance_rate
- only interesting foroptimizer = "MH"
. How often was the algorithm accepting the change of permutation in an iteration.
The function print.summary.gips()
returns an invisible NULL
.
Methods (by generic)
print(summary.gips)
: Printing method for classsummary.gips
. Prints every interesting information in a form pleasant for humans.
See also
find_MAP()
- Usually, thesummary.gips()
is called on the output offind_MAP()
.log_posteriori_of_gips()
- Calculate the likelihood of a permutation.AIC.gips()
,BIC.gips()
- Calculate Akaike's or Bayesian Information Criterionproject_matrix()
- Project the known matrix on the found permutations space.
Examples
require("MASS") # for mvrnorm()
perm_size <- 6
mu <- runif(6, -10, 10) # Assume we don't know the mean
sigma_matrix <- matrix(
data = c(
1.0, 0.8, 0.6, 0.4, 0.6, 0.8,
0.8, 1.0, 0.8, 0.6, 0.4, 0.6,
0.6, 0.8, 1.0, 0.8, 0.6, 0.4,
0.4, 0.6, 0.8, 1.0, 0.8, 0.6,
0.6, 0.4, 0.6, 0.8, 1.0, 0.8,
0.8, 0.6, 0.4, 0.6, 0.8, 1.0
),
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")
unclass(summary(g_map))
#> $optimized
#> [1] TRUE
#>
#> $found_permutation
#> [1] ()
#>
#> $found_permutation_log_posteriori
#> [1] -11.13438
#>
#> $start_permutation
#> [1] ()
#>
#> $start_permutation_log_posteriori
#> [1] -11.13438
#>
#> $times_more_likely_than_start
#> [1] 1
#>
#> $log_times_more_likely_than_start
#> [1] 0
#>
#> $n0
#> [1] 7
#>
#> $S_matrix
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 0.7760145 0.3082413 0.2244657 0.0691927 0.5369659 0.6207415
#> [2,] 0.3082413 0.3607247 0.3706926 0.3860654 0.3335820 0.3236141
#> [3,] 0.2244657 0.3706926 0.8115378 1.1206930 0.9744661 0.5336209
#> [4,] 0.0691927 0.3860654 1.1206930 1.8751686 1.5582959 0.8236683
#> [5,] 0.5369659 0.3335820 0.9744661 1.5582959 1.7616798 1.1207957
#> [6,] 0.6207415 0.3236141 0.5336209 0.8236683 1.1207957 0.9107889
#>
#> $number_of_observations
#> [1] 13
#>
#> $was_mean_estimated
#> [1] TRUE
#>
#> $delta
#> [1] 3
#>
#> $D_matrix
#> [,1] [,2] [,3] [,4] [,5] [,6]
#> [1,] 1.082652 0.000000 0.000000 0.000000 0.000000 0.000000
#> [2,] 0.000000 1.082652 0.000000 0.000000 0.000000 0.000000
#> [3,] 0.000000 0.000000 1.082652 0.000000 0.000000 0.000000
#> [4,] 0.000000 0.000000 0.000000 1.082652 0.000000 0.000000
#> [5,] 0.000000 0.000000 0.000000 0.000000 1.082652 0.000000
#> [6,] 0.000000 0.000000 0.000000 0.000000 0.000000 1.082652
#>
#> $n_parameters
#> [1] 21
#>
#> $AIC
#> [1] -638.8328
#>
#> $BIC
#> [1] -626.9688
#>
#> $optimization_algorithm_used
#> [1] "Metropolis_Hastings"
#>
#> $did_converge
#> NULL
#>
#> $number_of_log_posteriori_calls
#> [1] 10
#>
#> $whole_optimization_time
#> Time difference of 0.01913476 secs
#>
#> $log_posteriori_calls_after_best
#> [1] 9
#>
#> $acceptance_rate
#> [1] 0
#>
g_map2 <- find_MAP(g, max_iter = 10, show_progress_bar = FALSE, optimizer = "hill_climbing")
summary(g_map2)
#> The optimized `gips` object.
#>
#> Permutation:
#> ()
#>
#> Log_posteriori:
#> -11.13438
#>
#> Times more likely than starting permutation:
#> 1
#>
#> The number of observations:
#> 13
#>
#> The mean in the `S` matrix was estimated.
#> Therefore, one degree of freedom was lost.
#> There are 12 degrees of freedom left.
#>
#> n0:
#> 7
#>
#> The number of observations is bigger than n0 for this permutation,
#> so the gips model based on the found permutation does exist.
#>
#> The number of free parameters in the covariance matrix:
#> 21
#>
#> BIC:
#> -626.9688
#>
#> AIC:
#> -638.8328
#>
#> --------------------------------------------------------------------------------
#> Optimization algorithm:
#> hill_climbing did converge
#>
#> The number of log_posteriori calls:
#> 16
#>
#> Optimization time:
#> 0.03004646 secs
#>
#> Log_posteriori calls after the found permutation:
#> 15
# ================================================================================
S <- matrix(c(1, 0.5, 0.5, 2), nrow = 2, byrow = TRUE)
g <- gips(S, 10)
print(summary(g))
#> The unoptimized `gips` object.
#>
#> Permutation:
#> ()
#>
#> Log_posteriori:
#> -15.4837
#>
#> The number of observations:
#> 10
#>
#> The mean in the `S` matrix was estimated.
#> Therefore, one degree of freedom was lost.
#> There are 9 degrees of freedom left.
#>
#> n0:
#> 3
#>
#> The number of observations is bigger than n0 for this permutation,
#> so the gips model based on the found permutation does exist.
#>
#> The number of free parameters in the covariance matrix:
#> 3
#>
#> BIC:
#> 63.02608
#>
#> AIC:
#> 62.11833