Forecast Accuracy Using Naive Method

Using the naive method (most recent value) as the forecast for the next week, compute the following measures of forecast accuracy.

```{r naive-method, echo=TRUE # Time Series Data weeks <- 1:6 values <- c(17, 13, 15, 11, 17, 14)} `````

Naive Forecasting

```{forecasts <- c(NA, head(values, -1)) # Forecast for week 2-6 based on week 1-5 }

Errors

```{ errors <- forecasts - values # Forecast Error absolute_errors <- abs(errors) # Absolute Error squared_errors <- errors^2 # Squared Error percentage_errors <- abs(errors) / values * 100 # Percentage Error }

Calculating Forecast Accuracy Measures

```{ mae <- mean(absolute_errors, na.rm = TRUE) # Mean Absolute Error mse <- mean(squared_errors, na.rm = TRUE) # Mean Squared Error mape <- mean(percentage_errors, na.rm = TRUE) # Mean Absolute Percentage Error }

Forecast for Week 7

```{ forecast_week_7 <- tail(values, 1) }

Output Results

{ list( MAE = mae, MSE = mse, MAPE = mape, Forecast_Week_7 = forecast_week_7 ) }