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") fit$inv_metric()
#> $`1` #> [,1] [,2] [,3] [,4] #> [1,] 0.0481393 0.00000 0.0000000 0.0000000 #> [2,] 0.0000000 0.05628 0.0000000 0.0000000 #> [3,] 0.0000000 0.00000 0.0407205 0.0000000 #> [4,] 0.0000000 0.00000 0.0000000 0.0702359 #> #> $`2` #> [,1] [,2] [,3] [,4] #> [1,] 0.0462024 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0708086 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0509179 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0663432 #> #> $`3` #> [,1] [,2] [,3] [,4] #> [1,] 0.0401421 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0599614 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0409305 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0636495 #> #> $`4` #> [,1] [,2] [,3] [,4] #> [1,] 0.048948 0.0000000 0.000000 0.0000000 #> [2,] 0.000000 0.0612541 0.000000 0.0000000 #> [3,] 0.000000 0.0000000 0.053141 0.0000000 #> [4,] 0.000000 0.0000000 0.000000 0.0843771 #>
fit$inv_metric(matrix=FALSE)
#> $`1` #> [1] 0.0481393 0.0562800 0.0407205 0.0702359 #> #> $`2` #> [1] 0.0462024 0.0708086 0.0509179 0.0663432 #> #> $`3` #> [1] 0.0401421 0.0599614 0.0409305 0.0636495 #> #> $`4` #> [1] 0.0489480 0.0612541 0.0531410 0.0843771 #>
fit <- cmdstanr_example("logistic", metric = "dense_e") fit$inv_metric()
#> $`1` #> [,1] [,2] [,3] [,4] #> [1,] 0.04674080 -0.003735660 0.002672980 0.00238423 #> [2,] -0.00373566 0.068142800 -0.000262148 -0.01289230 #> [3,] 0.00267298 -0.000262148 0.046002800 -0.01442680 #> [4,] 0.00238423 -0.012892300 -0.014426800 0.07403270 #> #> $`2` #> [,1] [,2] [,3] [,4] #> [1,] 0.04818520 -0.00541596 0.00262377 0.00791809 #> [2,] -0.00541596 0.06098370 -0.00895976 -0.00360963 #> [3,] 0.00262377 -0.00895976 0.06049940 -0.01483090 #> [4,] 0.00791809 -0.00360963 -0.01483090 0.06889970 #> #> $`3` #> [,1] [,2] [,3] [,4] #> [1,] 0.04188870 -0.003366470 0.002556630 0.00143941 #> [2,] -0.00336647 0.072588600 -0.000749238 -0.01014960 #> [3,] 0.00255663 -0.000749238 0.062633300 -0.01869750 #> [4,] 0.00143941 -0.010149600 -0.018697500 0.06842820 #> #> $`4` #> [,1] [,2] [,3] [,4] #> [1,] 0.050144300 -0.00512010 -0.000121339 0.00550570 #> [2,] -0.005120100 0.05424960 0.005528330 -0.00520478 #> [3,] -0.000121339 0.00552833 0.047886100 -0.01343470 #> [4,] 0.005505700 -0.00520478 -0.013434700 0.07104140 #>
# }