Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error returned when forecasting fdm object that was fitted with method = "M" #55

Open
zjyap88 opened this issue Aug 31, 2023 · 1 comment

Comments

@zjyap88
Copy link

zjyap88 commented Aug 31, 2023

Hello,
I encountered an error when I tried to forecast an fdm object with Japan mortality rates.

The code:

jpn <- hmd.mx("JPN", "username", "password", "Japan")
jpn2 <- extract.years(jpn, 1947:2004)
jpn2 <- extract.ages(jpn2, 0:100, combine.upper = TRUE)
fit <- fdm(jpn2, series = "total", method = "M")
fcast <- forecast(fit, 11)

which would return
Error in fitted[, i] <- fitted(barima) :
number of items to replace is not a multiple of replacement length

The same error was also encountered when using mortality rates of Austria, Belgium, Bulgaria, Hungary, Ireland and Spain that were cleaned or transformed to avoid 0 and NA values.
However, I did not receive an error when using mortality rates of Australia, Italy, France and Scotland.

Any help to address these inconsistencies would be much appreciated. Thank you in advance.

@robjhyndman
Copy link
Owner

This appears to be a problem in ftsa::forecast.ftsm() rather than the demography package. Some weights are set to zero (due to you using method="M"), but then the ftsa package ignores that when computing fitted values. So the problem needs to be solved by the maintainer of the ftsa package. I will alert him.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants