Updated 13/03/2018

See end for effect use of different historic period for setting CPI expectations.

Original

You can find the repo for this markdown here. Please feel free to fork and PR.

Richard Wilkinson has done a rough and ready calculation of what the proposed USS pension deal of 12/03/2018 would mean in terms of the absolute maximum possible pension. His calculations can be found here. The long and the short of it is that he finds that if someone were to come in at the max pensionable salary and stay there for 40 years the max pension they could get would be:

(base <- 42000 * 40/85)
[1] 19764.71

Now this ignores that fact that many of us don’t get pensionable job until 30 years before retirement, and we don’t generally start on £42k (the max DB salary), but still, we are talking upper bounds here.

So this number does not look like the end of the world. But the problem is inflation - while £19,765 might sound okay now, what will it be worth in 40 years time? The new proposal suggests that inflation link revaluation will be capped at 2.5%. Rich Wilkinson calculation what this would mean for pensions if CPI did the same for the next 40 years as it has done for the last.

cpi <- read.table("british_cpi.tsv.csv", header=T, stringsAsFactors = F)
cpi$CPI = as.numeric(sub("%","",cpi$CPI))
truncated_cpi <- sapply(cpi$CPI,function(x)min(x,2.5))
actual_pension_new_scheme <- base*prod(truncated_cpi/100+1)
inflation_adjusted_pension <- base*prod(cpi$CPI/100+1)
(real_terms_pension_new_scheme <- actual_pension_new_scheme/prod(cpi$CPI/100+1))
[1] 9920.738

You can download the CPI figures here. As with Richard Wilkinson’s nubmers they come from here, via some excel wrangling.

So adjusting for inflation, the maximum possible defined benefit is £%#4.0-1e. This is much less good!! But how does it compare to the current scheme?

Well in the current scheme, the pension is re-evaluated at the “official pension re-evaluation rate” used by government schemes. This boils down to CPI matching up to 5%, then half the increase up to 10%, then fixed. How does this play out? First lets calculate the effective CPIs under this scheme:

revalue <- function(cpi) {
  if (cpi < 5) return (cpi)
  if (cpi < 15) {
    return (5 + 0.5*(cpi-5))}
  else {
    return (10)
  }
}

(effective_cpi_offical <- sapply(cpi$CPI, revalue))

These are very nearly the the real CPI values. Only in a few years did the CPI exceed 5%. Okay, lets assume our very luck new starter starts on 42k, but then never gets a pay increase. This seems like the fairest way to match the estimate above. What would their final defined benefit be worth in today’s terms?

Now under the old scheme, we accrued 75ths rather than 85ths. So the base pension is slightly different:

(old_base <- 42000 * 40/75)
[1] 22400

That’s a difference from £19,765 under the proposed system, but not a ruinous one. The real kicker is when we calculate the effective value in today’s money:

actual_pension_old_scheme <- old_base*prod(effective_cpi_offical/100+1)
inflation_adjusted_pension <- old_base*prod(cpi$CPI/100+1)
(real_terms_pension_old <- actual_pension_old_scheme/prod(cpi$CPI/100+1))
[1] 18638.72

So under the old inflation adjustment scheme the real terms value of this person would have been £18,639 rather than £9,921 under the new scheme.

This of course isn’t fair because no one comes in with a salary of £42,000 and then stays there for a whole 40 years. And over the 42k cap they’d be contributing to a DC pot, but it does show you how big an effect this 2.5% CPI cap has. Stay tuned for an update modelling a more realistic spine progression and including the DC pot.

Was the last 40 years an unfair period?

It has been pointed out to me that using the last 40 years to model the effects of inflation might be an unfair period to use becuase of 1) out of the ordinary spikes in inflation in the late 70s and early 80s that are unlikely to be repeated, not least because 2) in 1992 we adopted a 2% inflation target.

Okay, what does this mean? What has CPI done in the last 40 years?

