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.0435508 0.0000000 0.0000000 0.0000000
#> [2,] 0.0000000 0.0607469 0.0000000 0.0000000
#> [3,] 0.0000000 0.0000000 0.0503494 0.0000000
#> [4,] 0.0000000 0.0000000 0.0000000 0.0672705
#>
#> $`2`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.0532065 0.0000000 0.0000000 0.0000000
#> [2,] 0.0000000 0.0574785 0.0000000 0.0000000
#> [3,] 0.0000000 0.0000000 0.0512835 0.0000000
#> [4,] 0.0000000 0.0000000 0.0000000 0.0641874
#>
#> $`3`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.0502858 0.0000000 0.0000000 0.0000000
#> [2,] 0.0000000 0.0629888 0.0000000 0.0000000
#> [3,] 0.0000000 0.0000000 0.0512933 0.0000000
#> [4,] 0.0000000 0.0000000 0.0000000 0.0661664
#>
#> $`4`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.0453724 0.000000 0.00000 0.0000000
#> [2,] 0.0000000 0.061371 0.00000 0.0000000
#> [3,] 0.0000000 0.000000 0.04017 0.0000000
#> [4,] 0.0000000 0.000000 0.00000 0.0682251
#>
fit$inv_metric(matrix=FALSE)
#> $`1`
#> [1] 0.0435508 0.0607469 0.0503494 0.0672705
#>
#> $`2`
#> [1] 0.0532065 0.0574785 0.0512835 0.0641874
#>
#> $`3`
#> [1] 0.0502858 0.0629888 0.0512933 0.0661664
#>
#> $`4`
#> [1] 0.0453724 0.0613710 0.0401700 0.0682251
#>
fit <- cmdstanr_example("logistic", metric = "dense_e")
fit$inv_metric()
#> $`1`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.04487240 -0.00665557 0.00248036 -0.00336473
#> [2,] -0.00665557 0.05394230 -0.00841737 -0.00815855
#> [3,] 0.00248036 -0.00841737 0.04945140 -0.01015960
#> [4,] -0.00336473 -0.00815855 -0.01015960 0.07289150
#>
#> $`2`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.044891100 -0.00756532 0.00352846 -0.000462971
#> [2,] -0.007565320 0.06064960 -0.00809279 -0.004813840
#> [3,] 0.003528460 -0.00809279 0.05892730 -0.016947100
#> [4,] -0.000462971 -0.00481384 -0.01694710 0.063878300
#>
#> $`3`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.047806100 0.000761202 0.00579535 0.00494546
#> [2,] 0.000761202 0.062074500 -0.00488086 -0.01014510
#> [3,] 0.005795350 -0.004880860 0.05170230 -0.00609765
#> [4,] 0.004945460 -0.010145100 -0.00609765 0.07081120
#>
#> $`4`
#> [,1] [,2] [,3] [,4]
#> [1,] 0.04387350 0.004639300 0.001929550 0.00526756
#> [2,] 0.00463930 0.064076200 -0.000902685 -0.00609741
#> [3,] 0.00192955 -0.000902685 0.045911200 -0.00859578
#> [4,] 0.00526756 -0.006097410 -0.008595780 0.07087270
#>
# }