scripts and functions for LTV modelling