This dataset contains Apple four quarters revenue in millions from 2010 to 2018. After selecting the best model, we will use it to forecast the next four quarters revenue. We use R as the programming language for this project.

Step one
Create a new variable called time to conduct the analysis because it helps to do plotting and also model creation.
After we added the column, let's glimpse the graph. It is clear to see that there is a seasonality and trend in this dataset.

The graph below shows the trend of each year. You can see that starting from 2012, the highest revenue is the first quarter and the lowest is the fourth quarter. However, from 2010 to 2011, the highest revenue is the last quarter and the lowest is the second quarter. It is because Apple changed its fiscal year to the 52 or 53-week period that ends on the last Saturday of September from 2012. This indicates that the first quarter is from later September to mid-January. Generally speaking, people would love to shop more in winter holiday time.

Step two
Model formations
Linear Model
Use the ts function to set up the response variable, then use window function to split the dataset into training and testing set, the cutoff point is (2016,4). Finally, use the tslm function for the model creation.
Residual plot

MSE:114191876,MAD:9812.1,MAPE:18%
2. Quadratic Model
Use the same method as linear model, but just change the model formula to quadratic.
Residual plot

MSE:199075964,MAD:11298.5,MAPE:17%
3. Holt-Winters Exponential Smoothing
For Holt-Winters Exponential Smoothing, I used ets function, instead of tslm. Other than that, the data preparation process is the same as the previous models.
I tried two techniques for this model, additive and multiplicative.
The MSE,MAD and MAPE for additive technique are 26600373.58,3989.26,13%, respectively.
The MSE,MAD and MAPE for multiplicative technique are 12511097.63,2655.765,7%, respectively.
By comparison, the multiplicative technique is outperforming the additive technique because it generates lower MSE,MAD and MAPE.
The residual plot for multiplicative technique

By comparing the MSE,MAD and MAPE of the three models, Linear, Quadratic and Holt-Winters Exponential Smoothing, we can see that Holt-Winters Multiplicative is the best fitted model because it generates lower MSE,MAD and MAPE.
We can also visualize the comparison of the three models in a graph. The fitted values of Holt-Winters Multiplicative model is clearly more closer to actual values.

Let's use Holt-Winters Multiplicative model to predict the revenue for the next four quarters.
We use the default 95% confidence for this forecast.

Komentarze