Introduction

The dataset I chose contains gold prices for various countries, listed in their respective currencies, with the date of observation starting from January 31, 1990.

Load the dataset

gold_price <- read.csv("C:\\Users\\yinan\\downloads\\GoldPrice.csv")
print(colnames(gold_price))
##  [1] "Date"                      "United.States.USD."       
##  [3] "Europe.EUR."               "Japan.JPY."               
##  [5] "United.Kingdom.GBP."       "Canada.CAD."              
##  [7] "Switzerland.CHF."          "India.INR."               
##  [9] "China.CNY."                "Turkey.TRY."              
## [11] "Saudi.Arabia.SAR."         "Indonesia.IDR."           
## [13] "United.Arab.Emirates.AED." "Thailand.THB."            
## [15] "Vietnam.VND."              "Egypt.EGP."               
## [17] "South.Korean.KRW."         "Australia.AUD."           
## [19] "South.Africa.ZAR."

Data Prep

gold_price$Date <- as.Date(gold_price$Date, "%d-%m-%Y")
gold_price <- gold_price[order(gold_price$Date), ]
library(ggplot2)
library(readr)
## Warning: package 'readr' was built under R version 4.3.3
ggplot(gold_price, aes(x = Date, y = `United.States.USD.`)) + 
  geom_line() + 
  ggtitle("Gold Price in United States (USD)") +
  xlab("Date") + 
  ylab("Price in USD") +
  theme_minimal()

ETS Models

options(repos = c(CRAN = "https://cran.rstudio.com/"))
install.packages("forecast")
## Installing package into 'C:/Users/yinan/AppData/Local/R/win-library/4.3'
## (as 'lib' is unspecified)
## package 'forecast' successfully unpacked and MD5 sums checked
## Warning: cannot remove prior installation of package 'forecast'
## Warning in file.copy(savedcopy, lib, recursive = TRUE): problem copying
## C:\Users\yinan\AppData\Local\R\win-library\4.3\00LOCK\forecast\libs\x64\forecast.dll
## to
## C:\Users\yinan\AppData\Local\R\win-library\4.3\forecast\libs\x64\forecast.dll:
## Permission denied
## Warning: restored 'forecast'
## 
## The downloaded binary packages are in
##  C:\Users\yinan\AppData\Local\Temp\RtmpaeraBv\downloaded_packages
library(forecast)
## Warning: package 'forecast' was built under R version 4.3.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
gold_prices_ts <- ts(gold_price$`United.States.USD.`, frequency=12)
model_ana <- ets(gold_prices_ts, model="ANA")
model_aadn <- ets(gold_prices_ts, model="AAN", damped=TRUE)
model_man <- ets(gold_prices_ts, model="MAN")

Plots

autoplot(model_ana) + 
  ggtitle("ETS Model (A,N,A) Forecast") +
  theme_light()

autoplot(model_aadn) + 
  ggtitle("ETS Model (A,Ad,N) Forecast") +
  theme_light()

autoplot(model_man) + 
  ggtitle("ETS Model (M,A,N) Forecast") +
  theme_light()

Conclusion

The ETS (A,Ad,N) model appears to perform better. It captures the underlying trend without being overly aggressive in its projections. This model smoothly extends the existing trend of the data while tempering future growth expectations, which aligns with the unpredictable nature of gold prices. The (A,N,A) model overestimates seasonal effects, and the (M,A,N) model potentially overemphasizes the continuation of the current trend. Therefore, the (A,Ad,N) model’s cautious forecast is more likely to be reliable.