venta: (Default)
[personal profile] venta
So, sums. I can, broadly speaking, do sums. I have a degree in maths.

However, interest rate calculations have always baffled me. Sure, if you ask me to calculate 3 months compound interest at a monthly rate of x% I know what to do. However, when it comes to real examples of mortgages and credit cards, I can't work out what the sum I need to do is. I'm still slightly baffled about the interest charged me when I was a day late paying my credit card off in full in March.

Today, the BBC carried a story about a loanshark. It includes the following statement about someone who borrowed £1000:

"...to pay £49 a week over 60 weeks, making the total amount he had to
repay £2,940 at 917% APR."

Now, if we approximate 60 weeks to a year, then surely that's an annual interest rate of no more than 294%. The quoted APR isn't even in vaguely the right ballpark.

So... have I completely failed to understand APR ? (Wikipedia's page on the subject didn't really help with the definition.) Or is the BBC publishing unmitigated wank in the name of investigative journalism ?

Edit It turns out I'd failed to understand APR, and the BBC is cleared in this instance.

Date: 2008-07-29 10:08 am (UTC)
From: [identity profile] undyingking.livejournal.com
They're exactly right, according to this calculator.

Either that; or they also used that calculator, and it and they are both exactly wrong.

I think the trouble is that APR can be a bit of a misleading figure.

Date: 2008-07-29 10:16 am (UTC)
From: [identity profile] venta.livejournal.com
I wish I knew what sum that calculator was doing. In line with other comments above (suggesting my approach was too naive), I can believe the APR is much higher than expected. I still have no idea how to work it out, though :(

Date: 2008-07-29 10:23 am (UTC)
From: [identity profile] undyingking.livejournal.com
It's written in a JS in the page itself, so you can have a peek. The gist of the calc is:

function CalcRate() {

  var p=getVal(document.input.credit.value);
  var i=getVal(document.input.initial.value);
  var a=getVal(document.input.repay.value);
  var n=Math.floor(getVal(document.input.number.value));
  var f=getVal(document.input.last.value);
  
  //Isaac's magic ...
  var x=1.0001; var fx=0; var dx=0; var z=0;
  do {
    fx=i+a*(Math.pow(x,n+1)-x)/(x-1)+f*Math.pow(x,n)-p;
    dx=a*(n*Math.pow(x,n+1)-(n+1)*Math.pow(x,n)+1)/Math.pow(x-1,2)+n*f*Math.pow(x,n-1);
    z=fx/dx; x=x-z;
    //alert("fx="+fx+"\ndx="+dx+"\nz="+z+"\nx="+x)
    }
    while (Math.abs(z)>1e-9);
  r=100*(Math.pow(1/x,m)-1);
  
  document.input.credit.value=TwoDP(p);
  document.input.initial.value=TwoDP(i);
  document.input.repay.value=TwoDP(a);
  document.input.number.value=n;
  document.input.last.value=TwoDP(f);
  document.input.apr.value=OneDP(r);
}


Of course it'll take a certain amount of being bothered to peer at taht and see what it's actually doing, JS not being the most transparent of languages...

Date: 2008-07-29 10:34 am (UTC)
fluffymark: (Default)
From: [personal profile] fluffymark
Looks like a Newton-Raphson method.

The iteration is just trying to find the value of x so that p=a*(x^(n+1)-x) (p is the amount borrowed, a is the repayment amount, n is the number of repayments)

Then the APR is calculated by APR=100*((x^(-m))-1), where m is the number of repayments per year.

Date: 2008-07-29 10:37 am (UTC)
From: [identity profile] undyingking.livejournal.com
There you go, I gave up in disgust too early ;-)

Date: 2008-07-29 10:48 am (UTC)
chrisvenus: (Default)
From: [personal profile] chrisvenus
I probably should have known that. My approximation methods teachings that I did at first year of uni are slowly coming back to me now... :)

Date: 2008-07-29 11:16 am (UTC)
From: [identity profile] venta.livejournal.com
You win a coconut :)

Date: 2008-07-29 11:46 am (UTC)
From: [identity profile] venta.livejournal.com
Just for pedantry (and because I got confused, because I don't know Javascript), did you mean:

p = a*(x ^(n+1) - x)/(x-1)

?

... though where that equation came from is still beyond me. I appreciate it leads to the right answer, but how it was written down (and what concept x represents) is a bit of a mystery.

Date: 2008-07-29 12:09 pm (UTC)
fluffymark: (Default)
From: [personal profile] fluffymark
Yes, I spotted that error soon after posting. Have your coconut back! :)

