Data Set:

This data set contains time series data of the monthly electricity production in the United States, spanning from January 1985 to December 2017. The data was collected by the Federal Reserve Bank of St. Louis and consists of two columns: the date of the production and the electricity production in megawatt-hours (MWh). The data set includes a total of 397 observations but is cut down to only include the 150 most recent observations.

The variables in the data set include Date and IPG2211AN.

Time series:

Electric production uses monthly data, meaning that the frequency is 12. The graph that is created displays the monthly US electricity production over time, with the x-axis representing the date and the y-axis representing the electricity production in megawatt-hours. The plot can be used to identify trends, patterns, and seasonality in the electricity production data over the period from August 2005 to December 2017.

Forecasting with Decomposing:

This graph displays the decomposition of the time series data into its trend, seasonal, and random components. It allows for the visualization of the underlying patterns and trends in the data that are not immediately visible in the raw data.

The decomposition plot is a useful way to visualize the different components of a time series. The plot has four panels: the original time series, the trend component, the seasonal component, and the remainder component. The trend panel shows the overall direction of the data, whether it be increasing, decreasing, or remaining constant. The seasonal panel shows the regular pattern of the data, with peaks and troughs that repeat over time. The remainder panel shows the random fluctuations of the data that are not accounted for by the trend or seasonal components.

This graph is also used for decomposition, however, unlike the previous graph which used a classical decomposition method, this graph uses a seasonal-trend decomposition based on Loess (STL) method.

The STL method is a non-parametric approach to time series decomposition, which uses local regression to estimate the trend and seasonal components of the time series. In contrast, the classical decomposition method assumes that the trend and seasonal components follow specific mathematical models, such as linear or exponential functions.

STL decomposition helps with understanding the underlying patterns and trends in the data set, as well as being used to identify seasonal patterns, long-term trends, and random fluctuations in the data.

This code performs time series forecasting with decomposition using the STL method for four different training sets (n144, n109, n73, n48). It then compares the forecast errors for each training set using two metrics: Mean Squared Error (MSE) and Mean Absolute Percentage Error (MAPE).

The table has two columns, one for MSE and one for MAPE, and four rows, one for each training set, labeled by the number of observations in each set.

The sample size of 48 has the lowest MSE value of 26.42848, indicating that the forecast accuracy is the best with this sample size. However, it also has the highest MAPE value of 0.0355194, which indicates that the average absolute percentage difference between the forecasted values and actual values is relatively high.

In this case, the worst sample size would be n73, with the highest MSE value of 27.71894, and a high Mappe value of 0.0347812. This puts n73 as having worse MSE and MAPE value than n144 and n109, making those two samples sizes objectively better than n73.

However,since all of the sample sizes are relatively the same when it comes to MSE and MAPPE values and each having their own strengths and weaknesses the choice of sample size is ultimately up to the individual.

## Warning: package 'forecast' was built under R version 4.2.3
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
Error comparison between forecast results with different sample sizes
MSE MAPE
n.144 26.92753 0.0346743
n.109 26.83099 0.0345234
n. 73 27.71894 0.0347812
n. 48 26.42848 0.0355194

This plot provides a visual representation of the above table. The MSE values are in red while the MAPE values are in blue. The graphs interpretation is the same as the table above.