Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe method keyword arguments #106

Open
joshualeond opened this issue May 22, 2019 · 1 comment
Open

Describe method keyword arguments #106

joshualeond opened this issue May 22, 2019 · 1 comment
Labels
enhancement New feature or request

Comments

@joshualeond
Copy link

I had asked in the Turing slack channel if there were a simple way to adjust the precision of the describe methods output. I was told there isn't and to open a feature request. Currently we see something like this with the describe method:

julia> describe(chn)
2-element Array{ChainDataFrame,1}

Summary Statistics

│ Row │ parameters │ mean    │ std      │ naive_se  │ mcse      │ ess     │ r_hat    │
│     │ Symbol     │ Float64 │ Float64  │ Float64   │ Float64   │ Any     │ Any      │
├─────┼────────────┼─────────┼──────────┼───────────┼───────────┼─────────┼──────────┤
│ 1   │ m          │ 1.04149 │ 0.794192 │ 0.0251146 │ 0.0927405 │ 57.9072 │ 1.00897  │
│ 2   │ s          │ 1.95544 │ 1.46153  │ 0.0462175 │ 0.115658  │ 115.065 │ 0.999489 │

The keyword argument would adjust the level of precision on this output. Something like this, with an additional digits argument:

julia> describe(chn, digits = 2)
2-element Array{ChainDataFrame,1}

Summary Statistics

│ Row │ parameters │ mean    │ std      │ naive_se  │ mcse      │ ess     │ r_hat    │
│     │ Symbol     │ Float64 │ Float64  │ Float64   │ Float64   │ Any     │ Any      │
├─────┼────────────┼─────────┼──────────┼───────────┼───────────┼─────────┼──────────┤
│ 1   │ m          │ 1.04    │ 0.79     │ 0.03      │ 0.09      │ 57.91   │ 1.01     │
│ 2   │ s          │ 1.96    │ 1.46     │ 0.05      │ 0.12      │ 115.06  │ 1.0      │

While we're discussing the output of the describe method. Maybe it would be advantageous to include a depth argument as well. An example of this is in the rethinking package in R. Here's a description of the argument in the rethinking::precis function:

depth If 1, suppresses vectors and matrices of parameters. If 2, displays all parameters

A quick example of the differences with depth:

precis(m10.9, depth = 1)
#> 6 vector or matrix parameters omitted in display. Use depth=2 to show them.
#>     Mean StdDev lower 0.89 upper 0.89 n_eff Rhat
#> bm -0.09   0.09      -0.23       0.05   350    1

precis(m10.9, depth = 2)
#>       Mean StdDev lower 0.89 upper 0.89 n_eff Rhat
#> a[1]  0.68   0.11       0.52       0.86   482    1
#> a[2]  0.63   0.12       0.44       0.82   480    1
#> a[3] -0.58   0.08      -0.71      -0.46  1066    1
#> a[4] -0.62   0.09      -0.76      -0.47   680    1
#> a[5] -1.06   0.10      -1.22      -0.90   934    1
#> a[6] -2.65   0.16      -2.89      -2.40  1104    1
#> bm   -0.09   0.09      -0.23       0.05   350    1
@goedman
Copy link
Collaborator

goedman commented May 22, 2019

Hi Josh,

Thanks for the feedback!

Having a digits=... argument is a good suggestion.

On your 2nd question, the approach taken in MCMCChains is slightly different in that you can adjust the chain's name_map, e.g. in your example:

    chns = set_section(chn, Dict(
      :pooled => ["a[$i]" for i in 1:6]
    )

It means an extra step, but given a slightly more elaborate example:

    chns = set_section(chn, Dict(
      :parameters => ["mu", "tau"],
      :thetas => ["theta.$i" for i in 1:8],
      :etas => ["eta.$i" for i in 1:8],
      :internals => ["lp__", "accept_stat__", "stepsize__", "treedepth__", "n_leapfrog__",
        "divergent__", "energy__"]
      )
    )

for models with lots and lots of parameters it allows finer control.

@yebai yebai added the enhancement New feature or request label Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants