## Power function - problem with units

Use this forum to post Vensim related questions.
kaveh.dianati
Member
Posts: 23
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

### Power function - problem with units

Hi Tom/colleagues,

I am developing a small mortgage amortization model and I keep getting a unit error regarding the formulation of the mortgage repayment variable. My small model is attached, where I am using the following formula for calculating "monthly mortgage repayments":

M = P [r * (1+r)^n / ((1+r)^n - 1)]

Where P is the principal, r is monthly interest rate, and n is number of payments. The unit of time in my model is years.

The unit error that I get says that the "Mantissa of ^ must be dimensionless". However, (1+r) can't be dimensionless as I see it because r is monthly interest rate (dmnl/month). How would you suggest to fix/go around this problem?

Also, I have another (perhaps silly) conceptual question, where you might be able to help. I'm slightly confused which variable to assume as P (principal) in the above formula. Would that be the stock of "total mortgage debt"? But this stock has an inflow of interest as well, so it wouldn't constitute just the "principal". Or should I take the inflow of "new mortgages"? This might be the correct way to do it, but I feel slightly unsure to use the flow as an input here.

If you know of a model/paper with a similar stock & flow model of debt it would be great if you could kindly point me to it.

Kaveh.
Attachments
Housing debt structure.mdl

Posts: 3384
Joined: Wed Mar 05, 2003 3:10 am

### Re: Power function - problem with units

First, I'd charge the interest on the total outstanding debt (that's certainly what my bank does for my mortgage).

For units, in this case, I'd create a "unit month" to get the units to balance.

UNIT MONTH = INITIAL ( 1 )
Units : Month

monthly mortgage repayments =
total stock of mortgage debt
* average monthly mortgage interest rate
* ( 1 + average monthly mortgage interest rate * unit month) ^ average number of mortgage repayments
/ ( ( 1 + average monthly mortgage interest rate * unit month ) ^ average number of mortgage repayments - 1 )
http://www.ventanasystems.co.uk/forum/v ... f=2&t=4391

Units are important!
http://www.bbc.co.uk/news/magazine-27509559

tomfid
Posts: 2776
Joined: Wed May 24, 2006 4:54 am

### Re: Power function - problem with units

The problem is that the typical discrete formulation of interest and amortization functions is dimensionally inconsistent, unless you're careful about using dimensionless time periods. As a simple example, consider:

discount = (1 + rate)^nPeriods

If you directly plug in interest rate = 6%/year and term= 20 years, this is dimensionally inconsistent.

What you have to do is adjust by the number of payment periods to get dimensionless quantities:

rate = (rate per time)/(periods per time), which would be 0.5% (.005) if there are 12 payments per year.
nPeriods = (term)/(periods per time) = 240

Then you can plug in these dimensionless quantities and it all works.

If you don't have to match accounting exactly, it's much easier to use the continuous time versions. For example:
discount = EXP( -rate*time )

kaveh.dianati
Member
Posts: 23
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

### Re: Power function - problem with units

Thank you both very much for your replies!

I hadn't thought of continuous compounding which neatly resolves the unit inconsistency problem. Just to check I am implementing it correctly, the formula for mortgage repayments would then be: principal * (r/(1-EXP(-rt))). Is that right?

And if I may follow up also on my second question, for calculating interest I will definitely multiply the rate with the stock, because that's how it is done. But my question was about calculating the monthly repayments (above). In place of the 'principal', would you put the stock of debt, or the inflow of new loans? (Because the stock is now 'contaminated' with interest as well, and is therefore not the same thing as principal anymore..?)

Thanks again!
Kaveh.

kaveh.dianati
Member
Posts: 23
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

### Re: Power function - problem with units

Hello,

I wonder if I could ask this question once more:

Thinking about formulating mortgage repayments, my model is at an aggregate level for the city of London, and I don't need to match any exact accounting data. However, I am still unsure whether I should formulate mortgage repayments like this:

repayments = principal * (r/(1-EXP(-rt)))

The reason I am unsure is that in this way the stock never completely depletes. In other words, at the end of the mortgage period, about 10% of the principal is still left in the stock. This is of course natural when you make the outflow dependent on the stock..

(I never expected formulating a simple debt structure to be so tricky!)

Many thanks,
Kaveh.

kaveh.dianati
Member
Posts: 23
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

### Re: Power function - problem with units

..In other words, in formulas for monthly mortgage repayments what is multiplied by the discounting coefficient is P (the principal). However, modelling it in SD, if we use the "Stock of outstanding debt" instead of P, this means that payments get smaller over time as the stock gets depleted, which means that it would never reach zero.

I wonder how big of an issue this inconsistency is at an aggregate scale and over many years..

tomfid
Posts: 2776
Joined: Wed May 24, 2006 4:54 am

### Re: Power function - problem with units

You're correct - the aggregate SD approach with continuous payments and infinite horizon never fully repays the loan.

There are alternatives. One is to maintain more states for the loan. For example, the principal plus the term remaining. Then you can work out the remaining level payment at any point. You just have to be a little careful at the last time step because accumulated roundoff may make the last payment imperfect. Another possibility would be to run the level payment through a pipeline delay like DELAY FIXED.

Generally these approaches won't work well for many loans with diverse parameters, though the DELAY approach might be OK if you disaggregate by term.

My first instinct is that this stuff doesn't really matter, and an aggregate treatment is fine, but sometimes that's not true.

kaveh.dianati
Member
Posts: 23
Joined: Tue Dec 15, 2015 1:52 pm
Vensim version: DSS

### Re: Power function - problem with units

Hi Tom,
Thanks very much for your response. I agree with your instinct - I played around with it a bit, and using the continuous exponential discounting you suggested, the simulation replicates data sufficiently well.

Just as a final follow-up, do you know of any references to cite off the top of your head for using the continuous discounting formula?

Many thanks,
Kaveh.