better / convoys

Implementation of statistical models to analyze time lagged conversions
https://better.engineering/convoys/
MIT License
258 stars 42 forks source link

Numpy type error occurs when setting mcmc==True #132

Open 7cb15 opened 3 years ago

7cb15 commented 3 years ago

I am running into an numpy type error (see below) whenever I set value for the parameters mcmc==True or ci==0.95 in any convoys model. This is consistent across data sources and even occurs when using the example data sets. If I remove these parameters the code runs as expected with no errors. Is this something anyone else has come across? Any help is much appreciated!

TypeError: 'numpy.float64' object cannot be interpreted as an integer
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-160-acdf74229cef> in <module>
----> 1 model_test.fit(X,B,T)

~/opt/anaconda3/lib/python3.8/site-packages/convoys/multi.py in fit(self, G, B, T)
     29         for i, group in enumerate(G):
     30             X[i,group] = 1
---> 31         self.base_model.fit(X, B, T)
     32 
     33     def _get_x(self, group):

~/opt/anaconda3/lib/python3.8/site-packages/convoys/regression.py in fit(self, X, B, T, W)
    267                     ' %d walkers [' % n_walkers,
    268                     progressbar.AdaptiveETA(), ']'])
--> 269             for i, _ in enumerate(sampler.sample(p0, iterations=n_iterations)):
    270                 bar.update(i+1)
    271             result['samples'] = sampler.chain[:, n_burnin:, :] \

~/opt/anaconda3/lib/python3.8/site-packages/emcee/ensemble.py in sample(self, initial_state, log_prob0, rstate0, blobs0, iterations, tune, skip_initial_state_check, thin_by, thin, store, progress, progress_kwargs)
    377             checkpoint_step = thin_by
    378             if store:
--> 379                 self.backend.grow(iterations, state.blobs)
    380 
    381         # Set up a wrapper around the relevant model functions

~/opt/anaconda3/lib/python3.8/site-packages/emcee/backends/backend.py in grow(self, ngrow, blobs)
    173         self._check_blobs(blobs)
    174         i = ngrow - (len(self.chain) - self.iteration)
--> 175         a = np.empty((i, self.nwalkers, self.ndim), dtype=self.dtype)
    176         self.chain = np.concatenate((self.chain, a), axis=0)
    177         a = np.empty((i, self.nwalkers), dtype=self.dtype)

TypeError: 'numpy.float64' object cannot be interpreted as an integer