I am having some trouble modeling finance ODEs. I'm solid on investment interest problems if the given time units match, but if they don’t, it’s not clear within what groupings the various references to time must be made consistent. In a problem $P’ = rP + D$ or $P’ = rP – W$, where $P$ is the balance at time $t$, $r$ is the continuously compounded interest rate, and $D$ or $W$ are, respectively, deposits or withdrawals, the references to time I see are
1) units of $P’$ (\$ per ____),
2) units of $r$ (% per ____), but since the associated homogeneous equation $P’ = rP$ is really a special limiting case of the difference equation $P(n + 1) = (1 + \frac{I}{m})P(n)$, where $I$ is the discretely compounded interest rate with frequency $m$, we implicitly pick up
$\ \ \ \ $2a) units of $I$ (% per _____),
$\ \ \ \ $2b) units of $m$ (times compounded per ____), and
$\ \ \ \ $2c) units of $n$ (what is the duration between $n$ and $n + 1$?),
3) units of D or W (\$ per ____), and
4) units of t (what is the duration between $t = 0$ and $t = 1$?).
My first promising observation was that the ODE just expresses the combined effects of two individually contributing time evolutions, the associated homogeneous equation, which contributes the interest term $rP$, and the pure-time equation $P’ = D$ or $P’ = W$, where $D$ or $W$ are usually constant but could explicitly depend on $t$, which contributes the forcing term. It thus seems reasonable to expect the interest term and forcing term to be evolving against two independent clocks (i.e., deposits needn’t be made at the same frequency as the account’s compounding period). However, both clocks must somehow remain in sync with the LHS term $P’$, so it’s not clear that this is how the timings should ultimately be grouped.
My other issue is figuring out which variables in the ODE and underlying difference equation should undergo sign changes when switching from an investment interest problem to a loan interest problem (my book explains the former and sneaks in the latter as exercises) or other problem of the sort these two exemplify. My initial thought was to construct a timeline showing each transfer of value between the subject named in a problem, and their counterparty, but this works better for a loan than, i.e., a bank account, since intuitively speaking, the subject doesn’t lose ownership of funds deposited into a bank. Furthermore, this only seems to capture the evolution contributed by the forcing term, since interest doesn’t involve value transfer in the same sense. How can I generalize the algorithm for investment interest to work for loans and other problems of the sort?