Operations need to have demand forecasts in order to establish optimal resource allocation policies. But, when we make predictions the only thing that we assure is the occurrence of prediction errors. Fortunately, there is no need to be 100% accurate to succeed, we just need to perform better than our competitors. In this exercise we will learn a practical approach to predict using the forecast package.

Answers to the exercises are available here.

**Exercise 1**

Plot the fmsales data from expsmooth package.

**Exercise 2**

The data obtained are in weeks. In order to learn how to manipulate `ts`

function, create a new time serie, which is based on the previously one, starting at January, 2011.

**Exercise 3**

Use `decompose`

function to plot: observed, trend, seasonal and random.

**Exercise 4**

Use the moving average approach to create a vector of predictions. Consider that in this company you cannot change your purchasing planning for the next 3 months (time fence). So, there is no need of rolling statistics and you only need to make plans 4 times per year.

**Exercise 5**

Use the function `accuracy`

to compare the actual values and de predicting ones.

**Exercise 6**

Use the a simple exponential approach to create a vector of predictions. Consider the same time fence and planning event previously defined.

**Exercise 7**

Calculate the accuracy again and compare the performance using RSME. Which one is the best?

**Exercise 8**

Use the a double exponential approach, that consider trends, to make predictions for the next 3 months.

**Exercise 9**

Use the a triple exponential approach, that consider trend, and seasonal components, to make predictions for the next 3 months.

**Exercise 10**

Use the `summary`

function to find the RMSE and other information of this last model.

**What's next:**

- Explore all our (>1000) R exercises
- Find an R course using our R Course Finder directory
- Subscribe to receive weekly updates and bonus sets by email
- Share with your friends and colleagues using the buttons below

## Leave a Reply