I'm doing a finance project for my differential equations class to explore stochastic processes. I'm exploring IRA retirement funds.
From the project write-up:
Standing assumption: at time of retirement, you have 500 thousand dollars invested in an IRA retirement account, from which you will withdraw 40 thousand dollars per year until the account is exhausted—call this length of time the lifetime of the account.
Question 1: Assume the IRA pays (continuously) at a risk-free annual interest rate of 4%. In this case, the balance B is described by the IVP:
B’ = .04*B – 40, B(0) = 500
Easy to solve but I've included it so that those who answer know the context of the project and are financially-savvy. The next part involves the stochastic process:
Adding randomness: For remaining questions, we will assume the interest rate is not constant over time, but has some randomness built in. The simplest approach is to say that the annual interest rate is given by:
r = .04 + v*dW(t)
where dW(t) is the (standard) Wiener process (i.e., Brownian motion) and v is a measure of the volatility. (In effect, this makes the interest rate follow a Brownian motion path, wandering around 4%. The larger the volatility, the faster it wanders.) Thus the IRA’s balance is described by a stochastic Ito equation saying
dB = (.04 + v*dW(t))*B – 40, B(0) = 500
In Mathematica, I've described this equation as proc1. The WienerProcess[0, 0.25] implies 0 drift and 25% volatility.
proc1 = ItoProcess[\[DifferentialD]B[t] == (.04*B[t] - 40) \[DifferentialD]t +
.04*B[t]*\[DifferentialD]w[t], B[t], {B, 500}, t, w \[Distributed] WienerProcess[0, 0.25]]
data1 = RandomFunction[proc1, {0., 20., 0.01}, 50]
data1 is the RandomFunction using proc1 as its process with from 0 to 20, applying the process at every 0.01 step. It does this to generate 50 "walks" and returns the TemporalData[] structure associated with this RandomFunction
I've never seen TemporalData[] before and what I've seen in the Function Navigator hasn't been helpful to me.
What I'm trying to do:
Determine the total number of "paths" with "state" > 0 at "time" == targetLife or, can also determine the total number of "paths" with "state" < 0 at "time" == targetLife
So far, I've been working on the single element case:
state = Table[Last[data1["Path"][[i]], {i, 1, Length[data1["Path"]-1]}]
lifetime = Length[TakeWhile[state, # > 0&]]-1
I subtract 1 from lifetime to account for the initial condition.
It seems to work, but I can't seem to extend it to cover all paths. Any help with this would be greatly appreciated.
Thanks in advance!