Hi,
I am currently attempting to model a generative process for an AR1 timeseries model but I am encountering difficulties in aligning the shapes of ar_inint
and ar_innov
in order to concatenate them for the model. Also, I am aware about pymc’s builtin AR class but i am explicitly writing it down for better understanding…
import pymc as pm
import pytensor as ae
import pytensor.tensor as at
from pytensor.tensor.random.utils import RandomStream
srng = RandomStream(seed=234)
# Program
lags = 1
with pm.Model() as model_ar:
rho=pm.Uniform("rho")
sigma=pm.Exponential("sigma",1)
ar_init = pm.Normal("ar_init", shape=(lags,))
def ar_function(x_tm1, rho, sigma):
return srng.normal(x_tm1*rho,sigma)
ar_innov, updates = ae.scan(
fn=ar_function,
output_info = [dict(initial = ar_init, taps = [-lags] ) ],
non_sequences=[rho, sigma],
n_steps=100,
)
ar = pm.Deterministic("ar", at.concatenate([ar_init, ar_innov]))
Which is getting me the error below
**
TypeError: Only tensors with the same number of dimensions can be joined. Input ndims were: [1, 2]
**