Why does `transform=pm.distributions.transforms.ordered` lead to worse convergence?

Another guess is that one of your _means might be redundant with the alpha (they seem to both work as intercepts)

Good catch! Can’t believe I missed that :sweat_smile:.

Also good idea on reshaping after ordering. But it doesn’t seem to help in this case.

New model, without alpha, and reshaping after. Again I’ll be toggling the commented out line for both traces.

import numpy as np
import pymc3 as pm
import theano.tensor as tt

data = ...  # pandas DataFrame containing data
model_usage_data = data[["scaled_value"]]
model_day = model_usage_data.index.to_numpy().reshape(-1, 1)
coords = {"day": model_usage_data.index}
groups = 2

with pm.Model(coords=coords) as model:
    beta = pm.Normal("beta", mu=0, sd=1)

    day_data = pm.Data("day_data", model_day)
    broadcast_day = tt.concatenate([day_data, day_data], axis=1)

    trend = pm.Deterministic("trend", beta * broadcast_day)

    _means = pm.Normal(
        "_means",
        mu=[0, 0.1],
        sd=10,
        shape=(1, groups),
        # Will be toggling this line
        # transform=pm.distributions.transforms.ordered,
        testval=np.array([0, 0.2]),
    )
    means = pm.Deterministic(
        "means", tt.reshape(_means, (1, groups)) + trend
    )

    p = pm.Dirichlet("p", a=np.ones(groups))
    sds = pm.HalfNormal("sd", sd=10, shape=groups)

    pm.NormalMixture("y", w=p, mu=means, sd=sds, observed=model_usage_data)

    trace = pm.sample(
        draws=draws,
        tune=tune,
        target_accept=0.90,
        max_treedepth=15,
        return_inferencedata=False,
    )

Without transform=pm.distributions.transforms.ordered

With transform=pm.distributions.transforms.ordered