I slaved for 12 years! in the mines of this blog, toiling night and day, for all three of my readers. My now ex gf during five of those years once accused me of loving retirement finance and my computer more than her ;-) something which I can neither confirm nor deny, then or now.
Recently, just for fun and to see how it would go, I spent a couple hours recreating and recasting five or six of what I consider my sufficiently important or interesting coding projects into AI prompts <dramatic eye roll on all those wasted years>. I maybe should have waited for the advent of AI and saved myself at least some of those 11.999 years where I maybe didn't have to do anything. Or gone to a bar. Or traveled. Whatever, I thought I would share some of the prompts and projects here. To wit (each will be a separate post):
- GPT Prompt 01 - Spending Strategy Comparisons [this post]
- GPT Prompt 02 - Lifetime Probability of Ruin (LPR)
- GPT Prompt 03 - Dynamic Programming / HJB
- GPT Prompt 04 - Portfolio Longevity Heat Map
- GPT Prompt 05 - Perfect Withdrawal Rate (PWR)
- GPT Prompt 06 - Stochastic Present Value (SPV)
Some caveats first:
- The prompting process seems unstable for each re-prompt and yields varying results and is also conditional on the platform. I used ChatGPT's $20/month platform "Plus." Fwiw, I also save a physical copy so that I can re-force AI to more or less start from scratch each time rather than trusting it to remember stuff. Note that I actually had to re-prompt this after not looking at it for 6 months because it literally did not work after it had worked 50 times the last time I worked on it. Beware.
- AI's hallucinate and you have to take output carefully and/or with a grain of salt,
- Chat may evolve and obsolete the prompts,
- It helps to know the underlying theory and methods to second guess what it is doing. Otoh, one can have a dialogue now to figure it out,
- There are certain tasks it will NOT do. For example, it said once that it could do HJB on 2-asset allocation optimization and then when I said "ok, now run it," it said "sorry, bro, can't; it's too hard and will time out." It later created an acceptable work around but one needs to know what it can and can't do. It probably just want's me to pay more,
- I did this more or less "seat of the pants" so there might be assumptions Chat used for me during the many iterations that won't be resident in memory for you if you test drive. No idea...
- These are fairly trimmed down and focus more on simple versions of the theory. No fine tuning for fees or taxes or investor idiosyncrasies etc but those are probably easy enough to retrofit,
- Rigorous testing against a previously coded model has NOT been done. I guarantee I have probably mis-prompted somewhere in here and I don't even know it. The adjustment I just made to mortality for this post I have not rationalized, I just trusted Chat because I somehow got in an infinite loop and didn't want to think too hard, yet,
- This is titled "spending strategies" but is articulated below for comparing portfolios. It is trivial to swap to just one portfolio and use multiple spending strategies. Not shown. Maybe later. For the one of the three readers that care.
GPT Prompt 01 - Spending Strategy Comparison
Description
Rather than asking whether a retirement plan merely “avoids ruin,” this framework evaluates spending strategies by the lifetime well-being they actually deliver. Each candidate rule—fixed withdrawal rates, flexible rules, or utility-based spending—produces a stochastic path of real consumption over time, which is then evaluated using expected lifetime utility, weighting consumption by survival probabilities and (optionally) modest time discounting:
where is typically a CRRA utility function. Because raw utility is not directly interpretable, results are translated back into dollars via certainty-equivalent consumption: the constant real spending level that would yield the same lifetime utility. This approach captures the economic reality that early-life consumption, spending stability, and downside protection matter far more than late-life volatility or rare tail survival, and it frequently shows that conservative, floor-oriented spending policies can deliver higher lifetime welfare than mechanically “safe” withdrawal rules—even when those rules technically succeed.
[I let AI write the description so the narrative overview here pretty much sucks. Basically the model does a simulation to generate the expected discounted utility of lifetime consumption (EDULC) along a bunch of sim consumption paths. ie one may compare EDULC (or its certainty equivalents) for different portfolios or spending strategies and do some comparisons... Do you know or have you ever used MaxFi? This is the same thing except I am handing it out for free. Plus it is infinitely flexible...but way less sophisticated on things like taxes and social security and location buckets...but that'd be easy enough to fix I'd wager. This is my partial gift to you in other words because why pay for stuff we can get for free and especially when there are diminishing returns to marginal complexity ;-)]
The Prompt (which may or may not work anytime it is run) Parameters are highlighted in blue
Evaluate spending strategies under uncertainty using an economic consumption utility approach: “Expected Discounted (subjective time preference) Utility (CRRA) of Lifetime Consumption.”
Parameters:
- current_age: 65
Mortality model: Gompertz with modal age = 88, dispersion = 9; conditional on current_age; limit max age to 122
Gompertz model is this conditioned on current age: S(a) = \exp\!\left(-\exp\!\left(\tfrac{a - m}{b}\right)\right)
Precompute conditional survival and then sample once:
Compute Pt=tPx=S(x+t)/S(x) for t=0..T | x=current_age
Convert to death CDF over t (probability death occurs in year t)
Sample death year by inverse CDF (vectorized)
Portfolio model 1: 60/40 equity/bond with expected REAL forthcoming arithmetic return = 0.04, stdev = 0.12, annual rebalancing
Portfolio model 2: 100/0 equity-bond with expected REAL forthcoming arithmetic return = 0.06, stdev = 0.17, annual rebalancing
Portfolio model 3: 35/35/30 equity/bond/trend-following with expected REAL forthcoming arithmetic return 0.035, stdev 0.07, annual rebalancing
Returns: annual lognormal real gross returns calibrated to match stated arithmetic mean/stdev; annual rebalancing (single return per year)
initial wealth is $1,000,000
- Utility function: CRRA with risk aversion γ = 2
- Subjective time preference discount rate: 0.5%
the utility function formula for CRRA:
U(c) = \frac{c^{1-\gamma} - 1}{1-\gamma}, \quad \gamma \neq 1
and log utility for γ=1
certainty-equivalent consumption is normalized by the discounted weights not by expected lifetime
Additional assumptions:
- A guaranteed, inflation-adjusted income stream of $10,000 (in initial year(0) dollars) begins at age 70,
- Before age 70: if portfolio wealth depletes to less than $1, consumption falls to an inflation adjusted hard-life floor of $5,000 in year(0) dollars,
- At and after age 70: if portfolio wealth depletes, consumption immediately adjusts (“snaps”) to the guaranteed income stream.
- In those periods where wealth and income are more than enough for the spending strategy the excess income should not add to the spending strategy but rather be reinvested.
No borrowing is allowed.
1. Portfolio model 1
2. Portfolio model 2
3. Portfolio model 3
1. Simulate outcomes for each strategy across random returns and random lifetimes.
2. Report:
a. Expected discounted utility of lifetime consumption
b. Certainty-equivalent constant consumption
c. Probability of ruin (wealth hits 0 before death)
d. Probability consumption < 20,000
e. Distribution of terminal wealth at death
3. Rank strategies by certainty-equivalent consumption.
4. Summarize tradeoffs between strategies.
Notes
- If it won't run this, you might have to tell it to "Run this as a reproducible Monte Carlo now!"
- This sometimes takes a while. No doubt there are ways to speed this up
- Follow-on analysis and charting and changes are fairly straight forward (not shown)
- Sensitivity analysis for different spend rates? just ask. Guardrails? prompt
- Not discussed here but this kind of prompt would lend itself to evaluating competing spending "shapes." Think: Robinson and Tahini "Sustainable Retirement Income for the Socialite, the Gardener and the Uninsured," 2007.
- The seminal paper on consumption Utility is Menachem Yaari, "Uncertain Lifetime, Life Insurance and the Theory of the Consumer," 1965. Introduced random lifetime to consumption utility lifecycle models.
- When I originally wrote the programs related to this in R, I represented the discretized version of the function in simulation as:
which is more or less both the same as above and also the first half of this value function below from Yaari '65 except it's not in continuous form because I am simulating year by year and I dropped the bequest term which Professor Milevsky once told me to "just skip it." - I have a comprehensive summary of previous work in this area along with the academic references in this post "A WDT [wealth depletion time] Model.
Output Example (when the prompt actually works)
This series of posts is definitely the most useful writing on retirement finance I saw on the internet ever. And complex, takes a lot of effort for me to comprehend and study everything you mention, your sources. LLM or not, it's also a good digest of your blog. Thank you!
ReplyDeleteThanks. I actually appreciate that. Two more prompts to go... I am trying to give away for free the "nub" of every fun amateur thing I learned over 15 years. At 67 I kinda want to walk away from all of this but also punctuate the effort with a decent end. I probably should have tried to monetize some of this but I don't care about that now. And anyway, I don't really use this stuff irl
ReplyDeleteDon't really use it IRL either, counting on simpler strategies, basically just lower withdrawal rates and somewhat dynamic spending. It's just fascinates me and gives the motivation to study and think more, which is generally useful... I guess =)
Delete