model = pm.Model() with model: posnormal = pm.Bound(pm.Normal,lower = 0.0) negnormal = pm.Bound(pm.Normal,upper = 0.0) #Varying Intercept:- mu_intercept = pm.Normal('mu_intercept',mu = 0.0,sigma = 1e5) sigma_intercept = pm.HalfNormal('sigma_intercept',sigma = 1) intercept = pm.Normal('intercept',mu = mu_intercept,sigma = sigma_intercept, shape = asins_num) #Common slope:- brand_slope = posnormal('brand_slope',mu = 0.0, sigma = 1e5, shape = x2.shape[1]) #Varying slope:- mu_slope = posnormal('mu_slope',mu = 0.0,sigma = 1e5) sigma_slope = pm.HalfNormal('sigma_slope',sigma = 1) slope = pm.Normal('slope',mu = mu_slope,sigma = sigma_slope, shape = asins_num) slope1 = pm.Normal('slope1',mu = mu_slope,sigma = sigma_slope, shape = asins_num) slope2 = pm.Normal('slope2',mu = mu_slope,sigma = sigma_slope, shape = asins_num) sigma_y = pm.HalfNormal('sigma_y',sigma = 1) mu = intercept[asin_idx] + pm.math.dot(x2,brand_slope) + slope[asin_idx] * x1['Discount'] \ slope1[asin_index] * x1['SB_Impressions'] + slope2[asin_index] * x1['SNB_Impressions'] Y = pm.Normal('Y',mu = mu,sigma = sigma_y,observed = Y_Act) with model: trace = pm.sample(500,tune = 500,init = 'advi',n_init = 10000,cores = 4,progressbar = True) #start = pm.find_MAP() #step = pm.NUTS(scaling = start) #trace = pm.sample(500,tune = 500,step = step,start = start,cores = 4,progressbar = True)