Predicting one time series from another (or many others)?

I have been digging more into PyMC3 recently, but I am still not sure exactly how to specify a model where my inputs are time series, and my output is a time series as well.

I imagine I would have to rely on one of the pymc3.distributions.timeseries classes as the last line in my code, and match my output time-series to the observed= argument within it, but how would I go about specifying the other time series as individual components?

For ex., how would I specify a model wherein I try to predict the orange line, based on the others?

28%20PM

The official examples deal with standard time series forecasting - one time series in, forecast of same time series out, instead of (like I would want) many time series in, one time series out.

I would extremely appreciate any advice. Thank you.

You can treat the input time series as predictors, and build a regression model.

So, based on your reply, I imagine the easy solution you meant is to set something like this up in PyMC3,

\texttt{with pm.Model() as model:} \\ \ \ \ \ \ \ \ \ f(x_i) = series1_i + series2_i + series3_i + \ldots \ \ \ \text{*some regular regression*}\\ \ \ \ \ \ \ \ \ \texttt{sd_prior = pm.HalfNormal('sd_prior', sd = 3)} \\ \ \ \ \ \ \ \ \ \texttt{observed = pm.Normal('observed', mu = }f(x_i)\texttt{, sd = sd_prior,} \\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \texttt{observed = ???)} \\ \ \ \ \ \ \ \ \ \texttt{trace = pm.sample()}

Which helped me conceptually, but how would I set this up in PyMC3? I am not sure how to set up this regression, and what would I set equal to observed in pm.Normal() then?

Would you give me a quick example?

So I tried to do this, using 16 example time series to try to predict another,

with pm.Model() as model:
    
    mu_beta = pm.Normal('mu_beta', mu=0, sd=10)
    sd_beta = pm.HalfNormal('sd_beta', sd=10)
    beta = pm.Normal('beta', mu=mu_beta, sd=sd_beta, shape=(16))
    input_data = pm.math.dot(train[:,1:17].values, beta)
    
    sd_prior = pm.HalfNormal('std_prior', sd=3)

    observed = pm.Normal('observed', mu = input_data, sd = sd_prior, 
                         observed = train['observed'].values)
    
    trace = pm.sample(cores=4)

but sampling is slow, and I inevitably get a chain failure.

What am I doing wrong here?

Yep that’s what I meant - maybe try standardizing/normalizing the predictors train[:,1:17].values