The data – historical gold prices
Regression analysis is a statistical tool for understanding the relationship between variables. In this chapter, we will implement a nonlinear regression to predict the gold price based on the historic gold prices. For this example, we will use the historical gold prices from January 2003 to May 2013 in a monthly range, obtained from www.gold.org. Finally, we will forecast the gold price for June 2013 and will contrast it with the real price from an independent source. The complete datasets (since December 1978) can be found at http://gold.org/download/value/stats/statistics/xls/gold_prices.xls.
The first seven records of the CSV file (gold.csv
) look as follows:
date,price 1/31/2003,367.5 2/28/2003,347.5 3/31/2003,334.9 4/30/2003,336.8 5/30/2003,361.4 6/30/2003,346.0 7/31/2003,354.8
In this example, we will implement a Kernel ridge regression with the original time series and the smoothed time series, to compare the differences in the output.