Question about modeling approach?

Hi All,

I know it’s easier to answer a question if you have an example in code but I wanted to get some thoughts on whether I am thinking about my problem correctly to model it in pyro.

I’m trying to model life insurance policies, in this scenario the size of the first dimension of my data would be the number of policies. The latent variables of interest here are underlying mortality rates. Traditionally, experience studies result in mortality tables that vary by age for example. These rates for each age would be used to inform my priors.

What is the most efficient way to project policies into the future while ensuring that the correct prior distribution is used (the prior depends on age which changes through time).

One such way would be split the data by age into different tensors, apply the mortality rates and then somehow reassemble into a single tensor preserving the original order of policies. However, this would be done over and over and I imagine in would be relatively slow in pytorch.

Any ideas, maybe I am not thinking about the approach in the correct way? Presumable this problem would come up pretty frequently in time series models?

Thanks,
Paddy

Hi, I’m having trouble reconstructing your model from your description, but I find that “make it work, make it right, make it fast” is usually a good rule of thumb for these situations. Start by writing the most computationally naive version of your model, make sure that it behaves correctly on a small dataset, and then worry about performance. If you post a snippet with a model that you want to speed up, you’ll be able to get more specific suggestions.

If I follow that approach, I often find that I end up with a series of possibly nested for-loops, some over conditionally independent variables, and that each conditionally independent loop can be vectorized and replaced with an appropriate with pyro.iarange(...) statement. See the SVI pt2 and Tensor Shape tutorials for some examples.

@eb8680 Thanks so much for your comments, I really appreciate your response. I will follow your advise.