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

Usage

$inverse_metric(matrix = TRUE)

Arguments

  • matrix: (logical) Should a list of matrices be returned? By default a list of matrices is always returned, even if a diagonal metric was used when fitting the model. If a diagonal metric was used then setting matrix=FALSE will return a list of vectors instead, which uses less memory.

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$inverse_metric()
#> [[1]] #> [,1] [,2] [,3] [,4] #> [1,] 0.0489704 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0565619 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0505927 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0765553 #> #> [[2]] #> [,1] [,2] [,3] [,4] #> [1,] 0.0464694 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0502202 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0505695 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0764519 #> #> [[3]] #> [,1] [,2] [,3] [,4] #> [1,] 0.0508438 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0673253 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0560788 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0788151 #> #> [[4]] #> [,1] [,2] [,3] [,4] #> [1,] 0.0448417 0.0000000 0.0000000 0.0000000 #> [2,] 0.0000000 0.0581256 0.0000000 0.0000000 #> [3,] 0.0000000 0.0000000 0.0553186 0.0000000 #> [4,] 0.0000000 0.0000000 0.0000000 0.0710309 #>
fit$inverse_metric(matrix=FALSE)
#> [[1]] #> [1] 0.0489704 0.0565619 0.0505927 0.0765553 #> #> [[2]] #> [1] 0.0464694 0.0502202 0.0505695 0.0764519 #> #> [[3]] #> [1] 0.0508438 0.0673253 0.0560788 0.0788151 #> #> [[4]] #> [1] 0.0448417 0.0581256 0.0553186 0.0710309 #>
fit <- cmdstanr_example("logistic", metric = "dense_e")
#> Model executable is up to date!
fit$inverse_metric()
#> [[1]] #> [,1] [,2] [,3] [,4] #> [1,] 0.04622490 -0.00200878 -0.00532990 0.00912209 #> [2,] -0.00200878 0.05868030 -0.00111311 -0.00606391 #> [3,] -0.00532990 -0.00111311 0.04705130 -0.01343920 #> [4,] 0.00912209 -0.00606391 -0.01343920 0.06636260 #> #> [[2]] #> [,1] [,2] [,3] [,4] #> [1,] 0.048247300 0.000662222 0.00412900 0.00605341 #> [2,] 0.000662222 0.066143300 -0.01073320 0.00407476 #> [3,] 0.004129000 -0.010733200 0.05326770 -0.00932996 #> [4,] 0.006053410 0.004074760 -0.00932996 0.07355610 #> #> [[3]] #> [,1] [,2] [,3] [,4] #> [1,] 0.04912670 -0.00264697 0.00630654 -0.00385016 #> [2,] -0.00264697 0.06148540 -0.01042830 -0.01020800 #> [3,] 0.00630654 -0.01042830 0.06169950 -0.01587110 #> [4,] -0.00385016 -0.01020800 -0.01587110 0.07391140 #> #> [[4]] #> [,1] [,2] [,3] [,4] #> [1,] 0.040504300 0.000998829 -0.000784530 0.00366177 #> [2,] 0.000998829 0.051848800 0.000382584 -0.00376364 #> [3,] -0.000784530 0.000382584 0.044784800 -0.01134560 #> [4,] 0.003661770 -0.003763640 -0.011345600 0.06060850 #>
# }