Why isn't a deterministic continuous variable optimized by find_MAP?

Help on function find_MAP in module pymc3.tuning.starting:

find_MAP(start=None, vars=None, method='L-BFGS-B', return_raw=False, include_transformed=True, progressbar=True, maxeval=5000, model=None, *args, **kwargs)
Finds the local maximum a posteriori point given a model.

start : `dict` of parameter values (Defaults to `model.test_point`)
vars : list
    List of variables to optimize and set to optimum (Defaults to all continuous).

However, running it on the example in “Getting Started with PyMC3”:

basic_model = pm.Model()

with basic_model:

    # Priors for unknown model parameters
    alpha = pm.Normal('alpha', mu=0, sd=10)
    beta = pm.Normal('beta', mu=0, sd=10, shape=2)
    sigma = pm.HalfNormal('sigma', sd=1)

    # Expected value of outcome
    mu = alpha + beta[0]*X1 + beta[1]*X2

    # Likelihood (sampling distribution) of observations
    Y_obs = pm.Normal('Y_obs', mu=mu, sd=sigma, observed=Y)

The result does not include mu even though it is a continuous random variable. Maybe this is so because is a deterministic variable, but the documentation does not refer to determinism. Should mu be included, or should the documentation be improved?

mu is not a named variable in the graph, so it is ignored. If you want to keep the record of this variable in the point or trace, you can wrap it in a deterministic: mu = pm.Deterministic('mu', alpha + beta[0]*X1 + beta[1]*X2)

1 Like