Help with STS modeling

57 views
Skip to first unread message

Lenhart

unread,
Nov 6, 2022, 2:42:00 PM11/6/22
to TensorFlow Probability
I am working on understanding Bayesian modeling, time series and implementing in TFP. I have time series data that records monthly snowfall in northern Arizona. For six months of the year, it almost never snows; in the winter, it snows but there is a lot of variance in how much--as little as none, as much as 70 inches in one month during some years.

My model:
    trend = sts.LocalLevel(observed_time_series=obs_snow)
    seasonal = sts.Seasonal(num_seasons=12, observed_time_series=obs_snow, allow_drift=False)
    snow_model = sts.Sum([trend, seasonal], observed_time_series=obs_snow)


In this case, a good model would capture (1) summer month certainty, (2) winter month uncertainty, (3) very low error in summer months and (4) mean winter forecasts that are close to the mean of each month in the data. That is, he model accuracy/error would not be better than predicting each month's average, but the model should generate uncertainties that tell us about each month's variance.

The model fails to do 1. The standard deviation for almost all seasons is around 9 (inches), which seems like a reasonable posterior for the winter months but terrible for the summer.


I have fitted with VI following the STS tutorials very closely. I have tried varying several model parameters to see if those change my results. To me, the results resemble selecting a single scale parameter for a normal distribution and moving that distribution shape (i.e., loc) around to make predictions. I would like it do to both--summer months should have a negative loc (~=mean monthly snowfall), very low sigma Normal distribution, while winter months should have a positive loc and large sigma. (FWIW, a distribution with support [0, inf) makes more sense to me, but I would be happy with Normals as an approximation at the moment.)

I admit, I don't understand my own problem deeply. For one thing, I admit I don't really understand how to model a variable with a hard-lower bound (zero inches, e.g.) using normal distributions. Nor, however, do I understand how I might transform or add such a distribution to STS if I did. I realize that means I'm partly just asking a question about simple Bayesian modeling (and statistics), but any help would be appreciated.

Thanks,

Lenhart

Junpeng Lao

unread,
Nov 7, 2022, 8:45:36 AM11/7/22
to TensorFlow Probability, lenhart...@gmail.com
Hi Lenhart,

In my experience, this type of time series is not easy to express with seasonal STS. The reason is that in Seasonal STS, the latent state X transition is a Gaussian random walk regularised with a drift parameter. This means the state X (12 when unconstrained in this case) is relatively smooth, instead you would want the summer months with almost 0 drift but the winter months a positive drift.

I think the first thing worth trying is formulate the seasonal component as a sparse regression. Something along the line of:

x = np.arange(0, len(obs_snow))
x_reg = np.tile(np.eye(12), len(x) // 12 + 1).T[:len(x)]
seasonal = sts.SparseLinearRegression(x_reg)
snow_model = sts.Sum([seasonal],
                     observed_time_series=y_obs)

Michael Tamillow

unread,
Nov 7, 2022, 11:09:29 AM11/7/22
to Lenhart, TensorFlow Probability
I would think that snowfall would be partially causally attributed to temperature, humidity, and pressure. I would say build your uncertainty model over these factors with cyclicality and then create causal effects as a function of the generated data.

You should not rule out the possibility that it can snow in the summer, you should just make it extremely unlikely based on the combination of factors. As my 6 year old pointed out, as he filled a cup of water with only ice, ice is water (obviously in another state.) Likewise, rain is snow. I would model all precipitation to better understand snowfall.

--
You received this message because you are subscribed to the Google Groups "TensorFlow Probability" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tfprobabilit...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/tfprobability/CAAgGELniqDNZSLWgiJH31bcsaWzxbuJggokqu%2BnLtdTfLv7f_g%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages