Extract the inverse metric (mass matrix) for each MCMC chain.
inv_metric(matrix = TRUE)
(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.
A list of length equal to the number of MCMC chains. See the matrix
argument for details.
# \dontrun{
fit <- cmdstanr_example("logistic")
fit$inv_metric()
#> $`1`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.0399675 0.0000000 0.000000 0.0000000
#> [2,] 0.0000000 0.0581864 0.000000 0.0000000
#> [3,] 0.0000000 0.0000000 0.045564 0.0000000
#> [4,] 0.0000000 0.0000000 0.000000 0.0657117
#>
#> $`2`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.042812 0.0000000 0.0000000 0.0000000
#> [2,] 0.000000 0.0677379 0.0000000 0.0000000
#> [3,] 0.000000 0.0000000 0.0505126 0.0000000
#> [4,] 0.000000 0.0000000 0.0000000 0.0732512
#>
#> $`3`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.0421817 0.000000 0.0000000 0.0000000
#> [2,] 0.0000000 0.062998 0.0000000 0.0000000
#> [3,] 0.0000000 0.000000 0.0483093 0.0000000
#> [4,] 0.0000000 0.000000 0.0000000 0.0806989
#>
#> $`4`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.0458222 0.0000000 0.0000000 0.0000000
#> [2,] 0.0000000 0.0724218 0.0000000 0.0000000
#> [3,] 0.0000000 0.0000000 0.0524932 0.0000000
#> [4,] 0.0000000 0.0000000 0.0000000 0.0726335
#>
fit$inv_metric(matrix=FALSE)
#> $`1`
#> [1] 0.0399675 0.0581864 0.0455640 0.0657117
#>
#> $`2`
#> [1] 0.0428120 0.0677379 0.0505126 0.0732512
#>
#> $`3`
#> [1] 0.0421817 0.0629980 0.0483093 0.0806989
#>
#> $`4`
#> [1] 0.0458222 0.0724218 0.0524932 0.0726335
#>
fit <- cmdstanr_example("logistic", metric = "dense_e")
fit$inv_metric()
#> $`1`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.048423300 0.001823680 0.00659113 -0.000666867
#> [2,] 0.001823680 0.055877400 -0.00378891 0.000328776
#> [3,] 0.006591130 -0.003788910 0.04607360 -0.010493400
#> [4,] -0.000666867 0.000328776 -0.01049340 0.061314400
#>
#> $`2`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.055615500 -0.004688890 0.000366103 0.00657168
#> [2,] -0.004688890 0.070634600 0.000161933 -0.00900785
#> [3,] 0.000366103 0.000161933 0.043863800 -0.01242910
#> [4,] 0.006571680 -0.009007850 -0.012429100 0.06169190
#>
#> $`3`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.046092000 0.000277152 -0.000196182 0.00653545
#> [2,] 0.000277152 0.052935700 -0.001316380 -0.00135849
#> [3,] -0.000196182 -0.001316380 0.052723400 -0.00738233
#> [4,] 0.006535450 -0.001358490 -0.007382330 0.06829300
#>
#> $`4`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.05362400 -0.00182030 0.00998512 -0.00383164
#> [2,] -0.00182030 0.06051710 0.00414984 -0.01575160
#> [3,] 0.00998512 0.00414984 0.04282750 -0.01094520
#> [4,] -0.00383164 -0.01575160 -0.01094520 0.07697140
#>
# }