python - Generating random matrices for VAR(p) in PyMC3 -


i trying build simple var(p) model using pymc3, i'm getting cryptic errors incompatible dimensions. suspect issue i'm not generating random matrices. here attempt @ var(1), welcome:

# generate data y_full = numpy.zeros((2,100)) t = numpy.linspace(0,2*numpy.pi,100) y_full[0,:] = numpy.cos(5*t)+numpy.random.randn(100)*0.02 y_full[1,:] = numpy.sin(6*t)+numpy.random.randn(100)*0.01 y_obs = y_full[:,1:] y_lag = y_full[:,:-1] pymc3.model() model:   beta= pymc3.mvnormal('beta',mu=numpy.ones((4)),cov=numpy.ones((4,4)),shape=(4))   mu = pymc3.deterministic('mu',beta.reshape((2,2)).dot(y_lag))   y = pymc3.mvnormal('y',mu=mu,cov=numpy.eye(2),observed=y_obs) 

the last line should be

y = pm.mvnormal('y',mu=mu.t, cov=np.eye(2),observed=y_obs.t) 

mvnormal interprets last dimension mvnormal vectors. because behaviour of numpy indexing implies y_obs vector of length 2 containing vectors of length 100 (y_lag[i].shape == (100,))


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -