Hi,
I’m essentially building a wrapper around pymc for building more complex models (somewhat similar to bambi), and am trying to use pathfinder for sampling.
Sampling itself seems to work in most cases, but I run into two issues:
a) pmx.fit does not put ‘observed_data’ into the idata, and my pipeline relies on that being present
b) pmx.fit does not take initvals as an argument so all models that need manual initvals (like those making use of ordered transform) fail.
So I’m wondering if I can work around these two issues.
For instance, can I add the observed_data manually if I have access to the model object?
Also - is there a way to just inject initvals into the model after the fact (akin to do or observe commands)?
So, observed_data solution turned out to be easy enough as I could borrow from the code used for nutpie in pymc.sampling.mcmc
from arviz import dict_to_dataset
from pymc.backends.arviz import find_observations, coords_and_dims_for_inferencedata
coords, dims = coords_and_dims_for_inferencedata(model)
observed_data = dict_to_dataset(
find_observations(model),
library=pm,
coords=coords,
dims=dims,
default_dims=[]
)
idata.add_groups({"observed_data": observed_data},coords=coords,dims=dims)
And it seems initvals can be relatively easily loaded into the model with:
for rv_name, ivals in initvals:
fmodel.set_initval(model.named_vars[rv_name],ivals)
Next question I have:
Any objections to adding those things to pymc_extras.fit so it would behave more compatibly to pm.sample? Because if not, I’d happily do a PR with that
1 Like
Yeah that would be great.
Will put it on my todo list then 
1 Like