I’m trying to see whether there was a switch point in Syrian conflict casualties (2011-2014, grouped by casualties per week).
with pm.Model() as model: alpha = 1.0/a.casualties.mean() lambda_1 = pm.Exponential("lambda_1", alpha) lambda_2 = pm.Exponential("lambda_2", alpha) tau = pm.DiscreteUniform("tau", lower=0, upper=count_conflict_time-1)#switchpoint idx = np.arange(count_conflict_time) # Index lambda_ = pm.math.switch(tau > idx, lambda_1, lambda_2) observation = pm.Poisson("obs", lambda_, observed=a.casualties) with model: trace = pm.sample(10000, tune=5000)
pymc3 automatically chooses the right sampler:
NUTS: [lambda_2_log__, lambda_1_log__]
But when look at summary (pm.summary(trace)) I see Rhat is NaN:
mean sd mc_error hpd_2.5 hpd_97.5 n_eff Rhat tau 78.0, 0.0 0.0, 78.0, 78.0, 20000.0, NaN
And by plotting trace we see:
No matter what I do, I always get scale reduction factors (rhat) = NaN. Does this mean the tau didn’t converge? How can this be corrected?