Open stanbiryukov opened 4 years ago
Thanks for reporting this. I guess you're correct, and that we maybe we need to think more about initialization strategies at some point. If possible, could you share a simple example that reproduces the problem, so we might check this isn't some other bug. Thanks.
I realized part of the problem here is that brms automatically centers data whereas here we need to either specify more accurate priors or standardize the data before fitting with numpyro. Nevertheless, the pyro backends do work with non-centered columns in the example below. Agreed that it will be good to think through some initialization strategies.
import brmp
from brmp import brm
from brmp.numpyro_backend import backend as numpyro
from brmp.pyro_backend import backend as pyro
import pandas as pd
df = pd.read_csv('https://stats.idre.ucla.edu/stat/data/hdp.csv')
df = df.apply(lambda x: pd.factorize(x)[0] if np.issubdtype(x.dtype, np.number) is False else x) # factorize some columns
df['remission'] = df['remission'].astype(np.int)
df['DID'] = df['DID'].astype('category')
model = brm('remission ~ IL6 + CRP + CancerStage + LengthofStay + Experience + FamilyHx + SmokingHx + Sex + CancerStage + LengthofStay + WBC + BMI + (1 | DID)', df = df, family = brmp.family.Binomial(num_trials=1))
fit = model.fit(backend=numpyro, seed=8877, iter=1000, warmup=500) # fails
fit = model.fit(backend=pyro, seed=8877, iter=1000, warmup=500) # works
fit = model.fit(algo='svi', seed=8877, iter=10000, num_samples=1000) # works
Hi there, great initial work wrapping numpyro and pyro into a more user friendly interface! I'm having an issue with a few simple models where the numpyro backend gives me the following error:
Cannot find valid initial parameters. Please check your model again.
It seems to occur when there are many predictors in the formula.Pyro sampling and SVI both work fine for this model with the default Cauchy beta priors. Any thoughts on better initializing numpyro NUTS with SVI or perhaps using maximum a posteriori estimates? It's tough to figure out what exactly is causing MCMC to immediately fail but I'm assuming it's the initial starting values. Full traceback: