Batching estimates for model with multiple datasets

I’ve created a regression model that performs as expected. At the moment I am interested in the MAP estimates for the variables, for a given dataset. This is time series data and ideally I’d like to estimate one variable independently for each time window, while estimating the others over all available data. My idea was to make the variable I want to recompute per time window vector valued (where the size is the number of windows), while leaving the others scalars, but this approach is yielding non-sensical estimates for the vector valued variable (all components are nearly the same, and different from when they are computed independently).

This works as expected, where the inputs and outputs are all length 500:

n_samples = 500
n_start = 506
model = Model()
with model:  
    sigma = HalfNormal("sigma", sigma=10)
    a = HalfNormal("a", sigma=0.5)
    b = Normal("b", -42, sigma=2)
    c = Normal("c", 48/14, sigma=0.5)
    
    # Define likelihood

    out = Normal("out", mu=a + (b * x0[n_start:n_start + n_samples]) + (c * x1[n_start:n_start + n_samples]), 
                 sigma=sigma, observed=y[n_start:n_start + n_samples])

    m = find_MAP(model=model)

What I’d like to do, is given many inputs-sets of length 500 infer a different b variable for each input-set but estimate a and c using all of the available input. Does this make sense and can anyone point me in the right direction?

1 Like

Welcome!

Can you share what you did when you tried the parameter array? That might be a better starting point than the single time window example that is working.

1 Like