Modeling of multiple regression model with array form (original) (raw)
Really Thanks ^^.
By the way, last question, I will search the solution by myself. I don’t have a specific plan for implementing this.
However, I get still errors of the first question…
Could you help me again? ㅠㅠ…
(I am actually studying the workbook with PyMC3. So I don’t get used to pytensor…)
# multiple linear regression - Selective
x = np.random.normal(10,np.sqrt(2),size=(6,10))
y = np.random.normal(30,np.sqrt(15),size=(6,10))
with pm.Model() as mod:
Mu1_array = np.array([[5,10,0,4,0,9],
[0,6,2,0,8,11],
[13,12,11,10,0,0],
[0,0,5,3,7,8],
[10,0,11,0,15,0],
[0,7,8,6,4,0]])
Mu2_array = np.array([[5,10,0,4,0,9],
[0,6,2,0,8,11],
[13,12,11,10,0,0],
[0,0,5,3,7,8],
[10,0,11,0,15,0],
[0,7,8,6,4,0]])
sd1_array = np.array([[.5,.10,np.inf,.4,np.inf,.9],
[np.inf,.6,2,np.inf,.8,.11],
[1.3,1.2,1.1,np.inf,np.inf,np.inf],
[np.inf,np.inf,.5,.3,7,.8],
[np.inf,np.inf,1.1,np.inf,1.5,np.inf],
[np.inf,7,8,6,4,np.inf]])
sd2_array = np.array([[.5,.10,np.inf,.4,np.inf,.9],
[np.inf,.6,2,np.inf,.8,.11],
[1.3,1.2,1.1,np.inf,np.inf,np.inf],
[np.inf,np.inf,.5,.3,7,.8],
[np.inf,np.inf,1.1,np.inf,1.5,np.inf],
[np.inf,7,8,6,4,np.inf]])
Selective_Regressor = np.ones([6,1])
for i in np.arange(0,5):
Beta = pm.Normal('Beta', mu=Mu1_array[i,:],sigma=sd1_array[I,:])
Alpha = pm.Normal('Alpha', mu=Mu2_array[i,:],sigma=sd2_array[I,:])
epsilon = pm.Normal('epsilon',mu=0,sigma=np.sqrt(5), shape=(6,1))
Slope = Beta * x + Alpha
Selective_Regressor[i,0] = pm.Normal(f'Selective_Regressor_{i}',mu=Slope,observed=y)
tr = pm.sample(10)
The error is : Incompatible Elemwise input shapes [(1, 6), (6, 10)]