library(tidyverse)
library(datapasta)
library(prophet)
library(lubridate)
I pasted the data from a document downloaded from FAO:
For modelling the baseline, I use Facebook’s prophet package.
# prep data for prophet
df_prophet <- df %>%
select(ds = month, y = real_fpi)
# fit model
m <- prophet(df_prophet)
## Disabling weekly seasonality. Run prophet with weekly.seasonality=TRUE to override this.
## Disabling daily seasonality. Run prophet with daily.seasonality=TRUE to override this.
# generate forecasts
future <- make_future_dataframe(m, periods = 16, freq = "month")
fcst <- predict(m, future)
# plot historical and forecasted data
plot(m, fcst)
# plot model components
prophet_plot_components(m, fcst)
fcst %>%
filter(ds >= "2023-01-01") %>%
summarise(avg_lower_yhat = mean(yhat_lower),
avg_yhat = mean(yhat),
avg_upper_yhat = mean(yhat_upper))
## avg_lower_yhat avg_yhat avg_upper_yhat
## 1 105.2482 118.1067 130.9655
For 2023, the prediciton lies between 105 and 131. I compute the R^2 value next.
performance_df <- df_prophet %>% left_join(fcst %>% select(ds, yhat))
## Joining, by = "ds"
cor(performance_df$y, performance_df$yhat)^2
## [1] 0.7056875
70 % of the variation is explained by the model.
Inside view:
Given these, I’d place my bets on the upper bound of the forecast. The model also tends to underestimate sharp FPI increases, so my starting point would be 131. Importantly, further developments (related the war in Ukraine) should inform whether such a sharp increase in FPI is likely to happen in 2023 also.