How to model a Weibull distributed time series?

I have data that I want to model using a Weibull (or actually Rayleigh) distribution. I want to model it such that the beta parameter changes “over time” (data is a time series).

I tried to model that using a GaussianRandomWalk, see here:https://github.com/pymc-devs/pymc3/issues/3584

with pm.Model() as model:
    beta = pm.SomeThing('beta') # <-- some positive-only time-series model here
    y_obs = pm.Weibull('y_obs',
                alpha=2, #Rayleigh distribution
                beta=beta,
                observed=d)

That of course does not work, since the beta parameter is required to be positive, while the GaussianRandomWalk produces any kind of real value (thus also negative values). Do you have any suggestions how this could be modeled?

I have already tried to ignore time in my first approach and do analysis on distinct windows of the data, but now I want to integrate the time domain, as my visualizations suggest that this might make sense.

Thanks in advance for any ideas!

Why not:

with pm.Model() as model:
    tau = pm.HalfNormal('tau', 1)
    logbeta = pm.GaussianRandomWalk('beta_log', tau) # <-- latent time-series
    beta = pm.Deterministic('beta', tt.exp(logbeta))
    y_obs = pm.Weibull('y_obs',
                alpha=2, #Rayleigh distribution
                beta=beta,
                observed=d)
1 Like

Thanks, that tt.exp() trick worked for my model :smiley:

Just for future reference: I now use the sigma parameter on the tau prior to control how much smoothing I want for the resulting latent time-series. While this seems to work well, I wonder whether that is a “good” way of controlling the smoothness of the latent time-series. Any opinions on that?