I am trying to create a Bayesian Linear Regression model with one independent variable. However, when I try to sample my model using the NUTS sampler, I get the following error: “Sampling Error: Bad Initial Energy”.
The code below shows the approach I followed to build my model:
basic_model = pm.Model() with basic_model: alpha = pm.Gamma('alpha', mu=alpha_mean, sigma=alpha_std, shape=(1)) beta = pm.Beta('beta', mu=beta_mean, sigma=beta_std, shape=(1)) sigma = pm.HalfNormal('sigma', tau=1) mu = alpha + beta*model_input Y_obs = pm.Beta('Y_obs', mu=mu, sigma=sigma, observed=model_output)
trace = pm.sample(500, cores=1, init='adapt_diag')
I had pre-calculated the inputs to the model as follows:
# Slice out Variables X = bayesian_regressor_frame['X'] Y = bayesian_regressor_frame['Y'] X = X.values Y = Y.values model_input = theano.shared(X) model_output = theano.shared(Y) # Calculate Parameters alpha_mean = Rolling_OLS_params['alpha'].mean() alpha_std = Rolling_OLS_params['alpha'].std() beta_mean = Rolling_OLS_params['beta'].mean() beta_std = Rolling_OLS_params['beta'].std()
I have taken the liberty to attach the input files that were used to build the model. Where am I going wrong?