Shiny App - k-Bit Recurrence Model
Objective:
This algorithm model a stochastic process that combines the forward-branching structure of a binomial tree with the memory-retaining dynamics of a recurrent neural network (similar to Hopfield network when historical step (k) = 3), while computing expected values at every step under binary (0/1) outcomes.Applications:
- Monthly payment (utilities / phone / insurance)
- Repayments of loan / mortgage (beyond the scope of this app as maturity is not considered)
Instructions:
- Choose the number of historical time steps and the number of future steps you want to forecast.
- Enter the total population for each event code across the historical period, plus the expected number of events for the next upcoming step.
- Click Run to compute the expected values and visualize the resulting growth or decline curve.
See it move:
Pick a picture below. Each one shows one idea of the model (use the sliders to change it). The numbers in the animation are illustrative, so you can see the shape of the idea; the app below uses your own data.
In five steps:
- Each step is a 0 or a 1. Paid or not paid, event or no event. Every step splits into two branches, like a binomial tree.
- Remember the last k steps. The last k bits form a small pattern, which is the state (k = 3 gives 8 states). A normal tree only remembers the last step; this model remembers k.
- The state sets the odds. The pattern picks the chance that the next bit is a 1. Memory strength 0 means no memory (a plain tree); higher means the past matters more.
- Add up the paths. Different 0/1 paths that end with the same number of payments after the same number of steps are combined into one chance (tab 2).
- Push expected values forward. Instead of simulating thousands of random paths, it moves the expected number of people through the states, one step at a time, so the forecast is exact and fast.
Details:
In a binomial tree, each nodeâs probability depends only on the immediately previous state. Here, the transition probability at step k is derived from a grouped summary of multiple earlier stepsâeffectively treating the history as a compact state vector whose influence decays or aggregates in a controlled manner.This is similar to the recurrent connections in a Hopfield network, where the networkâs energy landscape stores and retrieves patterns from past activations. However, unlike Hopfield neural network (which typically performs deterministic or probabilistic retrieval), the algorithm injects a forward-looking expected-value layer.
This expectation is propagated forward, turning the process into a hybrid recurrent stochastic process that remembers past configurations while maintaining an analytically tractable martingale-like property.
Try it
The app is hosted on shinyapps.io. If the box below stays blank, use the button: it opens the same app in its own tab.
TO DO (based on funding):
- Different option of input methods
- Extend length of steps forward
- Extend length of historical steps
- Include the option of different set of parameters for each step up to the cycle of 12 steps
- Include length of terms for loans
- Include breakdown of number of events by each step