Extract the inverse metric (mass matrix) for each MCMC chain.

inv_metric(matrix = TRUE)

Arguments

matrix

(logical) If a diagonal metric was used, setting matrix = FALSE returns a list containing just the diagonals of the matrices instead of the full matrices. Setting matrix = FALSE has no effect for dense metrics.

Value

A list of length equal to the number of MCMC chains. See the matrix argument for details.

See also

Examples

# \dontrun{ fit <- cmdstanr_example("logistic")
#> Model executable is up to date!
fit$inv_metric()
#> $`1` #> [,1] [,2] [,3] [,4] #> [1,] 0.0544152 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0663648 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0511679 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0673017 #> #> $`2` #> [,1] [,2] [,3] [,4] #> [1,] 0.0482525 0.000000 0.000000 0.0000000 #> [2,] 0.0000000 0.057435 0.000000 0.0000000 #> [3,] 0.0000000 0.000000 0.050702 0.0000000 #> [4,] 0.0000000 0.000000 0.000000 0.0732792 #> #> $`3` #> [,1] [,2] [,3] [,4] #> [1,] 0.0397963 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0683896 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0544954 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0679505 #> #> $`4` #> [,1] [,2] [,3] [,4] #> [1,] 0.0599913 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0619537 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0573713 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0676692 #>
fit$inv_metric(matrix=FALSE)
#> $`1` #> [1] 0.0544152 0.0663648 0.0511679 0.0673017 #> #> $`2` #> [1] 0.0482525 0.0574350 0.0507020 0.0732792 #> #> $`3` #> [1] 0.0397963 0.0683896 0.0544954 0.0679505 #> #> $`4` #> [1] 0.0599913 0.0619537 0.0573713 0.0676692 #>
fit <- cmdstanr_example("logistic", metric = "dense_e")
#> Model executable is up to date!
fit$inv_metric()
#> $`1` #> [,1] [,2] [,3] [,4] #> [1,] 0.04623570 -0.00139207 -0.00260599 0.00540813 #> [2,] -0.00139207 0.05471960 0.00125107 -0.00394774 #> [3,] -0.00260599 0.00125107 0.04719890 -0.01083170 #> [4,] 0.00540813 -0.00394774 -0.01083170 0.07156050 #> #> $`2` #> [,1] [,2] [,3] [,4] #> [1,] 0.048543100 -0.00344888 0.000311215 0.00118579 #> [2,] -0.003448880 0.06322130 -0.005276520 -0.00610592 #> [3,] 0.000311215 -0.00527652 0.049614400 -0.01370430 #> [4,] 0.001185790 -0.00610592 -0.013704300 0.07833850 #> #> $`3` #> [,1] [,2] [,3] [,4] #> [1,] 0.05107010 -0.00250574 0.00478996 0.00293886 #> [2,] -0.00250574 0.05807220 -0.00689427 -0.01342300 #> [3,] 0.00478996 -0.00689427 0.04909890 -0.01018650 #> [4,] 0.00293886 -0.01342300 -0.01018650 0.08329210 #> #> $`4` #> [,1] [,2] [,3] [,4] #> [1,] 0.04414410 0.00144665 -0.00163528 0.00338170 #> [2,] 0.00144665 0.06106620 -0.00257072 -0.00794529 #> [3,] -0.00163528 -0.00257072 0.04137400 -0.00597881 #> [4,] 0.00338170 -0.00794529 -0.00597881 0.07713860 #>
# }