Thank you very much for your advice! my code is as follows:
import numpy as np
import pymc3 as pm
from theano import tensor as tt
N = 200 # the number of observed individuals
n= 11 # each individual was observed 5 times
e=np.ones(n)
mu0 = np.linspace(0.0, 0.0, num=n)
# simulate observation data(AR结构)
C2=np.zeros((n,n))
for i in range(0,n):
for j in range(0,n):
C2[i,j]=10.*0.4**np.abs(i-j)
dataSet2 = np.random.multivariate_normal(mu0, C2, size=N)
time_obseved = [-5.0,-4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0]
time = np.array(time_obseved)
H0 = np.zeros((n, n))
for i in range(0, n):
for j in range(0, n):
H0[i, j] = np.abs(time[j] - time[i])
with pm.Model() as model:
sigma_w = pm.InverseGamma('sigma_w',1.0,0.1)
rho = pm.Normal('rho', 0.4, 0.01)
cov0=sigma_w**2*tt.pow(rho,H0)
omega=pm.MvNormal('omega',mu=mu0,cov=cov0,shape=(1,n))
mu1=pm.Normal('mu1',mu=0.0,sd=0.01)
xi=pm.InverseGamma('xi',11.0,0.1)
b=pm.Normal('b', mu=0.0, sd=tt.sqrt(xi),shape=(N,1))
mu2=(mu1+b)*e+omega
sigma=pm.HalfNormal('sigma',0.01)
y=pm.Normal('y',mu=mu2,sd=sigma,observed=dataSet2)