I am trying to use pchip (Piecewise Cubic Hermite Interpolating Polynomial) function in R to expand abridged life table to complete one aged 5 to 89. I took 1-(1-5qx)^(1/5) as the initial value of death probability for a given age group(x+2.5) and interpolate death probabilities for each single year of age 1qx using pchip function. And then recalculated 5qx' through interpolated 1qx and compared them with original 5qx to see whether the difference between them is less than the specified tolerance(10E-6). Of course, in the first calculation, the specified tolerance cannot be met, therefore it needs iteration. So my problem is: how to update the initial value to conduct latter iteration?

I've tried several methods such as replacing 5qx by 5qx' directly and dichotomy iteration, but they did not work and the results did not show convergence.

library(pracma)
x<-c(seq(5,89,5))
qx<-data.frame(age=x,qx=0)
qx$qx<-c(0.004932256,0.003830182,0.005361885,0.007037384,
0.008048729,0.009432151,0.012446146,0.018325698,0.028762825,0.046290573,
0.074888731,0.120306557,0.190086799,0.291948621,0.429340330,0.593503019,
0.752210246)
qx_inti<-data.frame(age=seq(7.5,87.5,5),qx=0) ## initial value
qx_com<-data.frame(age=seq(5,89,1),qx=0)## store interpolated 1qx

## store the recalculated 5qx' by interpolated 1qx
qx_abr<-data.frame(age=seq(5,85,5),qx=0)

for (i in 1:nrow(qx_inti)){
  qx_inti$qx[i]=1-(1-qx$qx[i])^(1/5)
}

repeat {

  fp<-pchipfun(xi=qx_inti$age,yi=qx_inti$qx)
  qx_com$qx<-fp(seq(5,89,1))
  qx_com$px=1-qx_com$qx
  for (i in 1:nrow(qx_abr)){
    product=1
    for (j in (5*i-4):(5*i)){
      product=product*qx_com$px[j]
    }
    qx_abr$qx[i]=1-product 
  }
  if (max(abs(qx_abr$qx-qx$qx))<10e-6){
    break
  }
  ##updating qx_inti is needed
}

I expect the detailed method of updating initial value in order to meet the specified tolerance.

0 Answers