stan-dev / rstan

RStan, the R interface to Stan
https://mc-stan.org
1.04k stars 268 forks source link

EBFMI Warnings not shown on serialized stanfits #438

Open aaronjg opened 7 years ago

aaronjg commented 7 years ago

Summary:

When a model has low EBFMI, the warnings are shown after fitting. However, if the model is serialized, and then you try to find a warning via throw_sampler_warnings, EBFMI warnings are not shown.

Description:

The EBFMI warnings are not shown when you call throw_sampler_warnings since is_sfinstance_valid returns false, apparently because the cached binary is no longer loaded.

Reproducible Steps:

Create model with low BFMI, save using saveRDS, then reload and call stan:::throw_sampler_warnings(object)

Current Output:

No warning

Expected Output:

BFMI warnings

RStan Version:

2.16.2

R Version:

3.4.1

Operating System:

Ubuntu

jgabry commented 7 years ago

Looks like throw_sampler_warnings is only computing EBFMI if is_sfinstance_valid(object) is TRUE because it needs to be able to call get_num_upars(object). In the case of loading a saved stanfit object is_sfinstance_valid(object) will be FALSE.

@bgoodri perhaps these warnings should be stored somewhere in the stanfit object so they can be retrieved after saving and reloading? Either that or just the value of get_num_upars(object) could be stored so that it can be obtained after reloading.