Unable to fit Beta model to my data: SamplingError: Initial evaluation of model at starting point failed!

I’m new to pymc and probabilistic programming and I’m stuck with this error message:
Version: v4.0.0b6

SamplingError: Initial evaluation of model at starting point failed!
Starting values:
{'alpha_interval__': array(-0.16849976), 'beta_interval__': array(-0.38707828)}

Initial evaluation results:
{'alpha': -1.39, 'beta': -1.42, 'y': -inf}

I have observations that fit Beta model well:

Screen Shot 2022-08-16 at 1.34.10 PM

When I manually guess the alpha and beta parameters for the Beta distribution, I get a good approximation:

Screen Shot 2022-08-16 at 1.36.14 PM

I have a lot of 0s in the observation data and replaced all of them with 0.0001. Min and Max values of my observations are: (1e-05, 1.0)

Now, I need to estimate the parameters with pymc, but I’m getting an error:

with pm.Model() as model:    
    alpha = pm.Uniform("alpha", lower=0.13, upper=0.15)
    beta = pm.Uniform("beta", lower=3, upper=3.5)    
    y = pm.Beta("y", alpha=alpha, beta=beta, observed=observations)
    prior = pm.sample_prior_predictive(random_seed=RANDOM_SEED)
    trace = pm.sample(tune=1000, draws=4000, chains=4, cores=-1, return_inferencedata=True)
    posterior_predictive = pm.sample_posterior_predictive(trace=trace)

I cannot figure out what the problem is, please help!

I figured it out. The beta model for some reason requires x = (0,1) rather than x = [0,1] which is weird, because beta distribution should represent the proportions and percentages.
Ref: Beta Distribution


At the link you provided:

However, the inclusion of x = 0 and x = 1 does not work for α, β < 1; accordingly, several other authors, including W. Feller choose to exclude the ends x = 0 and x = 1, (so that the two ends are not actually part of the domain of the density function) and consider instead 0 < x < 1.

I can’t speak to the choice of how pm.Beta was designed, but that seems like a reasonable rationale.