sibylhe/mmm_stan

Struggled with -> RuntimeError: Initialization failed

CGDINHA opened this issue · 2 comments

Hi Sibyl,

First, let me thank you in advance for both your post (which is pretty good) and for your help!

I wanted to use your approach in an example but I can not fix the "RuntimeError: Initialization failed" when I do the ".sampling" and I really do not know what else to do. Could you give me any little advice?

Here it goes the data I provide to "sampling", and the error messagge:

Model data:

  • N: 53
  • max_lag: 2 (my example is with monthly data)
  • num_media: 8
  • X_media: As it is quite big and I guess the numbers do say nothing to you, I give you its shape (54,8)
  • mu_mdip: As I guess the numbers do say nothing to you, I give you its shape (8,)
  • num_ctrl: 1
  • X_ctrl: As I guess the numbers do say nothing to you, I give you its shape (53,1)
  • y: As I guess the numbers do say nothing to you, I give you its shape (53,)

Error message:

"RuntimeError Traceback (most recent call last)
in
----> 1 fit2 = sm2.sampling(data=model_data2, iter=2000, chains=4, verbose=True, n_jobs=1)

C:\ProgramData\Anaconda3\lib\site-packages\pystan\model.py in sampling(self, data, pars, chains, iter, warmup, thin, seed, init, sample_file, diagnostic_file, verbose, algorithm, control, n_jobs, **kwargs)
811 call_sampler_args = izip(itertools.repeat(data), args_list, itertools.repeat(pars))
812 call_sampler_star = self.module._call_sampler_star
--> 813 ret_and_samples = _map_parallel(call_sampler_star, call_sampler_args, n_jobs)
814 samples = [smpl for _, smpl in ret_and_samples]
815

C:\ProgramData\Anaconda3\lib\site-packages\pystan\model.py in _map_parallel(function, args, n_jobs)
88 pool.join()
89 else:
---> 90 map_result = list(map(function, args))
91 return map_result
92

stanfit4anon_model_c6677ffefdee0513f144508ee1783d0c_6434600101167848.pyx in stanfit4anon_model_c6677ffefdee0513f144508ee1783d0c_6434600101167848._call_sampler_star()

stanfit4anon_model_c6677ffefdee0513f144508ee1783d0c_6434600101167848.pyx in stanfit4anon_model_c6677ffefdee0513f144508ee1783d0c_6434600101167848._call_sampler()

RuntimeError: Initialization failed."

I hope you might help me,
Once again, thank you so much.
Best regards.

Hello!

One of my readers had "RuntimeError: Initialization failed" whiling running my code with her data, and here's her solution:
"I realized the issue is with Y variable. I made sure there were no missing data and all positive in Y. But there are good amount of Y which are 0. upon imputing them with mean, I could build the model."

I think errors at the sampling stage are highly likely to be related to the input data. You may want to check your data quality or if the data meet the constraints specified in the model code "data" section (e.g., specified x<lower=0>, but the actual data 'x' has negative values).

Hi Sibyl,

Thanks for you quick response, I could fix it, I hope I will not have to disturb you any more in the future.

Once again, thank you so much.
Best regards.