The expression is the sum of a geometric progression, as one would expect from compound interest

Specifically:
if n=1 then p = a*x
if n=2 then p = a*(x+x^2)
if n=3 then p = a*(x+x^2+x^3) and so on ...

And even than I'm still getting my head around what concept x represents.

Date: 2008-07-29 12:12 pm (UTC)
From: [identity profile] venta.livejournal.com
I just found ChrisVenus' post below (http://venta.livejournal.com/279549.html?thread=3943165#t3943165) quite useful in establishing where the formula came from... thought it doesn't help with the mystery x :)

Date: 2008-07-29 03:44 pm (UTC)
chrisvenus: (Default)
From: [personal profile] chrisvenus
Its quite hard to work out what has been answered where with theis many comments but in case you dont' already know x is 1/interest. I'm not sure why they were using that but I guess they liked the way the formulae came out more in doing so.

Date: 2008-07-29 04:19 pm (UTC)
From: [identity profile] venta.livejournal.com
Yes, I know it's the reciprocal of interest. However, that's not really a "concept" to me. It could be that, in those terms, it doesn't represent anything concrete. I find such things easier to understand when I know what the sums are meant to show, though :)

And yes - I wish LJ provided a 'display all' button for long threads, to allow me to choose to take the hit of rendering everything on the same page for clarity.

Date: 2008-07-29 04:33 pm (UTC)
From: [identity profile] undyingking.livejournal.com
IIRC there's at least one GreaseMonkey script that adds an "Unfold All" button to LJ comment pages. But also IIRC it was buggy last time I used it.

The LJ Addons extension includes links to unfold thread by thread without having to reload the page, if that's any help...

Date: 2008-07-29 04:39 pm (UTC)
chrisvenus: (Default)
From: [personal profile] chrisvenus
I have no LJ Addons extension and I get links to "expand" next to individual hidden comments and at the end of the last visible comment in a tree that does the "Expand all under this" behaviour (all AJAX of course rather than show in new tab or anything useless like that). This is with a fairly default view though so it may be that external addons are required for other styles or something... It does make life much easier than it used to be but more than anything my comment was aimed at the fact I couldn't be bothered to find the few newer comments. Though having said that the collapsed view does make that easier if you know what time you last checked roughly since you cna go and expand just the newer ones...

Date: 2008-07-29 07:59 pm (UTC)
From: [identity profile] undyingking.livejournal.com
Ah, maybe I was misattributing the expand feature. Well, LJ Addons definitely includes a button that displays the comments in chronological order of posting rather than in thread order, so you can easily see the new ones ;-0

