Turing fitting a Weibull model

I am trying to fit a Weibull distribution in Turing. Sometimes when I rerun the model I get the following error.

Any suggestions to avoid above error? I am also getting a similar error when I fit a regression model (see it below) with the explanatory variables.

scale = (intercept .+ XIncidenttype * aIncidentType .+
bDetectionMethod * data[:, :Detection_Method] .+
Xseverity * cseverity .+
XAgency * dAgency
)

shape ~ truncated(Normal(0, 100), 0, Inf)
mu = exp.(scale)

y .~ Weibull.(shape, mu)

Thank you.

I think you need to make sure the parameters on the Weibull distribution can’t be zero. So set the priors slightly above zero.

1 Like

Thank you. May I ask how? I am new to Turing.

Sure, so just modify the truncated bit from your code to something slightly higher than zero:

#priors
shape ~ truncated(Normal(0, 100), 0.01, Inf)
scale ~ truncated(Normal(0, 100), 0.01, Inf)

Thank you very much. It works on fitting the simulated data (distribution). But, on the regression, I am still getting the same error. Any suggestion?

scale = (
intercept .+
XIncidenttype * aIncidentType .+
bDetectionMethod * data[:, :Detection_Method] .+
Xseverity * cseverity
)

shape ~ truncated(Normal(0.5, 100), 0.01, Inf)
mu = exp.(scale)

y .~ Weibull.(shape, m)

It’s a little hard to say because I don’t think the whole model is shown here. I’d recommend checking out the linear regression example on the Turing site though:
https://turing.ml/dev/tutorials/5-linearregression/

Specifically, I’d look at the model specification section.

Try

m = exp.(scale) .+ 0.01

Thank you very much. It works.