-
Notifications
You must be signed in to change notification settings - Fork 35
Description
I am getting this error despite the fact that I'm not putting any attribute 'dist' into the FlatParam function, just the test_value argument which it is supposed to have. Below is a simplified toy model which also creates this error. It is a random effects model, and initially I thought the problem was somehow due to the LLB line and its inclusion in the return line, but that can be removed and the error will still occur.
from pydream.parameters import FlatParam
from pydream.parameters import SampledParam
from pydream.core import run_dream
from pydream.convergence import Gelman_Rubin
import numpy as np
#from pysb.integrate import Solver
from scipy.stats import norm
from scipy.stats import uniform
from dill import dump_session
x=norm.rvs(size=10)
xb=np.repeat(x,10)
y=xb+norm.rvs(size=100)
explan=np.repeat(range(0,9),10)
pysb_sampled_parameter_names=['B','sigmaB','sigma']
sigma = SampledParam(uniform,loc=0,scale=1000)
sigmaB = SampledParam(uniform,loc=0,scale=1000)
Blst = np.linspace(0,0,num=10)
B = FlatParam(test_value=Blst)
sampled_parameter_names=[B,sigmaB,sigma]
def likFH(parameter_vector):
param_dict = {pname: pvalue for pname, pvalue in zip(pysb_sampled_parameter_names, parameter_vector)}
LLB = norm.logpdf(param_dict['B'],0,param_dict['sigmaB'])
Mu = param_dict['B'][explan]
LL1 = norm.logpdf(y,Mu,param_dict['sigma'])
return (np.sum(LL1)+np.sum(LLB))
#Run model
sampled_params, log_ps = run_dream(sampled_parameter_names, likFH, model_name='ToyRE_5chain', verbose=True)