Autoregressive Model

Hello everyone,

I start saying that I am very new both to PyMC3 and Bayesian statistical modelling.
What I was trying to do was to write an AR(1) model for fitting the toy data produced by this function

def generate_poisson_ar(lam_int, slope_a, slope_b, mu_noise, sigma_noise,
                        burn_factor=2, time_steps=48):
    intercept = np.random.poisson(lam_int)
    slope = np.random.beta(slope_a, slope_b)
    process = [intercept]
    true_parameters = {
        'Intercpet': intercept,
        'Slope': slope
    }
    for time_step in range(time_steps * burn_factor):

        new_value = intercept + int(slope * process[time_step]) + \
            np.random.normal(mu_noise, sigma_noise)
        new_value = max(0, new_value)
        process.append(new_value)

    process = np.array(process[-time_steps:])
    return process, true_parameters  

process, true_parameters = generate_poisson_ar(
    lam_int=200,
    slope_a=2,
    slope_b=5,
    mu_noise=50,
    sigma_noise=50
)
X = process[:-1]
y = process[1:]

But instead of using the PyMC3 AR1 class I wrote this model:

prior_mu = 200
prior_alpha = 2
prior_beta = 5
with pm.Model() as ar_model:

        intercept = pm.Poisson(
            mu=prior_mu,
            name='Intercept'
        )
        slope = pm.Beta(
            alpha=prior_alpha,
            beta=prior_beta,
            name='Slope'
        )

        mu = intercept + slope*X

        outcome = pm.Poisson(
            mu=mu,
            observed=y,
            name='y'
        )

My questions are:

  1. Do you think the model I defined is a sensible alternative to use the example provided on the PyMC3 docs (the one using the AR1 class)?
  2. Inspecting both the traceplot and the the posterior predictions

    made by the model it seems that my solution work ok-ish (the MCMC chains are not very well mixed), however I get these errors:
Sampling 4 chains for 2_000 tune and 1_000 draw iterations (8_000 + 4_000 draws total) took 72 seconds.
The acceptance probability does not match the target. It is 0.9144978498054566, but should be close to 0.8. Try to increase the number of tuning steps.
The estimated number of effective samples is smaller than 200 for some parameters.

Can anyone help me shading some light on the reasons behind these messages?

Thank you :blush: