[This article was first published on DataGeeek, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.Fitch projects a decline of about 30% in gold in 2026. Easing the trade war and the Israel-Iran conflict may support this idea. We will project how the prices could go by the end of the year.We will use the modeltime.resample package for forecasting modeling.library(tidymodels)library(modeltime)library(modeltime.resample)library(tidyverse)library(tidyquant)library(timetk)#Gold Futuresdf_gold % select(date, close) %>% drop_na()#Make a Cross-Validation Training Planresamples_tscv % tk_time_series_cv_plan() %>% plot_time_series_cv_plan(date, close, .facet_ncol = 2, .interactive = FALSE)#Model 1: auto_arimamodel_arima % set_engine(engine = "auto_arima") %>% fit(close ~ date, data = df_gold)#Model 2: prophetmodel_prophet % set_engine(engine = "prophet") %>% fit(close ~ date, data = df_gold)#Model 3: glmnetmodel_glmnet % set_engine("glmnet")rec_glmnet % step_mutate(date_num = as.numeric(date)) %>% step_date(date, features = "month") %>% step_rm(date) %>% step_dummy(all_nominal_predictors(), one_hot = TRUE) %>% step_normalize(all_numeric_predictors()) glmnet_fit % add_recipe(rec_glmnet) %>% add_model(model_glmnet) %>% fit(df_gold) #Modeltime Tablegold_models % modeltime_resample_accuracy(summary_fns = mean) %>% table_modeltime_accuracy(.interactive = FALSE)#Calibration for the Prophet Model calibration_prophet % modeltime_calibrate(new_data = df_gold)#Accuracy of the finalized modelcalibration_prophet %>% modeltime_accuracy(metric_set = metric_set(rmse, rsq, mape))#Forecast Forwardcalibration_prophet %>% modeltime_forecast(h = "6 months", actual_data = df_gold %>% filter(date>= as.Date("2025-01-01"))) %>% plot_modeltime_forecast(.interactive = FALSE, .legend_show = FALSE, .line_size = 1.5, .color_lab = "", .title = "Gold Futures") + labs(subtitle = "Predictive IntervalsML Model") + scale_x_date(expand = expansion(mult = c(.1, .1)), labels = scales::label_date(format = "%b'%y")) + scale_y_continuous(labels = scales::label_currency()) + theme_minimal(base_family = "Roboto Slab", base_size = 20) + theme(legend.position = "none", plot.background = element_rect(fill = "azure", color = "azure"), plot.title = element_text(face = "bold"), axis.text = element_text(face = "bold"), plot.subtitle = ggtext::element_markdown(face = "bold"))According to the Prophet model, the gold price seems to be difficult to reach the peak again by the end of the year.To leave a comment for the author, please follow the link and comment on their blog: DataGeeek.R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.Continue reading: Predicting Gold Prices: Backtesting of ML Models