I have this example code that i am using in python with pymc3 package
import pymc3
import numpy as np
size = 100
# Predictor variable
X1 = np.random.randn(size)
X2 = np.random.randn(size) * 0.2
X3 = np.random.randn(size) * 2
alpha, sigma = 1, 1
beta = [1, 2.5]
Y = alpha + beta[0]*X1 + beta[1]*X2 + np.random.randn(size)*sigma
basic_model = pymc3.Model()
with basic_model:
# Priors for unknown model parameters
alpha = pymc3.Normal('alpha', mu=0, sd=1)
beta = pymc3.Normal('beta', mu=0, sd=1, shape=3)
sigma = pymc3.HalfNormal('sigma', sd=1)
# Expected value of outcome
mu = alpha + beta[0]*X1 + beta[1]*X2 + beta[2]*X3
Y_obs = pymc3.Normal('Y_obs', mu=mu, sd=sigma, observed = Y)
trace = pymc3.sample(100,chains = 1, step = pymc3.NUTS())
a = trace['alpha']
b = trace['beta']
print (trace['alpha'])
print (trace['beta'])
print (a[0] + b[0][0]*X1[0] + b[0][1]*X2[0] + b[0][2]*X3[0]) #mu
I expected that if mu = 0, only beta and alpha constants will vary? And I get an analysis from that, but mu result is never 0 or even close to 0? For example, if alpha is negative other constants or at least one should be positive so every the calculation(mu) should be 0 or close to 0?. If I try to set mu to = 0 I get an error SyntaxError: can't assign to literal