Closed Wilsonnn245 closed 1 year ago
You probably want to use jumpchoice = "actual"
in forecast()
. There are several variations on the Lee-Carter method, and the function tries to handle them all via the arguments.
Yup, I already tried changing to jumpchoice = "actual"
but it would still generate the same results as when I used jumpchoice = "fit"
.
Right, what is stored in the forecast object is an adjusted version of kt, with the last value subtracted. This makes the code simpler. It makes no difference to the final mx forecasts. If you want the forecasted kt values to match the fitted kt values, just add on the value at the end:
kt.f <- forecastItalyFemale$kt.f
last_kt <- c(tail(ItalylcaFemale$kt,1))
kt.f$x <- ItalylcaFemale$kt
kt.f$mean <- kt.f$mean + last_kt
kt.f$lower <- kt.f$lower + last_kt
kt.f$upper <- kt.f$upper + last_kt
plot(kt.f)
It works perfectly now, appreciate your help!
I've also had another issue using the FDM model in 'demography' package. I've tried to simulate the results and compare it with a past research. When I plot the basis functions, the shape of the graphs are similar but the scaling is off.
Reference:
Simulated Results:
R Code:
Is there something that I would have to amend? Or the scaling would not be a huge issue as long as the shape is similar? Thanks in advance!
The scale factors are arbitrary -- if you multiply the basis function by k and divide the coefficient by k, you get the same result. For this reason, the basis functions are usually normalized in some way. Perhaps the normalization being used is different in the reference to the current version of the package.
I see, that's great! Thanks for all the help and guidance Rob, really appreciate it <3
Hi, I'm facing an issue when forecasting mortality data using Lee-Carter. This is the R code I used:
This is the re-adjusted kt output:
Thus, I would expect the forecast kt at year 2001 to be around -15. However, the generated value is -0.55:
After doing some digging, I found that the forecast function changed my re-adjusted kt value:
I'm not sure what went wrong since the ax and bx values are unaffected. Would appreciate on any advice to get the expected forecast kt value. Thanks!