library(ggplot2)
ggplot(cpi, aes(Year, CPI)) + geom_point() + geom_smooth() + theme_bw()

Okay, so the late 70s and early 80s really do look like a different world, and since ’92, the 2% target has quite a good job of limiting inflation, with the exception of the time immediataely after the ’08 crash. The realy question is whether the blip around ’90 is part of the old regieme or the new. The peak might look big, but once the trend is removed, is it really much bigger than the the 2011 peak?

What would make a more reasonable estimation of the effect of CPI. In the following I am going to use the following plan. I will build a predicted future inflation by randomly sampling inflation from the post-92 years 40 times (lets remember that 95-2008 was a period of almost unrivaled prosperity, so this is pretty generous). I’ll do this 100 times and build up a picture of the possible futures. we can also include 88-92 to see what difference that makes.

The UUK side seem to be valuing their risk based on a 67% confidence. What happens if we do the same?

library(dplyr)
simulated_futures %>%
  group_by(scheme, historic_period) %>%
  summarise(Prudence_estimate=quantile(samples, 0.33)) %>%
  mutate(Prudence_estimate=scales::dollar_format(prefix="£")(Prudence_estimate))
ABCDEFGHIJ0123456789
scheme
<fctr>
historic_period
<fctr>
Prudence_estimate
<chr>
proposed'92 and after£17,670.44
proposed'89 and after£14,875.70
proposed'08 and after£16,352.04
current'92 and after£22,400.00
current'89 and after£21,618.71
current'08 and after£22,400.00

The first thing to say is that this definately looks better than the above estimate using data from the last 40 years. But we are still looking at a £4.7-£6.7k per year loss. The second thing to say is that what inflation does really matters. Was 89-92 part of the old world order or was 1995-2008 a never to be repeated golden period? Is the post crash world the new normal? Or does the fact its “post-crash” make it an abnormal anomoly to be ignored?

I suppose this is what we mean by “risk”. This is a proposal to “share” risk between the employers and USS memebers. How much risk is transferred from employers to members under this scheme? I have no idea how to calculate this properly, but I’m going to have a go a reasoning this through a bit. Please someone tell me I’m wrong.

USS claim to have a £7.5bn deficit under the “de-risked” current scheme, with 350,000 members, thats a per-member deficit of £21,429. If you only include the 190,000 actively contriubting members, thats £39,473 each. They calculate this using a 67% prudence, and if we do the same with the new scheme, we find a range of losses, from £4.7k-£6.7k. Let us take the lowest figure, £4.7k. Someone with 40 years still to constribute would be 28 now, would retire at 68, and would expect to live another 19 years. So the loss to that person over those 19 years would be £89,300 (real terms), far more than the £21,429 deficit, and more than twice £39,473.

Same caveats apply: this is only considering the DB part of the scheme, and not what additional DC contributions might bring - its not a full pension modeller, although it would be nice to see these CPI simulations added to the existing pension modeller. Real people also start on less than £42k. Oh, and I could be getting it all wrong!

LS0tCnRpdGxlOiAiQ29tcGFyaXNvbiBvZiBvbGQgVVNTIHBlbnNpb25zIHRvIG5ldyBwcm9wb3NhbCIKb3V0cHV0OiBodG1sX25vdGVib29rCmF1dGhvcjogSWFuIFN1ZGJlcnkKZGF0ZTogMTIvMDMvMjAxOAotLS0KCiMjIFVwZGF0ZWQgMTMvMDMvMjAxOAoKU2VlIGVuZCBmb3IgZWZmZWN0IHVzZSBvZiBkaWZmZXJlbnQgaGlzdG9yaWMgcGVyaW9kIGZvciBzZXR0aW5nIENQSSBleHBlY3RhdGlvbnMuCgojIyBPcmlnaW5hbAoKWW91IGNhbiBmaW5kIHRoZSByZXBv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