Date: 2008-08-01 03:38 pm (UTC)
From: [identity profile] imc.livejournal.com
Greasemonkey! (http://imc.livejournal.com/182062.html?style=mine)

Oh, and comments in chronological order can be accessed without the browser addon by tacking "?view=flat" on to the URL, but I usually find the lack of context for each comment in this mode makes it very difficult to read.

(Here because I seem to have coincidentally asked the same question (http://imc.livejournal.com/185389.html?style=mine) on my journal and was directed to this thread. And my UK mobile number is 7 times a prime while my home number is 2*3*5 times a prime.)

Date: 2008-08-01 03:49 pm (UTC)
From: [identity profile] undyingking.livejournal.com
Excellent, thanks for the new script -- looking at the ones I'd tried, I'd given up after Henrik's stopped working. I shall give yours a go now and report if any probs!

(Do I know you, btw? -- you seem to know several of my friends, and to have been around Oxford while I was there.)

Date: 2008-08-04 09:44 am (UTC)
From: [identity profile] imc.livejournal.com
I don't think I actually know who you are, but you appear a lot in [livejournal.com profile] jiggery_pokery's journal. :-)  (and despite [livejournal.com profile] venta being a former Oxford mathematician I don't think I know her either). I was a long-standing member of the Invariant Society and veteran of ox.net.

Date: 2008-07-29 04:41 pm (UTC)
chrisvenus: (Default)
From: [personal profile] chrisvenus
ah. I don't think it has any more meaning than being one over interest. I suspect that they just ended up with lots of terms of "1/interest" and simplified by substituting x for that.

Or its possibly somethign to do with the approximation method only working if the solution is between 0 and 1 or something maybe... I'm pretty sure its a pure mathematical construct rather than anything with a real world equivalent though.

Date: 2008-07-29 07:32 pm (UTC)
From: [identity profile] drdoug.livejournal.com
1/interest

You could call it something pithy like "indifference", "apathy" or "incuriosity" :-)

Date: 2008-08-04 09:33 am (UTC)
From: [identity profile] imc.livejournal.com
x is 1/(1+i), where i is interest. So it represents the depreciation of your capital due to interest: xc is the amount of money you must have borrowed last week if c is the amount of money you owe this week.

My working is as follows. There is a recurrence relation relating the amount you owe this week after a repayment to the amount you owed last week:

cn+1 = cn(1+i) – r

Eliminating the recursion gives this:

cn = c0(1+i)nr(1+i)n-1 – … – r(1+i) – r

where the right-hand side is a geometric series which can be simplified thusly:

cn = c0(1+i)nr((1+i)n–1)/i .

So the repayment r in terms of the initial amount of credit c and interest rate (per week) i is:

r = cik/(k–1) where k = (1+i)n .

Now presumably they've done their recurrence relation the other way about and ended up with

c = rx(xn–1)/(x–1) where x = 1/(1+i)

but the two formulae are equivalent, it turns out.

Date: 2008-07-29 10:39 am (UTC)
chrisvenus: (Default)
From: [personal profile] chrisvenus
Yeah, I'm struggling with that too... you can simplify by setting i and f to 0 which knocks out a few terms and makes the while loop:


do {
fx=a*(Math.pow(x,n+1)-x)/(x-1)-p;
dx=a*(n*Math.pow(x,n+1)-(n+1)*Math.pow(x,n)+1)/Math.pow(x-1,2);
z=fx/dx; x=x-z;
//alert("fx="+fx+"\ndx="+dx+"\nz="+z+"\nx="+x)
}
while (Math.abs(z)>1e-9);
r=100*(Math.pow(1/x,m)-1);


And then the last line of that basically implies to me that x = 1/weekly interest rate.

I think they are then using some kind of iterative process of approximations to find a value of x whcih satisfies the equations. It stops when z is very close to 0 which means that fx must be much much smaller than dx.

I suspect dx is worked out in some clever way. It looks vaguely like a differential and I suspect if I'd done more computer programming I'd recognise some technique of using differentials to get closer to an approximation of something...

The initial value fx basically has two terms the p on the end and the other bit. The first bit is basically decaying your repayments to simulate interest. You should note that Math.pow(x,n+1)-x)/(x-1) is a power series that can be expanded to x^n+x^(n-1)+...+x^2+x. When multiplied by a this is your repayments decaying by the interest rate. Personally I find it easier to see when you divide through by x^n and set interest = 1/x since you will then see the more intuitive series of each repayment having interest applied to it and them adding up to the total loan amount with interest added.

I've worked out now also that my discrepancy came purely from taking the first repayment off before applying interest. If I always apply interest before repayment then I get the same 917% that the BBC quote (I should also mention that in my inintial comment above I forgot to take the 100% off for the initial loan amount).

Date: 2008-07-29 11:01 am (UTC)
From: [identity profile] hughe.livejournal.com
yup that is right. i stand corrected. the apr is more symbolic of the value of the loan than just a percentage of the interest to the innitial loan amount.

Though i'm still trying to work out how they are calculating it...
  x = 1.0001
  z = 0
  do {
    fx = ( 49 * (x61 - x) / (x - 1) ) - 1000;
    dx = 49 * (60x61 - 61x60 + 1) / (x - 1)2
    z = fx / dx
    x = x - z
  }
  while (ABS(z) > 0.000000001)

  rate = 100 * ( (1 / x)52 - 1)


ok yeh i kind of see what they are getting at now. so it is usefull for working out which is the best rate of equivilant loans, but useless at a metric for actually working out cashflow or anything.

as far as cashflow goes the amount payed back is about 3 times that leant, over 14 months (200% or so intrest) but like a mortgage, at the start your repayments are mainly paying interest, and as time goes on more of your repayment goes on paying back the loan instead of interest. so i supose its a way to takee this into account too. ?
Edited Date: 2008-07-29 11:19 am (UTC)

Date: 2008-07-29 11:48 am (UTC)
From: [identity profile] venta.livejournal.com
Phew. I'm glad someone else worked dx out. It appears I can't differentiate any more.

Profile

venta: (Default)
venta

December 2025

S M T W T F S
 123456
78910111213
14151617181920
212223 24252627
28293031   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Dec. 27th, 2025 02:21 am
Powered by Dreamwidth Studios